35 template<
class EnumType,
int nEnum>
40 for (
int enumi=0; enumi < nEnum; ++enumi)
44 lookup_.insert(
names[enumi], enumi);
49 List<string> goodNames(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>
72 List<word> lst(nEnum);
75 for (
int enumi=0; enumi < nEnum; ++enumi)
88 template<
class EnumType,
int nEnum>
94 for (
int enumi=0; enumi < nEnum; ++enumi)
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>
206 const NamedEnum<EnumType, nEnum>& wrapped
209 return wrapped.lookup_.writeKeys(
os, 10);
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return an entry data stream. FatalIOError if not found, or not a stream. ...
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
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...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
A NamedEnum is a wrapper around a list of names that represent particular enumeration values...
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
errorManip< error > abort(error &err)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
OBJstream os(runTime.globalPath()/outputName)
#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
Includes some standard C++ headers, defines global macros and templates used in multiple places by Op...
forAllConstIters(mixture.phases(), phase)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...