|
plptools
|
maps integers (typically: enumeration values) to Strings. More...
#include <Enum.h>
Public Member Functions | |
| void | add (long, const char *) |
| adds a new int -> string mapping Does NOT take over responsibility for the pointer (i.e. More... | |
| std::string | lookup (long) const |
| returns the string representation for this integer. More... | |
| long | lookup (const char *) const |
| returns the integer associated with the given string or -1 if the value is not found (XXX: this should throw an exception). More... | |
| bool | inRange (long) const |
| returns true, if we have an representation for the given integer. More... | |
Private Types | |
| typedef std::multimap< long, const char * > | i2s_map_t |
| there can be one value, mapping to multiple strings. More... | |
Private Attributes | |
| i2s_map_t | stringMap |
| just for the record. More... | |
maps integers (typically: enumeration values) to Strings.
Takes care of the fact, that an Integer may map to multiple strings (sometimes multiple enumeration values represent the same integer).
Provides a means to get the string representation of an integer and vice versa.
|
private |
| void EnumBase::i2sMapper::add | ( | long | i, |
| const char * | s | ||
| ) |
| bool EnumBase::i2sMapper::inRange | ( | long | i | ) | const |
| long EnumBase::i2sMapper::lookup | ( | const char * | s | ) | const |
| string EnumBase::i2sMapper::lookup | ( | long | i | ) | const |
|
private |
just for the record.
Mapping back a string to the Integer value in question. Since Symbols must be unique, there is only a 1:1 relation as opposed to i2s_map_t. So we can use a normal map here.
Since in the usual application, mapping a string back to its value is not important performance wise (typically in a frontend), so it is implemented as exhaustive search, not as extra map. Saves some bits of memrory ..