|
ponder
3.2
C++ reflection library
|
ponder::Enum represents a metaenum composed of <name, value> pairs More...
#include <enum.hpp>
Inheritance diagram for ponder::Enum:Classes | |
| struct | Pair |
| Structure defining the <name, value> pairs stored in metaenums. More... | |
Public Types | |
| typedef long | EnumValue |
| Type used to hold the enum value. | |
Public Member Functions | |
| IdReturn | name () const |
| Return the name of the metaenum. More... | |
| size_t | size () const |
| Return the size of the metaenum. More... | |
| Pair | pair (size_t index) const |
| Get a pair by its index. More... | |
| bool | hasName (IdRef name) const |
| Check if the enum contains a name. More... | |
| bool | hasValue (EnumValue value) const |
| Check if the enum contains a value. More... | |
| template<typename E > | |
| bool | hasValue (E value) const |
| Check if the enum contains a value. More... | |
| IdReturn | name (EnumValue value) const |
| Return the name corresponding to given a value. More... | |
| template<typename E > | |
| IdReturn | name (E value) const |
| Return the name corresponding to given a value for enum class. More... | |
| EnumValue | value (IdRef name) const |
| Return the value corresponding to given a name. More... | |
| template<typename E > | |
| E | value (IdRef name) const |
| Return the value corresponding to given a name for enum class. More... | |
| bool | operator== (const Enum &other) const |
| Operator == to check equality between two metaenums. More... | |
| bool | operator!= (const Enum &other) const |
| Operator != to check inequality between two metaenums. More... | |
Static Public Member Functions | |
| template<typename T > | |
| static EnumBuilder | declare (IdRef name=IdRef()) |
| Declare a new metaenum. More... | |
| template<typename T > | |
| static void | undeclare () |
| Undeclare an existing metaenum. More... | |
Friends | |
| class | EnumBuilder |
| class | detail::EnumManager |
Related Functions | |
(Note that these are not member functions.) | |
| size_t | enumCount () |
| Get the total number of existing metaenums. More... | |
| const Enum & | enumByName (IdRef name) |
| Get a metaenum from its name. More... | |
| template<typename T > | |
| const Enum & | enumByObject (T value) |
| Get a metaenum from a C++ object. More... | |
| template<typename T > | |
| const Enum & | enumByType () |
| Get a metaenum from its C++ type. More... | |
| template<typename T > | |
| const Enum * | enumByTypeSafe () |
| Get a metaenum from its C++ type. More... | |
ponder::Enum represents a metaenum composed of <name, value> pairs
Enums are declared, bound to a C++ type and filled with the declare template function.
It then provides a set of accessors to retrieve names, values and pairs contained in it.
|
static |
Declare a new metaenum.
This is the function to call to create a new metaenum. The template parameter T is the C++ enum type that will be bound to the metaclass.
| name | Name of the metaenum in Ponder. This name identifies the metaenum and thus has to be unique |
| bool ponder::Enum::hasName | ( | IdRef | name | ) | const |
Check if the enum contains a name.
| name | Name to check |
|
inline |
Check if the enum contains a value.
This generic version of hasValue() allows enum classes to be queried.
| value | Value to check |
| bool ponder::Enum::hasValue | ( | EnumValue | value | ) | const |
Check if the enum contains a value.
| value | Value to check |
| IdReturn ponder::Enum::name | ( | ) | const |
Return the name of the metaenum.
|
inline |
Return the name corresponding to given a value for enum class.
| value | Value to get |
| InvalidEnumValue | value doesn't exist in the metaenum |
| IdReturn ponder::Enum::name | ( | EnumValue | value | ) | const |
Return the name corresponding to given a value.
| value | Value to get |
| InvalidEnumValue | value doesn't exist in the metaenum |
| bool ponder::Enum::operator!= | ( | const Enum & | other | ) | const |
Operator != to check inequality between two metaenums.
| other | Metaenum to compare with this |
| bool ponder::Enum::operator== | ( | const Enum & | other | ) | const |
Operator == to check equality between two metaenums.
Two metaenums are equal if their name is the same.
| other | Metaenum to compare with this |
| Pair ponder::Enum::pair | ( | size_t | index | ) | const |
Get a pair by its index.
| index | Index of the pair to get |
| OutOfRange | index is out of range |
| size_t ponder::Enum::size | ( | ) | const |
Return the size of the metaenum.
|
static |
Undeclare an existing metaenum.
Call this to undeclare an Enum that you no longer require.
| name | Name of the existing metaenum in Ponder. |
| EnumValue ponder::Enum::value | ( | IdRef | name | ) | const |
Return the value corresponding to given a name.
| name | Name to get |
| InvalidEnumName | name doesn't exist in the metaenum |
|
inline |
Return the value corresponding to given a name for enum class.
Enum classes are strongly typed so the return type needs to be specified, e.g. MyEnum a = enum.value<MyEnum>("one");
| name | Name to get |
| InvalidEnumName | name doesn't exist in the metaenum |
|
related |
Get a metaenum from its name.
| name | Name of the metaenum to retrieve (case sensitive) |
| EnumNotFound | name is not a valid metaenum name |
|
related |
Get a metaenum from a C++ object.
It is equivalent to calling enumByType<T>(index).
| value | Value to get the metaenum of |
| EnumNotFound | no metaenum has been declared for T |
|
related |
Get a metaenum from its C++ type.
| EnumNotFound | no metaenum has been declared for T |
|
related |
Get a metaenum from its C++ type.
|
related |
Get the total number of existing metaenums.