Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values. All dictionary searches use a literal (not regex). More...
Public Types | |
typedef EnumType | value_type |
The type of enumeration represented by the Enum. More... | |
Public Member Functions | |
Enum ()=default | |
Construct null (empty list) More... | |
Enum (std::initializer_list< std::pair< EnumType, const char * >> list) | |
Construct from a values/names list. More... | |
bool | empty () const noexcept |
True if the enumeration list is empty. More... | |
label | size () const noexcept |
The number of name/value pairs for the enumeration. More... | |
const List< word > & | names () const |
The list of enum names, in construction order. Same as toc() More... | |
const List< word > & | toc () const |
The list of enum names, in construction order. Same as names() More... | |
List< word > | sortedToc () const |
The sorted list of enum names. More... | |
const List< int > & | values () const |
The list of enum values, in construction order. More... | |
void | clear () |
Clear all entries. More... | |
void | append (std::initializer_list< std::pair< EnumType, const char * >> list) |
Append value/key pairs to the lists of known enumerations. More... | |
label | find (const word &enumName) const |
Find the index of the given name. More... | |
label | find (const EnumType e) const |
Find the first index of given enumeration. More... | |
bool | found (const word &enumName) const |
Test if there is an enumeration corresponding to the given name. More... | |
bool | found (const EnumType e) const |
Test if there is a name corresponding to the given enumeration. More... | |
EnumType | get (const word &enumName) const |
The enumeration corresponding to the given name. More... | |
EnumType | get (const word &enumName, const EnumType deflt) const |
The enumeration corresponding to the given name. More... | |
const word & | get (const EnumType e) const |
The name corresponding to the given enumeration. More... | |
EnumType | get (const word &key, const dictionary &dict) const |
EnumType | getOrDefault (const word &key, const dictionary &dict, const EnumType deflt, const bool failsafe=false) const |
bool | readEntry (const word &key, const dictionary &dict, EnumType &val, const bool mandatory=true) const |
Find entry and assign to T val. More... | |
bool | readIfPresent (const word &key, const dictionary &dict, EnumType &val) const |
Find an entry if present, and assign to T val. More... | |
EnumType | read (Istream &is) const |
Read a word from Istream and return the corresponding enumeration. More... | |
bool | read (Istream &is, EnumType &val, const bool mandatory=true) const |
Read a word from Istream, lookup named enumeration. More... | |
void | write (const EnumType e, Ostream &os) const |
Write the name representation of the enumeration to an Ostream. More... | |
Ostream & | writeList (Ostream &os, const label shortLen=0) const |
Write the names as a list to an Ostream. More... | |
EnumType | operator[] (const word &enumName) const |
Return the enumeration corresponding to the given name. More... | |
const word & | operator[] (const EnumType e) const |
const word & | operator() (const EnumType e) const |
EnumType | operator() (const word &enumName, const EnumType deflt) const |
EnumType | lookupOrDefault (const word &key, const dictionary &dict, const EnumType deflt, const bool failsafe=false) const |
EnumType | FOAM_DEPRECATED_FOR (2018-10, "get() method") lookup(const word &key |
Deprecated(2018-10) same as two-parameter get() More... | |
Public Attributes | |
EnumType const dictionary &const | dict |
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values. All dictionary searches use a literal (not regex).
Definition at line 51 of file IOstreamOption.H.
typedef EnumType value_type |
|
default |
Construct null (empty list)
|
explicit |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
Foam::List< Foam::word > sortedToc | ( | ) | const |
|
inline |
void append | ( | std::initializer_list< std::pair< EnumType, const char * >> | list | ) |
|
inline |
|
inline |
Test if there is an enumeration corresponding to the given name.
Definition at line 88 of file EnumI.H.
Referenced by IOstreamOption::formatEnum(), and FIREMeshReader::readGeometry().
|
inline |
EnumType get | ( | const word & | enumName | ) | const |
The enumeration corresponding to the given name.
FatalError if not found.
Definition at line 86 of file Enum.C.
Referenced by derivedFields::read(), limitFields::read(), and lumpedPointMovement::readDict().
EnumType get | ( | const word & | enumName, |
const EnumType | deflt | ||
) | const |
|
inline |
EnumType get | ( | const word & | key, |
const dictionary & | dict | ||
) | const |
EnumType getOrDefault | ( | const word & | key, |
const dictionary & | dict, | ||
const EnumType | deflt, | ||
const bool | failsafe = false |
||
) | const |
Find the key in the dictionary and return the corresponding enumeration element based on its name.
key | Lookup key. Uses LITERAL (not REGEX) |
dict | dictionary |
deflt | fallback if not found |
failsafe | Warn only on bad enumeration |
Definition at line 190 of file Enum.C.
Referenced by distributedTriSurfaceMesh::distributedTriSurfaceMesh(), and Enum< filterType >::lookupOrDefault().
bool readEntry | ( | const word & | key, |
const dictionary & | dict, | ||
EnumType & | val, | ||
const bool | mandatory = true |
||
) | const |
Find entry and assign to T val.
FatalIOError if the enumeration is incorrect, or when it is mandatory but was not found.
key | Lookup key. Uses LITERAL (not REGEX) |
dict | dictionary |
val | the value to read into |
mandatory | the keyword is mandatory |
bool readIfPresent | ( | const word & | key, |
const dictionary & | dict, | ||
EnumType & | val | ||
) | const |
Find an entry if present, and assign to T val.
FatalIOError if the enumeration is incorrect. Default search: non-recursive with patterns.
key | Lookup key. Uses LITERAL (not REGEX) |
dict | dictionary |
val | the value to read into |
Definition at line 271 of file Enum.C.
Referenced by Time::readDict().
EnumType read | ( | Istream & | is | ) | const |
Read a word from Istream and return the corresponding enumeration.
Definition at line 120 of file Enum.C.
Referenced by Foam::operator>>(), and addcommsTypeToOpt::readData().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Find the key in the dictionary and return the corresponding enumeration element based on its name.
key | Lookup key. Uses LITERAL (not REGEX) |
dict | dictionary |
deflt | fallback if not found |
failsafe | Warn only on bad enumeration |
Definition at line 272 of file Enum.H.
Referenced by abort::read(), and writeObjects::read().
EnumType FOAM_DEPRECATED_FOR | ( | 2018- | 10, |
"get() method" | |||
) | const & |
Deprecated(2018-10) same as two-parameter get()
EnumType const dictionary& const dict |
Definition at line 286 of file Enum.H.
Referenced by Enum< filterType >::lookupOrDefault().