35#include "Dictionary.h"
50template <
class E,
class OWNER=E>
68 const std::string &
str(
const E & value){
78 bool setValue(
const std::string & key, E & value){
96 E
getValue(
const E & value,
bool lenient=
true){
106 E
getValue(
const std::string &key,
bool lenient=
true){
144 const std::string &
getKey(
const std::string & s,
bool lenient=
true){
149 const char *
getKey(
const char * s,
bool lenient=
true){
154 const std::string &
getKey(
const E & value,
bool lenient=
true){
155 return dict.
getKey(value, lenient);
180 void convert(
const E & value, std::string &s){
182 s.assign(dict.
getKey(value));
186 void convert(
const std::string &s, E & value){
222template <
typename E,
bool STRICT=true>
240 template <
typename T>
241 void set(
const T & value){
278 template <
typename T>
285 void set(
const std::string &arg){
289 void set(
const char * arg){
293 void set(
const MultiEnumWrapper &arg){
297 template <
typename T>
298 void set(
const T & value){
333#define DRAIN_ENUM_CONV(enumtype) template <> class Converter<enumtype> : public Enum<enumtype> {}
338#define DRAIN_ENUM_DICT(enumtype) template <> const drain::Enum<enumtype>::dict_t drain::Enum<enumtype>::dict
339#define DRAIN_ENUM_DICT2(enumtype,owner) template <> const drain::Enum<enumtype,owner>::dict_t drain::Enum<enumtype,owner>::dict
341#define DRAIN_ENUM_ENTRY(nspace, key) {#key, nspace::key}
343#define DRAIN_ENUM_OSTREAM(enumtype) inline std::ostream & operator<<(std::ostream &ostr, const enumtype & e){return ostr << drain::Enum<enumtype>::dict.getKey(e);}
Two-way mapping between strings and objects of template class T.
Definition Dictionary.h:63
const K & getKey(const V &value, bool lenient=true) const
Identity mapping useful for type deduction of template arguments in functions.
Definition Dictionary.h:172
const V & getValue(const K &key, bool lenient=true) const
Given a key, return the first value associated with it.
Definition Dictionary.h:149
EnumWrapper(const E &x)
All the other constructors, including default constructor.
Definition Enum.h:236
MultiEnumWrapper(const T &arg)
Default constructor.
Definition Enum.h:280
Definition DataSelector.cpp:1277
A container for a static dictionary of enumeration values.
Definition Enum.h:51
static E getValue(const char *key, bool lenient=true)
Convenience for object.set(...) like commands.
Definition Enum.h:116
static const std::string & str(const E &value)
Convenience.
Definition Enum.h:68
static E getValue(const E &value, bool lenient=true)
Convenience for object.set(...) like commands.
Definition Enum.h:96
static bool setValue(const std::string &key, E &value)
Assign string values to an enumeration type.
Definition Enum.h:78
static void convert(const E &value, std::string &s)
Experimental. Convenience for object.set(...) like commands.
Definition Enum.h:180
static const std::string & getKey(const std::string &s, bool lenient=true)
Convenience for object.set(...) like commands.
Definition Enum.h:144
static E getValue(const std::string &key, bool lenient=true)
Convenience for object.set(...) like commands.
Definition Enum.h:106