Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/rtti/Enum.h>
Classes | |
class | make |
class | Value |
Public Types | |
typedef Vector< Value >::Iter | Iter |
Public Types inherited from Type | |
typedef HashMap< string, const Type * >::Iter | TypeIter |
Public Member Functions | |
Enum (const make &make) | |
Enum (cstring name, const Value values[]) | |
Iter | values (void) const |
virtual const Type & | type (void) const |
virtual int | valueFor (string text) const |
virtual cstring | nameFor (int value) const |
virtual bool | canCast (const Type *t) const |
virtual bool | isEnum (void) const |
virtual const Enumerable & | asEnum (void) const |
Public Member Functions inherited from Type | |
Type (string name="") | |
virtual | ~Type (void) |
string | name (void) const |
const PointerType & | pointer (void) const |
virtual bool | isVoid (void) const |
virtual bool | isBool (void) const |
virtual bool | isInt (void) const |
virtual bool | isFloat (void) const |
virtual bool | isPtr (void) const |
virtual const PointerType & | asPtr (void) const |
virtual bool | isClass (void) const |
virtual const AbstractClass & | asClass (void) const |
virtual bool | isSerial (void) const |
virtual const Serializable & | asSerial (void) const |
virtual const TemplateType * | asTemplate (void) const |
virtual const InstanceType * | asInstance (void) const |
virtual const ParamType * | asParam (void) const |
void | initialize (void) |
bool | operator== (const Type &t) const |
bool | operator!= (const Type &t) const |
Public Member Functions inherited from Enumerable | |
virtual | ~Enumerable (void) |
Additional Inherited Members | |
Static Public Member Functions inherited from Type | |
static const Type * | get (string name) |
static TypeIter | types (void) |
Static Public Attributes inherited from Type | |
static const Type & | param0 |
static const Type & | param1 |
static const Type & | param2 |
static const Type & | param3 |
Type for an enumerated type. Recording an enumration in the RTTI system requires several actions:
To help providing this stuff, two macros are provided, DECLARE_ENUM is used in the header file and DEFINE_ENUM in the source file.
The code below represents an heade file where an enumerated type is provided:
The code below shows the source corresponding part:
Concrete representation of an enumerated type.
Constructor using a make object.
make | Object providing enumeration description. |
Old-style enumerated type builder.
name | Full-qualified enumerated name. |
values | Values of the enumerated type. |
Old-style constructor only provided for backward compatibility.
References Enum::values().
|
virtual |
Get the enumeration description corresponding to this type. If the type is not enumerated, an assertion failure is raised.
Reimplemented from Type.
Test if the type can be casted to the given type.
t | Type to cast to. |
Reimplemented from Type.
References Type::isInt().
|
virtual |
Find the name corresponding to the gi en enumerated value.
value | Value to look text for. |
Implements Enumerable.
References elm::rtti::value(), and Enum::values().
Get the type corresponding to this enumerable interface.
Implements Enumerable.
|
virtual |
Referenced by Enum::Enum(), and Enum::nameFor().