33 template<
class EnumType>
36 std::initializer_list<std::pair<EnumType, const char*>> list
43 for (
const auto& pair : list)
45 keys_[i] = pair.second;
46 vals_[i] = int(pair.first);
54 template<
class EnumType>
57 std::initializer_list<std::pair<EnumType, const char*>> list
62 keys_.resize(i + list.size());
63 vals_.resize(i + list.size());
65 for (
const auto& pair : list)
67 keys_[i] = pair.second;
68 vals_[i] = int(pair.first);
74 template<
class EnumType>
77 const label idx = keys_.find(enumName);
82 << enumName <<
" is not in enumeration: " << *
this <<
nl 86 return EnumType(vals_[idx]);
90 template<
class EnumType>
97 const label idx = keys_.find(enumName);
104 return EnumType(vals_[idx]);
108 template<
class EnumType>
111 const word enumName(is);
113 const label idx = keys_.find(enumName);
118 << enumName <<
" is not in enumeration: " << *
this <<
nl 122 return EnumType(vals_[idx]);
126 template<
class EnumType>
134 const word enumName(is);
136 const label idx = keys_.find(enumName);
140 val = EnumType(vals_[idx]);
147 << enumName <<
" is not in enumeration: " << *
this <<
nl 155 template<
class EnumType>
164 const label idx = keys_.find(enumName);
169 <<
"Lookup:" <<
key <<
" enumeration " << enumName
170 <<
" is not in enumeration: " << *
this <<
nl 174 return EnumType(vals_[idx]);
178 template<
class EnumType>
183 const EnumType deflt,
187 const entry* eptr =
dict.findEntry(
key, keyType::LITERAL);
193 const label idx = keys_.find(enumName);
197 return EnumType(vals_[idx]);
205 <<
"Lookup:" <<
key <<
" enumeration " << enumName
206 <<
" is not in enumeration: " << *
this <<
nl 207 <<
"using default " <<
get(deflt)
208 <<
" (value " <<
int(deflt) <<
')' <<
endl;
213 <<
"Lookup:" <<
key <<
" enumeration " << enumName
214 <<
" is not in enumeration: " << *
this <<
nl 223 template<
class EnumType>
229 const bool mandatory,
233 const entry* eptr =
dict.findEntry(
key, keyType::LITERAL);
239 const label idx = keys_.find(enumName);
243 val = EnumType(vals_[idx]);
252 <<
"Lookup:" <<
key <<
" enumeration " << enumName
253 <<
" is not in enumeration: " << *
this <<
nl 254 <<
"leaving value unchanged" 255 <<
" (value " << int(val) <<
')' <<
endl;
260 <<
"Lookup:" <<
key <<
" enumeration " << enumName
261 <<
" is not in enumeration: " << *
this <<
nl 269 <<
" not found in dictionary " <<
dict.name() <<
nl EnumType get(const word &enumName) const
The enumeration corresponding to the given name.
EnumType read(Istream &is) const
Read a word from Istream and return the corresponding enumeration.
void push_back(std::initializer_list< std::pair< EnumType, const char *>> list)
Append value/key pairs to the lists of known enumerations.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
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...
A class for handling words, derived from Foam::string.
T get() const
Get a T from the stream, FatalIOError if the number of tokens is incorrect.
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.
Enum() noexcept=default
Default construct, an empty list.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
EnumType lookup(const word &enumName, const EnumType deflt) const
The enumeration corresponding to the given name.
A keyword and a list of tokens is an 'entry'.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...