It would be very helpful if Fast-DDS-Gen could generate enum-to-string and string-to-enum mappings automatically for enums defined in IDL files.
Proposed Solution:
- Extend the
EnumTypeCode.java file to include methods for generating mappings.
- Modify the
CommonEnumType.stg template to generate helper functions like enumToString and stringToEnum.
Example Output:
inline const char* enumToString(MyEnum value) {
switch (value) {
case MyEnum::Value1: return "Value1";
case MyEnum::Value2: return "Value2";
// ...
default: return "UNKNOWN";
}
}
inline MyEnum stringToEnum(const std::string& str) {
if (str == "Value1") return MyEnum::Value1;
if (str == "Value2") return MyEnum::Value2;
// ...
return MyEnum::UNKNOWN;
}
It would be very helpful if Fast-DDS-Gen could generate
enum-to-stringandstring-to-enummappings automatically for enums defined in IDL files.Proposed Solution:
EnumTypeCode.javafile to include methods for generating mappings.CommonEnumType.stgtemplate to generate helper functions likeenumToStringandstringToEnum.Example Output: