Go to the documentation of this file.
44 #include <initializer_list>
55 template<
class EnumType>
class Enum;
61 template<
class EnumType>
76 std::is_enum<EnumType>::value || std::is_integral<EnumType>::value,
77 "Enum must be enum or an integral type"
94 Enum() noexcept = default;
101 std::initializer_list<std::pair<EnumType, const
char*>> list
110 inline
bool empty() const noexcept;
113 inline label
size() const noexcept;
119 inline const
List<
int>&
values() const noexcept;
137 std::initializer_list<std::pair<EnumType, const
char*>> list
145 inline label
find(const
word& enumName) const;
149 inline label
find(const EnumType
e) const;
152 inline
bool found(const
word& enumName) const;
155 inline
bool found(const EnumType
e) const;
159 EnumType
get(const
word& enumName) const;
163 inline const
word&
get(const EnumType
e) const;
168 EnumType
lookup(const
word& enumName, const EnumType deflt) const;
192 const EnumType deflt,
193 const
bool failsafe = false
206 const
bool mandatory = true
233 const
bool mandatory = true
243 inline OS&
writeList(OS& os, const label ununsed=0) const;
251 inline EnumType operator[](const
word& enumName) const;
256 inline const
word& operator[](const EnumType
e) const;
276 const Enum* eptr =
nullptr,
281 inline const word& key()
const;
284 inline EnumType val()
const;
294 inline
bool operator==(const
const_iterator& iter) const noexcept;
295 inline
bool operator!=(const
const_iterator& iter) const noexcept;
302 const_iterator
end()
const {
return cend(); }
316 const EnumType deflt,
317 const bool failsafe =
false
327 const
word& operator()(const EnumType
e)
const
335 EnumType operator()(const
word& key, const EnumType deflt)
const
337 return lookup(key, deflt);
343 EnumType
get(const
word& key, const EnumType deflt)
const
345 return lookup(key, deflt);
361 template<
class EnumType>
362 inline Ostream&
operator<<(Ostream& os,
const Enum<EnumType>& list);
365 template<
class EnumType>
366 inline std::ostream&
operator<<(std::ostream& os,
const Enum<EnumType>& list);
const_iterator begin() const
EnumType lookupOrDefault(const word &key, const dictionary &dict, const EnumType deflt, const bool failsafe=false) const
const_iterator cbegin() const
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
A class for handling words, derived from Foam::string.
bool found(const word &enumName) const
True if there is an enumeration corresponding to the given name.
bool empty() const noexcept
True if the enumeration list is empty.
const List< word > & toc() const noexcept
The list of enum names, in construction order. Same as names()
A const_iterator for iterating an Enum list.
EnumType get(const word &enumName) const
The enumeration corresponding to the given name.
EnumType value_type
The type of enumeration represented by the Enum.
bool operator!=(const eddy &a, const eddy &b)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
const_iterator cend() const
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
void write(const EnumType e, Ostream &os) const
Write the name representation of the enumeration to an Ostream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
EnumType getOrDefault(const word &key, const dictionary &dict, const EnumType deflt, const bool failsafe=false) const
Enum() noexcept=default
Default construct, an empty list.
Lookup type of boundary radiation properties.
EnumType lookup(const word &enumName, const EnumType deflt) const
The enumeration corresponding to the given name.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
word key_type
The type of keys used.
void append(std::initializer_list< std::pair< EnumType, const char * >> list)
Append value/key pairs to the lists of known enumerations.
const_iterator end() const
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
label size() const noexcept
The number of name/value pairs for the enumeration.
void clear()
Clear all entries.
tmp< faMatrix< Type > > operator*(const areaScalarField &, const faMatrix< Type > &)
OS & writeList(OS &os, const label ununsed=0) const
const dimensionedScalar e
Elementary charge.
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
bool readIfPresent(const word &key, const dictionary &dict, EnumType &val) const
Find an entry if present, and assign to T val.
List< word > sortedToc() const
The sorted list of enum names.
label find(const word &enumName) const
Find the index of the given name.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
EnumType read(Istream &is) const
Read a word from Istream and return the corresponding enumeration.
const List< int > & values() const noexcept
The list of enum values, in construction order.
bool readEntry(const word &key, const dictionary &dict, EnumType &val, const bool mandatory=true) const
Find entry and assign to T val.
const List< word > & names() const noexcept
The list of enum names, in construction order. Same as toc()