49 EnumDef(
const char* nm,
const char* s[],
51 bool isValidKey(
const char*)
const;
52 int indexOf(
const char* s)
const;
54 int getEnumValForIndex(
int)
const;
55 const char* getKeyForIndex(
int i)
const;
56 uiString getUiStringForIndex(
int i)
const;
57 void setUiStringForIndex(
int,
const uiString&);
61 const char* getIconFileForIndex(
int idx)
const;
62 void setIconFileForIndex(
int idx,
const char*);
67 void remove(
const char* key);
68 void add(
const char* key,
const uiString&,
69 int enumval,
const char* iconfile);
80 {
return isValidKey(key); }
81 const char*
convert(
int idx)
const {
return getKeyForIndex(idx); }
89 EnumDefImpl(
const char* nm,
const char* s[],
short nrs=0);
90 bool parse(
const char* txt,ENUM& res)
const;
91 bool parse(
const IOPar& par,
const char* key,ENUM& res)
const;
92 ENUM parse(
const char* txt)
const;
93 ENUM getEnumForIndex(
int idx)
const;
94 const char* getKey(ENUM theenum)
const;
100 const char*
toString(ENUM theenum)
const {
return getKey(theenum); }
258 #define mDeclareEnumUtils(enm) \ 260 static const EnumDefImpl<enm>& enm##Def(); \ 261 static const char** enm##Names();\ 262 static bool parseEnum##enm(const char*,enm&); \ 263 static bool parseEnum(const char*,enm&); \ 264 static bool parseEnum(const IOPar&,const char*,enm&); \ 265 static enm parseEnum##enm(const char*); \ 266 static const char* toString(enm); \ 267 static uiString toUiString(enm); \ 268 static const char* get##enm##String(enm); \ 270 static const char* enm##Keys_[]; \ 271 static ConstPtrMan<EnumDefImpl<enm> > enm##Definition_; \ 274 #define mDeclareNameSpaceEnumUtils(mod,enm) \ 275 mExtern(mod) const EnumDefImpl<enm>& enm##Def(); \ 276 mExtern(mod) const char** enm##Names();\ 277 extern const char* enm##Keys_[]; \ 278 mExtern(mod) bool parseEnum(const IOPar&,const char*,enm&); \ 279 mExtern(mod) bool parseEnum(const char*,enm&); \ 280 mExtern(mod) bool parseEnum##enm(const char*,enm&); \ 281 mExtern(mod) enm parseEnum##enm(const char*); \ 282 mExtern(mod) const char* toString(enm); \ 283 mExtern(mod) uiString toUiString(enm); \ 284 mExtern(mod) const char* get##enm##String(enm); 286 #define _DefineEnumNames(prefix,enm,deflen,prettynm) \ 287 const EnumDefImpl<prefix::enm>& prefix::enm##Def() \ 289 if ( !enm##Definition_ ) \ 291 EnumDefImpl<prefix::enm>* newdef = \ 292 new EnumDefImpl<prefix::enm>(prettynm,prefix::enm##Keys_,deflen); \ 293 if ( !enm##Definition_.setIfNull( newdef ) ) \ 297 return *enm##Definition_; \ 299 const char** prefix::enm##Names() \ 300 { return prefix::enm##Keys_; } \ 301 bool prefix::parseEnum##enm(const char* txt, prefix::enm& res ) \ 303 const bool isok = prefix::parseEnum( txt, res ); \ 304 if ( !isok ) res = (prefix::enm) 0; \ 307 bool prefix::parseEnum(const char* txt, prefix::enm& res ) \ 308 { return prefix::enm##Def().parse( txt, res ); } \ 309 bool prefix::parseEnum( const IOPar& par, const char* key, prefix::enm& res ) \ 310 { return prefix::enm##Def().parse( par, key, res ); } \ 311 prefix::enm prefix::parseEnum##enm(const char* txt) \ 312 { return prefix::enm##Def().parse( txt ); } \ 313 const char* prefix::get##enm##String( prefix::enm theenum ) \ 314 { return prefix::toString( theenum ); } \ 315 const char* prefix::toString( prefix::enm theenum ) \ 316 { return enm##Def().getKey( theenum ); } \ 317 uiString prefix::toUiString( prefix::enm theenum ) \ 318 { return enm##Def().toUiString( theenum ); } \ 319 const char* prefix::enm##Keys_[] = 322 #define DefineEnumNames(clss,enm,deflen,prettynm) \ 323 ConstPtrMan<EnumDefImpl<clss::enm> > clss::enm##Definition_ = 0; \ 324 _DefineEnumNames( clss, enm, deflen, prettynm ) 326 #define DefineNameSpaceEnumNames(nmspc,enm,deflen,prettynm) \ 327 static ConstPtrMan<EnumDefImpl<nmspc::enm> > enm##Definition_ = 0; \ 328 _DefineEnumNames( nmspc, enm, deflen, prettynm ) 331 #define mDefineEnumUtils(clss,enm,prettynm) \ 332 DefineEnumNames(clss,enm,0,prettynm) 334 #define mDefineNameSpaceEnumUtils(nmspc,enm,prettynm) \ 335 DefineNameSpaceEnumNames(nmspc,enm,0,prettynm) 338 #define DeclareEnumUtils(enm) mDeclareEnumUtils(enm) 339 #define DefineEnumUtils(clss,enm,prettynm) mDefineEnumUtils(clss,enm,prettynm) 340 #define DefineNameSpaceEnumUtils(nmspc,enm,prettynm) \ 341 mDefineNameSpaceEnumUtils(nmspc,enm,prettynm) 342 #define DeclareNameSpaceEnumUtils(mod,enm) mDeclareNameSpaceEnumUtils(mod,enm) 344 #define mEnumTr(str) tr(str) 347 template <
class ENUM>
inline 354 pErrMsg(
"Wrong number of uistrings" );
362 pErrMsg(
"Wrong number of iconfiles" );
366 template <
class ENUM>
inline 380 template <
class ENUM>
inline 384 const char* val = par.
find( key );
385 return parse( val, res );
389 template <
class ENUM>
inline 392 return (ENUM)
enums_[idx];
396 template <
class ENUM>
inline 403 template <
class ENUM>
inline 414 template <
class ENUM>
inline 422 template <
class ENUM>
inline #define mExpClass(module)
Definition: commondefs.h:160
const char * convert(int idx) const
Definition: enums.h:81
#define mODTextTranslationClass(clss)
Definition: uistring.h:38
Export_Basic uiString toUiString(ViewStyle)
BufferStringSet iconfiles_
Definition: enums.h:76
int convert(const char *txt) const
Definition: enums.h:82
Definition: uistring.h:89
bool isEmpty() const
Definition: odset.h:45
Set of BufferString objects.
Definition: bufstringset.h:28
ObjectSet< T >::size_type indexOf(const ObjectSet< T > &os, const S &val)
Locate object in set.
Definition: objectset.h:169
int indexOf(const char *s) const
const char * getKey(ENUM theenum) const
Definition: enums.h:404
const BufferStringSet & keys() const
Definition: enums.h:58
bool isValidKey(const char *) const
size_type size() const
Definition: objectset.h:50
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
ENUM getEnumForIndex(int idx) const
Definition: enums.h:390
const char * toString(ENUM theenum) const
Definition: enums.h:100
const char * find(const char *) const
returns null if not found
const uiStringSet & strings() const
Definition: enums.h:59
uiString getUiStringForIndex(int i) const
EnumDefImpl(const char *nm, const char *s[], short nrs=0)
Definition: enums.h:348
uiStringSet uistrings_
Definition: enums.h:73
void init()
Definition: enums.h:423
const char * buf() const
Definition: odstring.h:47
size_type size() const
Definition: typeset.h:254
Object with a name.
Definition: namedobj.h:35
uiString toUiString(ENUM theenum) const
Definition: enums.h:415
TypeSet< int > enums_
Definition: enums.h:75
Definition: uistring.h:218
BufferString & get(int idx)
Definition: bufstringset.h:36
bool isValidName(const char *key) const
Definition: enums.h:79
BufferStringSet keys_
Definition: enums.h:74
bool parse(const char *txt, ENUM &res) const
Definition: enums.h:367
#define mClass(module)
Definition: commondefs.h:164
#define pErrMsg(msg)
Definition: errmsg.h:60
virtual size_type indexOf(T, bool forward=true, size_type start=-1) const
Definition: typeset.h:311
Holds data pertinent to a certain enum. It does not know the enum values themselves, but treat them as integers.
Definition: enums.h:45