A NamedEnum is a wrapper around a list of names that represent particular enumeration values. More...
Public Types | |
typedef EnumType | value_type |
The type of enumeration wrapped by NamedEnum. More... | |
Public Member Functions | |
NamedEnum () FOAM_DEPRECATED_FOR(2017-05 | |
Construct from names. More... | |
label | size () const |
The number of lookup names for the enumeration. More... | |
wordList | toc () const |
The list of enum names. More... | |
wordList | sortedToc () const |
The sorted list of enum names. More... | |
wordList | words () const |
The list of enum names, in construction order. More... | |
List< int > | values () const |
The list of enum values, in construction order. More... | |
bool | found (const word &enumName) const |
Test if there is an enumeration corresponding to the given name. More... | |
bool | hasEnum (const word &enumName) const |
Test if there is an enumeration corresponding to the given name. More... | |
bool | hasName (const EnumType e) const |
Test if there is a name corresponding to the given enumeration. More... | |
EnumType | lookup (const word &key, const dictionary &dict) const |
Lookup the key in the dictionary and return the corresponding. More... | |
EnumType | lookupOrDefault (const word &key, const dictionary &dict, const EnumType deflt) const |
Find the key in the dictionary and return the corresponding. More... | |
EnumType | read (Istream &is) const |
Read a word from Istream and return the corresponding enumeration. More... | |
void | write (const EnumType e, Ostream &os) const |
Write the name representation of the enumeration to an Ostream. More... | |
const EnumType | operator[] (const word &name) const |
Return the enumeration element corresponding to the given name. More... | |
const char * | operator[] (const EnumType e) const |
Return the name of the given enumeration element. More... | |
Static Public Attributes | |
static const char * | names [nEnum] |
The set of names corresponding to the enumeration EnumType. More... | |
Friends | |
Ostream & | operator (Ostream &os, const NamedEnum< EnumType, nEnum > &wrapped) |
Write names to Ostream, as per writeKeys() with shortListLen=10. More... | |
A NamedEnum is a wrapper around a list of names that represent particular enumeration values.
Definition at line 58 of file NamedEnum.H.
typedef EnumType value_type |
The type of enumeration wrapped by NamedEnum.
Definition at line 92 of file NamedEnum.H.
NamedEnum | ( | ) |
Construct from names.
Definition at line 36 of file NamedEnum.C.
References Foam::abort(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, HashTable< T, Key, Hash >::insert(), NamedEnum< EnumType, nEnum >::names, and Foam::nl.
|
inline |
The number of lookup names for the enumeration.
Definition at line 31 of file NamedEnumI.H.
|
inline |
The list of enum names.
Definition at line 38 of file NamedEnumI.H.
|
inline |
The sorted list of enum names.
Definition at line 45 of file NamedEnumI.H.
Foam::wordList words | ( | ) | const |
The list of enum names, in construction order.
Definition at line 70 of file NamedEnum.C.
References Foam::BitOps::count(), and List< T >::setSize().
Foam::List< int > values | ( | ) | const |
The list of enum values, in construction order.
Definition at line 89 of file NamedEnum.C.
References Foam::BitOps::count(), and List< T >::setSize().
Test if there is an enumeration corresponding to the given name.
Definition at line 53 of file NamedEnumI.H.
Test if there is an enumeration corresponding to the given name.
Definition at line 63 of file NamedEnumI.H.
bool hasName | ( | const EnumType | e | ) | const |
Test if there is a name corresponding to the given enumeration.
Definition at line 113 of file NamedEnum.C.
References Foam::constant::electromagnetic::e, and forAllConstIters().
EnumType lookup | ( | const word & | key, |
const dictionary & | dict | ||
) | const |
Lookup the key in the dictionary and return the corresponding.
enumeration element based on its name. Fatal if anything is incorrect.
Definition at line 130 of file NamedEnum.C.
References dict, Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, dictionary::lookup(), and Foam::nl.
EnumType lookupOrDefault | ( | const word & | key, |
const dictionary & | dict, | ||
const EnumType | deflt | ||
) | const |
Find the key in the dictionary and return the corresponding.
enumeration element based on its name. Return the default value if the key was not found in the dictionary. Fatal if enumerated name was incorrect.
Definition at line 152 of file NamedEnum.C.
References dict, dictionary::found(), and Foam::cellModeller::lookup().
EnumType read | ( | Istream & | is | ) | const |
Read a word from Istream and return the corresponding enumeration.
Definition at line 168 of file NamedEnum.C.
References Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, and Foam::nl.
void write | ( | const EnumType | e, |
Ostream & | os | ||
) | const |
Write the name representation of the enumeration to an Ostream.
A noop if the enumeration wasn't found.
Definition at line 187 of file NamedEnum.C.
References Foam::constant::electromagnetic::e.
Return the enumeration element corresponding to the given name.
Definition at line 75 of file NamedEnumI.H.
References Foam::name().
|
inline |
Return the name of the given enumeration element.
Definition at line 85 of file NamedEnumI.H.
References Foam::constant::electromagnetic::e.
Write names to Ostream, as per writeKeys() with shortListLen=10.
|
static |
The set of names corresponding to the enumeration EnumType.
Definition at line 98 of file NamedEnum.H.
Referenced by NamedEnum< EnumType, nEnum >::NamedEnum().