51 #ifndef __EST_TNAMEDENUM_H__ 52 #define __EST_TNAMEDENUM_H__ 61 #define NAMED_ENUM_MAX_SYNONYMS (10) 69 template<
class ENUM,
class VAL,
class INFO>
88 virtual int eq_vals(VAL v1, VAL v2)
const {
return v1 == v2; };
91 void initialise(
const void *defs);
92 void initialise(
const void *defs, ENUM (*conv)(
const char *));
94 void initialise(ENUM unknown_e, VAL unknown_v) {
initialise(); p_unknown_enum=unknown_e; p_unknown_value = unknown_v;};
101 {initialise((
const void *)defs); };
103 {initialise((
const void *)defs, conv); };
108 ENUM
token(VAL value)
const;
109 ENUM
token(
int n)
const {
return nth_token(n); }
110 ENUM nth_token(
int n)
const;
111 VAL value(ENUM token,
int n=0)
const;
112 INFO &
info(ENUM token)
const;
116 int valid(ENUM token)
const {
return !eq_vals(value(token),p_unknown_value); };
126 int eq_vals(
const char *v1,
const char *v2)
const {
return strcmp(v1,v2) ==0; };
130 {this->initialise((
const void *)defs); };
132 {this->initialise((
const void *)defs, conv); };
133 const char *
name(ENUM tok,
int n=0)
const {
return this->value(tok,n); };
142 {this->initialise((
const void *)defs);};
144 {this->initialise((
const void *)defs, conv);};
154 {this->initialise(undef_e, undef_n);};
156 {this->initialise((
const void *)defs);};
158 {this->initialise((
const void *)defs, conv);};
EST_TValuedEnumI(EST_TValuedEnumDefinition< ENUM, VAL, INFO > defs[])
EST_TNamedEnum(EST_TValuedEnumDefinition< const char *, const char *, NO_INFO > defs[], ENUM(*conv)(const char *))
EST_TValuedEnumI(EST_TValuedEnumDefinition< const char *, VAL, INFO > defs[], ENUM(*conv)(const char *))
EST_write_status save(EST_String name, EST_TNamedEnum &definitive, char quote='"') const
int valid(ENUM token) const
#define NAMED_ENUM_MAX_SYNONYMS
EST_TNamedEnum(EST_TValuedEnumDefinition< ENUM, const char *, NO_INFO > defs[])
const char * name(ENUM tok, int n=0) const
int eq_vals(const char *v1, const char *v2) const
void initialise(ENUM unknown_e, VAL unknown_v)
EST_TNamedEnumI(EST_TValuedEnumDefinition< const char *, const char *, INFO > defs[], ENUM(*conv)(const char *))
VAL values[NAMED_ENUM_MAX_SYNONYMS]
EST_TValuedEnumDefinition< ENUM, VAL, INFO > * definitions
VAL unknown_value(void) const
EST_read_status load(EST_String name, EST_TNamedEnum &definitive)
EST_read_status load(EST_String name)
virtual int eq_vals(VAL v1, VAL v2) const
EST_TValuedEnum(EST_TValuedEnumDefinition< ENUM, VAL, NO_INFO > defs[])
EST_TValuedEnum(EST_TValuedEnumDefinition< const char *, VAL, NO_INFO > defs[], ENUM(*conv)(const char *))
ENUM unknown_enum(void) const
EST_write_status save(EST_String name, char quote='"') const
EST_TNamedEnum(ENUM undef_e, const char *undef_n=NULL)
EST_TNamedEnumI(EST_TValuedEnumDefinition< ENUM, const char *, INFO > defs[])