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...
#include <Enum.H>
Classes | |
| class | const_iterator |
| A const_iterator for iterating an Enum list. More... | |
Public Types | |
| typedef word | key_type |
| The type of keys used. | |
| typedef EnumType | value_type |
| The type of enumeration represented by the Enum. | |
Public Member Functions | |
| Enum () noexcept=default | |
| Default construct, an empty list. | |
| Enum (std::initializer_list< std::pair< EnumType, const char * > > list) | |
| Construct from a values/names list. | |
| bool | empty () const noexcept |
| True if the enumeration list is empty. | |
| label | size () const noexcept |
| The number of name/value pairs for the enumeration. | |
| const List< word > & | names () const noexcept |
| The list of enum names, in construction order. Same as toc(). | |
| const List< int > & | values () const noexcept |
| The list of enum values, in construction order. | |
| const List< word > & | toc () const noexcept |
| The list of enum names, in construction order. Same as names(). | |
| List< word > | sortedToc () const |
| The sorted list of enum names. | |
| void | clear () |
| Clear all entries. | |
| void | push_back (std::initializer_list< std::pair< EnumType, const char * > > list) |
| Append value/key pairs to the lists of known enumerations. | |
| bool | contains (const word &enumName) const |
| True if there is an enumeration corresponding to the given name. | |
| bool | contains (const EnumType e) const |
| True if there is a name corresponding to the given enumeration. | |
| EnumType | get (const word &enumName) const |
| The enumeration corresponding to the given name. | |
| const word & | get (const EnumType e) const |
| The name corresponding to the given enumeration. | |
| EnumType | lookup (const word &enumName, const EnumType deflt) const |
| The enumeration corresponding to the given name. | |
| EnumType | get (const word &key, const dictionary &dict) const |
| Get the key in the dictionary and return the corresponding enumeration element based on its name. | |
| EnumType | getOrDefault (const word &key, const dictionary &dict, const EnumType deflt, const bool warnOnly=false) const |
| Find the key in the dictionary and return the corresponding enumeration element based on its name. | |
| bool | readEntry (const word &key, const dictionary &dict, EnumType &val, const bool mandatory=true, const bool warnOnly=false) const |
| Find entry and assign to T val. | |
| bool | readIfPresent (const word &key, const dictionary &dict, EnumType &val, const bool warnOnly=false) const |
| Find an entry if present, and assign to T val. | |
| EnumType | read (Istream &is) const |
| Read a word from Istream and return the corresponding enumeration. | |
| bool | read (Istream &is, EnumType &val, const bool mandatory=true) const |
| Read a word from Istream, lookup named enumeration. | |
| void | write (const EnumType e, Ostream &os) const |
| Write the name representation of the enumeration to an Ostream. | |
| template<class OS> | |
| OS & | writeList (OS &os, const label ununsed=0) const |
| Write enumeration names as a list without line-breaks to an output stream. | |
| EnumType | operator[] (const word &k) const |
| Return the enumeration corresponding to the given name. | |
| const word & | operator[] (EnumType e) const |
| Return the first name corresponding to the given enumeration, or an empty word if not found. | |
| const_iterator | cbegin () const noexcept |
| const_iterator | cend () const noexcept |
| const_iterator | begin () const noexcept |
| const_iterator | end () const noexcept |
| const_iterator | cfind (const word &key) const |
| Find key/value pair by enumeration name. | |
| const_iterator | find (const word &key) const |
| const_iterator | cfind (const EnumType e) const |
| Find key/value pair by enumeration value. | |
| const_iterator | find (const EnumType e) const |
| EnumType | lookupOrDefault (const word &key, const dictionary &dict, const EnumType deflt, const bool warnOnly=false) const |
| Same as getOrDefault(). | |
| const word & | operator() (const EnumType e) const |
| Deprecated(2020-11) use get() method. | |
| EnumType | operator() (const word &key, const EnumType deflt) const |
| Deprecated(2020-11) use two-parameter lookup() method. | |
| EnumType | get (const word &key, const EnumType deflt) const |
| Deprecated(2020-11) use two-parameter lookup() method. | |
| EnumType | lookup (const word &key, const dictionary &dict) const |
| Deprecated(2018-10) same as two-parameter get() method. | |
| void | append (std::initializer_list< std::pair< EnumType, const char * > > list) |
| Append value/key pairs to the lists of known enumerations. | |
| bool | found (const word &key) const |
| Same as contains(). | |
| bool | found (const EnumType e) const |
| Same as contains(). | |
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).
| typedef EnumType value_type |
|
defaultnoexcept |
Default construct, an empty list.
References clear(), contains(), dict, e, empty(), Enum(), get(), getOrDefault(), lookup(), names(), Foam::noexcept, os(), push_back(), read(), readEntry(), readIfPresent(), size(), sortedToc(), toc(), values(), write(), and writeList().
Referenced by Enum< EnumType >::const_iterator::const_iterator(), and Enum().


|
explicit |
|
inlinenoexcept |
True if the enumeration list is empty.
Definition at line 24 of file EnumI.H.
References Foam::noexcept.
Referenced by Enum().

|
inlinenoexcept |
The number of name/value pairs for the enumeration.
Definition at line 31 of file EnumI.H.
References Foam::noexcept.
Referenced by cend(), cfind(), Enum(), Enum(), Enum< EnumType >::const_iterator::good(), and push_back().

