81 void add(
long,
const char*);
88 std::string
lookup(
long)
const;
96 long lookup (
const char *)
const;
208 inline operator E ()
const {
return value; }
220 operator const char *()
const {
return toString().c_str(); }
299#define ENUM_DEFINITION_BEGIN(EnumName, initWith) \
304template <> Enum<EnumName>::sdata::sdata() : \
305 name(#EnumName),defaultValue(initWith) {
307#define ENUM_DEFINITION_END(EnumName) \
308} template Enum< EnumName >::sdata Enum< EnumName >::staticData;
std::ostream & operator<<(std::ostream &out, const Enum< E > &e)
Writes enumeration's string representation.
maps integers (typically: enumeration values) to Strings.
std::multimap< long, const char * > i2s_map_t
there can be one value, mapping to multiple strings.
bool inRange(long) const
returns true, if we have an representation for the given integer.
void add(long, const char *)
adds a new int -> string mapping Does NOT take over responsibility for the pointer (i....
i2s_map_t stringMap
just for the record.
std::string lookup(long) const
returns the string representation for this integer.
the Base for the Enum template.
Wrapper class featuring range-checking and string representation of enumerated values.
static bool inRange(long i)
This static member returns true, if the integer value given fits int the range of this Enumeration.
static std::string getEnumName()
returns the Name for this enumeration.
E value
The actual value hold by this instance.
static E getValueFor(const std::string &s)
returns the Value for a specific String.
Enum()
default constructor.
static std::string getStringFor(E e)
gives the String represenatation of a specific value of this Enumeration.
Enum & operator=(E setval)
assign an Enumeration of this type.
Enum(const std::string &s)
initialize with the string representation XXX: throw Exception if not found ?
Enum(E init)
initialize with Enumeration given.
std::string toString() const
returns the String representation for the value represented by this instance.
sdata()
The constructor of the static data part.