Go to the documentation of this file.
35 template<
class EnumType,
int nEnum>
40 for (
int enumi=0; enumi < nEnum; ++enumi)
51 for (
int i = 0; i < enumi; ++i)
53 goodNames[i] =
names[i];
57 <<
"Illegal enumeration name at position " << enumi <<
nl
58 <<
"after entries " << goodNames <<
nl
59 <<
"Possibly your NamedEnum<EnumType, nEnum>::names array"
60 <<
" is not of size " << nEnum <<
endl
69 template<
class EnumType,
int nEnum>
75 for (
int enumi=0; enumi < nEnum; ++enumi)
77 if (names[enumi] && names[enumi][0])
79 lst[
count++] = names[enumi];
88 template<
class EnumType,
int nEnum>
94 for (
int enumi=0; enumi < nEnum; ++enumi)
96 if (names[enumi] && names[enumi][0])
98 auto iter = lookup_.cfind(names[enumi]);
102 lst[
count++] = iter.val();
112 template<
class EnumType,
int nEnum>
115 const int enumValue(
e);
119 if (iter.val() == enumValue)
128 template<
class EnumType,
int nEnum>
136 auto iter = lookup_.cfind(enumName);
141 << enumName <<
" is not in enumeration: "
142 << lookup_.sortedToc() <<
nl
146 return EnumType(iter.val());
150 template<
class EnumType,
int nEnum>
167 template<
class EnumType,
int nEnum>
170 const word enumName(is);
171 auto iter = lookup_.cfind(enumName);
176 << enumName <<
" is not in enumeration: "
177 << lookup_.sortedToc() <<
nl
181 return EnumType(iter.val());
185 template<
class EnumType,
int nEnum>
192 const int idx = int(
e);
193 if (idx >= 0 && idx < nEnum)
202 template<
class EnumType,
int nEnum>
209 return wrapped.lookup_.writeKeys(os, 10);
List< int > values() const
The list of enum values, in construction order.
A class for handling words, derived from Foam::string.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
bool hasName(const EnumType e) const
Test if there is a name corresponding to the given enumeration.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
Ostream & endl(Ostream &os)
Add newline and flush stream.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
const cellModel * lookup(const word &modelName)
Deprecated(2017-11) equivalent to cellModel::ptr static method.
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
void write(const EnumType e, Ostream &os) const
Write the name representation of the enumeration to an Ostream.
errorManip< error > abort(error &err)
EnumType lookupOrDefault(const word &key, const dictionary &dict, const EnumType deflt) const
Find the key in the dictionary and return the corresponding.
errorManipArg< error, int > exit(error &err, const int errNo=1)
NamedEnum() FOAM_DEPRECATED_FOR(2017-05
Construct from names.
wordList words() const
The list of enum names, in construction order.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
forAllConstIters(mixture.phases(), phase)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
EnumType lookup(const word &key, const dictionary &dict) const
Lookup the key in the dictionary and return the corresponding.
const dimensionedScalar e
Elementary charge.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
void setSize(const label newSize)
Alias for resize(const label)
static const char * names[nEnum]
The set of names corresponding to the enumeration EnumType.
A NamedEnum is a wrapper around a list of names that represent particular enumeration values.
EnumType read(Istream &is) const
Read a word from Istream and return the corresponding enumeration.