Quark  0.1
EnumTraits.h++ File Reference
#include <QList>
#include <QString>
#include <QStringList>
#include <quark/EnumTraitsImpl.h++>
Include dependency graph for EnumTraits.h++:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  EnumTraits< E >
 A collection of static methods for accessing enum type metadata. More...
 

Namespaces

 quark
 
 quark::util
 General-purpose utilities.
 

Macros

#define QUARK_DECLARE_ENUM_TRAITS(TYPE, DEFAULT_VALUE, INVALID_VALUE, VALUE_LIST, LABEL_LIST)
 Registers the metadata for an enum type so that it can be used with the quark::util::EnumTraits template. More...
 

Macro Definition Documentation

◆ QUARK_DECLARE_ENUM_TRAITS

#define QUARK_DECLARE_ENUM_TRAITS (   TYPE,
  DEFAULT_VALUE,
  INVALID_VALUE,
  VALUE_LIST,
  LABEL_LIST 
)
Value:
namespace quark { namespace util { \
template<> EnumMap<TYPE> EnumTraits<TYPE>::_map(DEFAULT_VALUE, \
INVALID_VALUE, VALUE_LIST, LABEL_LIST); \
} }
Definition: BarChartView.h++:6

Registers the metadata for an enum type so that it can be used with the quark::util::EnumTraits template.

For example:

enum Direction { DirInvalid = -1, DirNone = 0, DirNorth, DirEast, DirSouth,
    DirWest };
QUARK_DECLARE_ENUM_TRAITS(Direction, DirNone, DirInvalid,
    (QList<Direction>() << DirNone << DirNorth << DirEast << DirSouth
        << DirWest),
    (QStringList() << "None" << "North" << "East" << "South" << "West"));
Parameters
TYPEThe enum type.
DEFAULT_VALUEThe "default" value for the enum type.
INVALID_VALUEThe "invalid" value for the enum type.
VALUE_LISTA QList<E> containing the valid enum values for the enum type.
LABEL_LISTA QStringList containing the labels for the valid values for the enum type.