|
libcommonc++
0.7
|
A bidirectional mapping between enum values and static string constants. More...
#include <EnumTraits.h++>


Public Member Functions | |
| EnumMap () | |
| Constructor. More... | |
| ~EnumMap () | |
| Destructor. More... | |
| EnumMap & | add (E value, const char *str) |
| Add a mapping. More... | |
| E | valueForString (const char *str) const |
| Map a string to its enum value. More... | |
| const char * | stringForValue (E value) const |
| Map an enum value to its string. More... | |
Private Attributes | |
| T | elements |
| STL member. More... | |
A bidirectional mapping between enum values and static string constants.
An EnumMap can be constructed as follows:
enum FileType { TypeFile, TypeDirectory, TypeSymLink };EnumMap<FileType> fileTypeMap;
fileTypeMap.add(TypeFile, "file")
.add(TypeDirectory, "directory")
.add(TypeSymLink, "symlink");
|
inline |
Constructor.
|
inline |
Destructor.
|
inline |
Add a mapping.
|
inline |
Map an enum value to its string.
| value | The enum value to map. |
|
inline |
Map a string to its enum value.
| str | The string to map. |