|
inlinenoexcept |
The list of enum names, in construction order. Same as toc().
Definition at line 39 of file EnumI.H.
References Foam::noexcept.
Referenced by Enum< injectionMethod >::contains(), and Enum().

|
inlinenoexcept |
The list of enum values, in construction order.
Definition at line 47 of file EnumI.H.
References Foam::noexcept.
Referenced by Enum().

|
inlinenoexcept |
The list of enum names, in construction order. Same as names().
Definition at line 55 of file EnumI.H.
References Foam::noexcept.
Referenced by Enum().

|
inline |
The sorted list of enum names.
Definition at line 63 of file EnumI.H.
References Foam::sort().
Referenced by Enum().


|
inline |
Clear all entries.
Definition at line 74 of file EnumI.H.
References List< T >::clear().
Referenced by Enum().


| void push_back | ( | std::initializer_list< std::pair< EnumType, const char * > > | list | ) |
|
inline |
|
inline |
| EnumType get | ( | const word & | enumName | ) | const |
The enumeration corresponding to the given name.
FatalError if not found.
Definition at line 68 of file Enum.C.
References Foam::exit(), Foam::FatalError, FatalErrorInFunction, and Foam::nl.
Referenced by Enum(), get(), lookup(), operator()(), operator[](), and operator[]().


|
inline |
The name corresponding to the given enumeration.
Return an empty word if there is no corresponding name for it.
Definition at line 96 of file EnumI.H.
References e, and word::null.
| EnumType lookup | ( | const word & | enumName, |
| const EnumType | deflt ) const |
| EnumType get | ( | const word & | key, |
| const dictionary & | dict ) const |
Get the key in the dictionary and return the corresponding enumeration element based on its name.
FatalIOError if anything is incorrect.
| key | Lookup key. Uses LITERAL (not REGEX) |
| dict | dictionary |
Definition at line 149 of file Enum.C.
References dict, and keyType::LITERAL.
| EnumType getOrDefault | ( | const word & | key, |
| const dictionary & | dict, | ||
| const EnumType | deflt, | ||
| const bool | warnOnly = 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 |
| warnOnly | Warn (not fail) on bad enumeration |
Definition at line 172 of file Enum.C.
References dict, and keyType::LITERAL.
Referenced by Enum(), and lookupOrDefault().

| bool readEntry | ( | const word & | key, |
| const dictionary & | dict, | ||
| EnumType & | val, | ||
| const bool | mandatory = true, | ||
| const bool | warnOnly = false ) const |
Find entry and assign to T val.
FatalIOError if the enumeration is incorrect, or when it is mandatory but was not found.
(TDB: handle IOobjectOption::readOption instead)
| key | Lookup key. Uses LITERAL (not REGEX) |
| dict | dictionary |
| val | The value to read into |
| mandatory | The keyword is mandatory |
| warnOnly | Warn (not fail) on bad enumeration |
Definition at line 217 of file Enum.C.
References dict.
Referenced by Enum().

|
inline |
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 |
| warnOnly | Warn (not fail) on bad enumeration |
Definition at line 110 of file EnumI.H.
References dict.
Referenced by Enum().

| EnumType read | ( | Istream & | is | ) | const |
Read a word from Istream and return the corresponding enumeration.
Definition at line 102 of file Enum.C.
References Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, and Foam::nl.
Referenced by Enum().


| bool read | ( | Istream & | is, |
| EnumType & | val, | ||
| const bool | mandatory = true ) const |
Read a word from Istream, lookup named enumeration.
Definition at line 120 of file Enum.C.
References Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, and Foam::nl.

|
inline |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
Definition at line 220 of file EnumI.H.
References Foam::noexcept.
Referenced by begin().

|
inlinenoexcept |
Definition at line 228 of file EnumI.H.
References Foam::noexcept, and size().
Referenced by end().


|
inlinenoexcept |
|
inlinenoexcept |
Definition at line 383 of file Enum.H.
References cend(), and Foam::noexcept.

|
inline |
|
inline |
Definition at line 391 of file Enum.H.
References cfind(), and Enum< EnumType >::const_iterator::key().

|
inline |
|
inline |
|
inline |
Same as getOrDefault().
| key | Lookup key. Uses LITERAL (not REGEX) |
| dict | dictionary |
| deflt | fallback if not found |
| warnOnly | Warn (not fail) on bad enumeration |
Definition at line 408 of file Enum.H.
References dict, getOrDefault(), Enum< EnumType >::const_iterator::key(), and lookupOrDefault().
Referenced by lookupOrDefault().


|
inline |
|
inline |
Deprecated(2020-11) use two-parameter lookup() method.
Definition at line 436 of file Enum.H.
References Enum< EnumType >::const_iterator::key(), and lookup().

|
inline |
Deprecated(2020-11) use two-parameter lookup() method.
Definition at line 447 of file Enum.H.
References get(), Enum< EnumType >::const_iterator::key(), and lookup().

|
inline |
Deprecated(2018-10) same as two-parameter get() method.
Definition at line 458 of file Enum.H.
References dict, get(), Enum< EnumType >::const_iterator::key(), and lookup().

|
inline |
Append value/key pairs to the lists of known enumerations.
Does not check for duplicate entries
Definition at line 469 of file Enum.H.
References append(), and push_back().
Referenced by append().


|
inline |
Same as contains().
Definition at line 480 of file Enum.H.
References contains(), and Enum< EnumType >::const_iterator::key().

|
inline |
Same as contains().
Definition at line 485 of file Enum.H.
References contains(), and e.
