![]() |
Gorgon Game Engine
|
Gorgon Library supports stream-able, parsable and enumerable enumerations.
A single macro call with enum type and enum value - name pairs is all that is required. There is no need to modify original enum definition. Additionally, this system allows multiple names for a single enum value which will be used while parsing a string to the enum type. If there are multiple names, first one is used while converting enum to string.
There are some restrictions to the use of macros supplied with this system. First restrictions is that the macro call should be done in the same namespace as the original enum. Both regular enum and enum class is supported. For a simple namespace enum or enum class, DefineEnumStrings macro should be used. This macro requires only the name of the enum along with the value - name pairs. Enum type supplied to the DefineEnumStrings macro cannot contain scope resolution operator. This eliminates the possibility of using class member enums with this macro. However, for this specific purpose, DefineEnumStringsCM macro is created. This macro allows class member enums to be used by suppling class name as the first parameter.
String::Parse() method requires name of the type, which is automatically deduced from the typename. If this is not desired DefineEnumStringsTN macro could be used. This macro has a parameter after the type which will be used as the type name. Additionally DefineEnumStringsCMTN is also defined to be used with class member enums.
Example