#include <EnumDictionary.h>
Public Member Functions |
|
| CEnumDictionary (SI_Char const **in_ppStringArray) | |
| Constructor. |
|
| const SI_Char * | ToString (Enum in_Value) const |
| Convert from enum to string. |
|
| SI_Bool | ToEnum (Enum &out_rEnum, const SI_Char *in_pValue) const |
| Convert from string to enum. |
|
| Enum | Enumerated type | |
| size | Value of the last valid entry of the enumerated type |
// the enum type enum MyEnum { SomeValue = 1, SomeOtherValue = 2, TheLastValue = 4 }; // the strings matching the enum values static const SI_Char* g_szMyEnumStrings[] = { "SomeValue", "SomeOtherValue", "TheLastValue" }; // The Enum dictionary to convert from enum to string // or string to enum CEnumDictionary<MyEnum, TheLastValue> l_dict( g_szMyEnumStrings );
| CEnumDictionary | ( | SI_Char const ** | in_ppStringArray | ) | [inline] |
Constructor.
| in_ppStringArray | Array containing the strings. |
in_ppStringArray is not freed upon destruction.// example of typical in_ppStringArray static const SI_Char* g_szMyEnumStrings[] = { "SomeValue", "SomeOtherValue", "TheLastValue" };
| const SI_Char* ToString | ( | Enum | in_Value | ) | const [inline] |
Convert from enum to string.
| in_Value | Enum value to convert |
CEnumDictionary<EnumType, LastEnumValue> l_EnumDict(g_szMyEnumStrings); const SI_Char *l_szStringValue = l_EnumDict.ToString(LastEnumValue);
| SI_Bool ToEnum | ( | Enum & | out_rEnum, | |
| const SI_Char * | in_pValue | |||
| ) | const [inline] |
Convert from string to enum.
| out_rEnum | Resulting enum value | |
| in_pValue | String value to convert |
| false | There is no matching enum value | |
| true | The matching enum value was found |
CEnumDictionary<EnumType, LastEnumValue> l_EnumDict(g_szMyEnumStrings); EnumType l_EnumValue; if (!l_EnumDict.ToEnum(l_EnumValue, "LastEnumValue")) { // conversion failed }