mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-18 05:36:32 +00:00
Generate a C++ function for EnumValues{{ENUM_NAME}} (#4337)
* enables "for each" logic on enumeration types
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
01c50d57a6
commit
dadd1a926e
Binary file not shown.
@@ -39,6 +39,15 @@ enum Color {
|
||||
Color_ANY = 11
|
||||
};
|
||||
|
||||
inline Color (&EnumValuesColor())[3] {
|
||||
static Color values[] = {
|
||||
Color_Red,
|
||||
Color_Green,
|
||||
Color_Blue
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char **EnumNamesColor() {
|
||||
static const char *names[] = {
|
||||
"Red",
|
||||
@@ -68,6 +77,16 @@ enum Any {
|
||||
Any_MAX = Any_MyGame_Example2_Monster
|
||||
};
|
||||
|
||||
inline Any (&EnumValuesAny())[4] {
|
||||
static Any values[] = {
|
||||
Any_NONE,
|
||||
Any_Monster,
|
||||
Any_TestSimpleTableWithEnum,
|
||||
Any_MyGame_Example2_Monster
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char **EnumNamesAny() {
|
||||
static const char *names[] = {
|
||||
"NONE",
|
||||
|
||||
@@ -21,6 +21,15 @@ enum EnumInNestedNS {
|
||||
EnumInNestedNS_MAX = EnumInNestedNS_C
|
||||
};
|
||||
|
||||
inline EnumInNestedNS (&EnumValuesEnumInNestedNS())[3] {
|
||||
static EnumInNestedNS values[] = {
|
||||
EnumInNestedNS_A,
|
||||
EnumInNestedNS_B,
|
||||
EnumInNestedNS_C
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char **EnumNamesEnumInNestedNS() {
|
||||
static const char *names[] = {
|
||||
"A",
|
||||
|
||||
@@ -28,6 +28,19 @@ enum Character {
|
||||
Character_MAX = Character_Unused
|
||||
};
|
||||
|
||||
inline Character (&EnumValuesCharacter())[7] {
|
||||
static Character values[] = {
|
||||
Character_NONE,
|
||||
Character_MuLan,
|
||||
Character_Rapunzel,
|
||||
Character_Belle,
|
||||
Character_BookFan,
|
||||
Character_Other,
|
||||
Character_Unused
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char **EnumNamesCharacter() {
|
||||
static const char *names[] = {
|
||||
"NONE",
|
||||
|
||||
Reference in New Issue
Block a user