33template<
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);
54template<
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);
74template<
class EnumType>
77 const label idx = find(enumName);
82 << enumName <<
" is not in enumeration: " << *
this <<
nl
86 return EnumType(vals_[idx]);
90template<
class EnumType>
97 const label idx = find(enumName);
104 return EnumType(vals_[idx]);
108template<
class EnumType>
111 const word enumName(is);
113 const label idx = find(enumName);
118 << enumName <<
" is not in enumeration: " << *
this <<
nl
122 return EnumType(vals_[idx]);
126template<
class EnumType>
134 const word enumName(is);
136 const label idx = find(enumName);
140 val = EnumType(vals_[idx]);
147 << enumName <<
" is not in enumeration: " << *
this <<
nl
155template<
class EnumType>
164 const label idx = find(enumName);
169 << enumName <<
" is not in enumeration: " << *
this <<
nl
173 return EnumType(vals_[idx]);
177template<
class EnumType>
182 const EnumType deflt,
192 const label idx = find(enumName);
196 return EnumType(vals_[idx]);
204 << enumName <<
" is not in enumeration: " << *
this <<
nl
205 <<
"using failsafe " << get(deflt)
206 <<
" (value " << int(deflt) <<
')' <<
endl;
211 << enumName <<
" is not in enumeration: " << *
this <<
nl
220template<
class EnumType>
235 const label idx = find(enumName);
239 val = EnumType(vals_[idx]);
244 << enumName <<
" is not in enumeration: " << *
this <<
nl
250 <<
"'" << key <<
"' not found in dictionary " <<
dict.
name() <<
nl
Enum() noexcept=default
Default construct, an empty list.
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.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
unsigned int get() const
Get value as unsigned, no range-checking.
virtual bool read()
Re-read model coefficients if they have changed.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
const fileName & name() const noexcept
The dictionary name.
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
A keyword and a list of tokens is an 'entry'.
Lookup type of boundary radiation properties.
bool append() const noexcept
True if output format uses an append mode.
A class for handling words, derived from Foam::string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)