Merge "Optionally prefix each exported enum value (name) with a string specified in the"
diff --git a/EnumType.cpp b/EnumType.cpp
index d5abf6d..5513596 100644
--- a/EnumType.cpp
+++ b/EnumType.cpp
@@ -329,6 +329,16 @@
name = quotedString.substr(1, quotedString.size() - 2);
}
+ std::string valuePrefix;
+
+ const AnnotationParam *prefixParam = annotation->getParam("value_prefix");
+ if (prefixParam != nullptr) {
+ CHECK_EQ(prefixParam->getValues()->size(), 1u);
+
+ std::string quotedString = prefixParam->getValues()->at(0);
+ valuePrefix = quotedString.substr(1, quotedString.size() - 2);
+ }
+
const ScalarType *scalarType = mStorageType->resolveToScalarType();
CHECK(scalarType != NULL);
@@ -349,7 +359,7 @@
const auto &type = *it;
for (const auto &entry : type->values()) {
- out << entry->name();
+ out << valuePrefix << entry->name();
std::string value = entry->cppValue(scalarType->getKind());
CHECK(!value.empty()); // use autofilled values for c++.