summaryrefslogtreecommitdiffstats
path: root/edify
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-06-20 00:56:49 +0200
committerTao Bao <tbao@google.com>2018-07-10 08:20:30 +0200
commit511d75962789837231459e53e86eaaa6a1ff6e06 (patch)
tree25e167440b5c06697a6b91640afd71be2fd965a6 /edify
parentMerge "applypatch: Restrict applypatch_check to eMMC targets." (diff)
downloadandroid_bootable_recovery-511d75962789837231459e53e86eaaa6a1ff6e06.tar
android_bootable_recovery-511d75962789837231459e53e86eaaa6a1ff6e06.tar.gz
android_bootable_recovery-511d75962789837231459e53e86eaaa6a1ff6e06.tar.bz2
android_bootable_recovery-511d75962789837231459e53e86eaaa6a1ff6e06.tar.lz
android_bootable_recovery-511d75962789837231459e53e86eaaa6a1ff6e06.tar.xz
android_bootable_recovery-511d75962789837231459e53e86eaaa6a1ff6e06.tar.zst
android_bootable_recovery-511d75962789837231459e53e86eaaa6a1ff6e06.zip
Diffstat (limited to '')
-rw-r--r--edify/expr.cpp8
-rw-r--r--edify/include/edify/expr.h19
2 files changed, 12 insertions, 15 deletions
diff --git a/edify/expr.cpp b/edify/expr.cpp
index 6823b7339..c090eb28a 100644
--- a/edify/expr.cpp
+++ b/edify/expr.cpp
@@ -51,9 +51,9 @@ bool Evaluate(State* state, const std::unique_ptr<Expr>& expr, std::string* resu
if (!v) {
return false;
}
- if (v->type != VAL_STRING) {
- ErrorAbort(state, kArgsParsingFailure, "expecting string, got value type %d", v->type);
- return false;
+ if (v->type != Value::Type::STRING) {
+ ErrorAbort(state, kArgsParsingFailure, "expecting string, got value type %d", v->type);
+ return false;
}
*result = v->data;
@@ -68,7 +68,7 @@ Value* StringValue(const char* str) {
if (str == nullptr) {
return nullptr;
}
- return new Value(VAL_STRING, str);
+ return new Value(Value::Type::STRING, str);
}
Value* StringValue(const std::string& str) {
diff --git a/edify/include/edify/expr.h b/edify/include/edify/expr.h
index 770d1cf0d..ccd200778 100644
--- a/edify/include/edify/expr.h
+++ b/edify/include/edify/expr.h
@@ -53,19 +53,16 @@ struct State {
bool is_retry = false;
};
-enum ValueType {
- VAL_INVALID = -1,
- VAL_STRING = 1,
- VAL_BLOB = 2,
-};
-
struct Value {
- ValueType type;
- std::string data;
+ enum class Type {
+ STRING = 1,
+ BLOB = 2,
+ };
+
+ Value(Type type, const std::string& str) : type(type), data(str) {}
- Value(ValueType type, const std::string& str) :
- type(type),
- data(str) {}
+ Type type;
+ std::string data;
};
struct Expr;