Classes | Public Types | Public Member Functions | List of all members
Enum Class Reference

Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values. All dictionary searches use a literal (not regex). More...

Classes

class  const_iterator
 

Public Types

typedef word key_type
 
typedef EnumType value_type
 

Public Member Functions

 Enum () noexcept=default
 
 Enum (std::initializer_list< std::pair< EnumType, const char * >> list)
 
bool empty () const noexcept
 
label size () const noexcept
 
const List< word > & names () const noexcept
 
const List< int > & values () const noexcept
 
const List< word > & toc () const noexcept
 
List< wordsortedToc () const
 
void clear ()
 
void append (std::initializer_list< std::pair< EnumType, const char * >> list)
 
label find (const word &enumName) const
 
label find (const EnumType e) const
 
bool found (const word &enumName) const
 
bool found (const EnumType e) const
 
EnumType get (const word &enumName) const
 
const wordget (const EnumType e) const
 
EnumType lookup (const word &enumName, const EnumType deflt) const
 
EnumType get (const word &key, const dictionary &dict) const
 
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
 
bool readIfPresent (const word &key, const dictionary &dict, EnumType &val) const
 
EnumType read (Istream &is) const
 
bool read (Istream &is, EnumType &val, const bool mandatory=true) const
 
void write (const EnumType e, Ostream &os) const
 
template<class OS >
OS & writeList (OS &os, const label ununsed=0) const
 
EnumType operator[] (const word &enumName) const
 
const wordoperator[] (const EnumType e) const
 
const_iterator cbegin () const noexcept
 
const_iterator cend () const noexcept
 
const_iterator begin () const noexcept
 
const_iterator end () const noexcept
 
EnumType lookupOrDefault (const word &key, const dictionary &dict, const EnumType deflt, const bool failsafe=false) const
 
const wordoperator() (const EnumType e) const
 
EnumType operator() (const word &key, const EnumType deflt) const
 
EnumType get (const word &key, const EnumType deflt) const
 
EnumType lookup (const word &key, const dictionary &dict) const
 

Detailed Description

Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values. All dictionary searches use a literal (not regex).

Source files

Definition at line 53 of file IOstreamOption.H.

Member Typedef Documentation

◆ key_type

typedef word key_type

Definition at line 72 of file Enum.H.

◆ value_type

typedef EnumType value_type

Definition at line 82 of file Enum.H.

Constructor & Destructor Documentation

◆ Enum() [1/2]

Enum ( )
defaultnoexcept

◆ Enum() [2/2]

Enum ( std::initializer_list< std::pair< EnumType, const char * >>  list)
explicit

Definition at line 28 of file Enum.C.

Member Function Documentation

◆ empty()

bool empty ( ) const
inlinenoexcept

Definition at line 24 of file EnumI.H.

◆ size()

Foam::label size ( ) const
inlinenoexcept

Definition at line 31 of file EnumI.H.

Referenced by Enum< actionType >::cend().

Here is the caller graph for this function:

◆ names()

const Foam::List< Foam::word > & names ( ) const
inlinenoexcept

Definition at line 39 of file EnumI.H.

Referenced by Enum::const_iterator::key().

Here is the caller graph for this function:

◆ values()

const Foam::List< int > & values ( ) const
inlinenoexcept

Definition at line 47 of file EnumI.H.

◆ toc()

const Foam::List< Foam::word > & toc ( ) const
inlinenoexcept

Definition at line 55 of file EnumI.H.

◆ sortedToc()

Foam::List< Foam::word > sortedToc ( ) const
inline

Definition at line 63 of file EnumI.H.

Referenced by filmTurbulenceModel::Cw().

Here is the caller graph for this function:

◆ clear()

void clear ( )
inline

Definition at line 74 of file EnumI.H.

◆ append()

void append ( std::initializer_list< std::pair< EnumType, const char * >>  list)

Definition at line 49 of file Enum.C.

◆ find() [1/2]

Foam::label find ( const word enumName) const
inline

Definition at line 82 of file EnumI.H.

◆ find() [2/2]

Foam::label find ( const EnumType  e) const
inline

Definition at line 89 of file EnumI.H.

◆ found() [1/2]

bool found ( const word enumName) const
inline

Definition at line 96 of file EnumI.H.

Referenced by FIREMeshReader::readGeometry().

Here is the caller graph for this function:

◆ found() [2/2]

bool found ( const EnumType  e) const
inline

Definition at line 103 of file EnumI.H.

◆ get() [1/4]

EnumType get ( const word enumName) const

◆ get() [2/4]

const Foam::word & get ( const EnumType  e) const
inline

Definition at line 110 of file EnumI.H.

◆ lookup() [1/2]

EnumType lookup ( const word enumName,
const EnumType  deflt 
) const

Definition at line 85 of file Enum.C.

Referenced by Enum< actionType >::get(), Foam::getStopAction(), Enum< actionType >::operator()(), and derivedFields::read().

Here is the caller graph for this function:

◆ get() [3/4]

EnumType get ( const word key,
const dictionary dict 
) const
Parameters
keyLookup key. Uses LITERAL (not REGEX)
dictdictionary

Definition at line 150 of file Enum.C.

◆ getOrDefault()

EnumType getOrDefault ( const word key,
const dictionary dict,
const EnumType  deflt,
const bool  failsafe = false 
) const
Parameters
keyLookup key. Uses LITERAL (not REGEX)
dictdictionary
defltfallback if not found
failsafeWarn only on bad enumeration

Definition at line 172 of file Enum.C.

Referenced by distributedTriSurfaceMesh::distributedTriSurfaceMesh(), Enum< actionType >::lookupOrDefault(), abort::read(), and writeObjects::read().

Here is the caller graph for this function:

◆ readEntry()

bool readEntry ( const word key,
const dictionary dict,
EnumType &  val,
const bool  mandatory = true 
) const
Parameters
keyLookup key. Uses LITERAL (not REGEX)
dictdictionary
valthe value to read into
mandatorythe keyword is mandatory

Definition at line 215 of file Enum.C.

◆ readIfPresent()

bool readIfPresent ( const word key,
const dictionary dict,
EnumType &  val 
) const
inline
Parameters
keyLookup key. Uses LITERAL (not REGEX)
dictdictionary
valthe value to read into

Definition at line 125 of file EnumI.H.

Referenced by Time::readDict().

Here is the caller graph for this function:

◆ read() [1/2]

EnumType read ( Istream is) const

Definition at line 102 of file Enum.C.

Referenced by Foam::operator>>(), and addcommsTypeToOpt::readData().

Here is the caller graph for this function:

◆ read() [2/2]

bool read ( Istream is,
EnumType &  val,
const bool  mandatory = true 
) const

◆ write()

void write ( const EnumType  e,
Ostream os 
) const
inline

Definition at line 137 of file EnumI.H.

◆ writeList()

OS & writeList ( OS &  os,
const label  ununsed = 0 
) const
inline

Definition at line 150 of file EnumI.H.

◆ operator[]() [1/2]

EnumType operator[] ( const word enumName) const
inline

Definition at line 244 of file EnumI.H.

◆ operator[]() [2/2]

const Foam::word & operator[] ( const EnumType  e) const
inline

Definition at line 254 of file EnumI.H.

◆ cbegin()

Foam::Enum< EnumType >::const_iterator cbegin ( ) const
inlinenoexcept

Definition at line 226 of file EnumI.H.

Referenced by Enum< actionType >::begin().

Here is the caller graph for this function:

◆ cend()

Foam::Enum< EnumType >::const_iterator cend ( ) const
inlinenoexcept

Definition at line 234 of file EnumI.H.

Referenced by Enum< actionType >::end().

Here is the caller graph for this function:

◆ begin()

const_iterator begin ( ) const
inlinenoexcept

Definition at line 295 of file Enum.H.

◆ end()

const_iterator end ( ) const
inlinenoexcept

Definition at line 296 of file Enum.H.

◆ lookupOrDefault()

EnumType lookupOrDefault ( const word key,
const dictionary dict,
const EnumType  deflt,
const bool  failsafe = false 
) const
inline
Parameters
keyLookup key. Uses LITERAL (not REGEX)
dictdictionary
defltfallback if not found
failsafeWarn only on bad enumeration

Definition at line 307 of file Enum.H.

◆ operator()() [1/2]

const word& operator() ( const EnumType  e) const
inline

Definition at line 321 of file Enum.H.

◆ operator()() [2/2]

EnumType operator() ( const word key,
const EnumType  deflt 
) const
inline

Definition at line 329 of file Enum.H.

◆ get() [4/4]

EnumType get ( const word key,
const EnumType  deflt 
) const
inline

Definition at line 337 of file Enum.H.

◆ lookup() [2/2]

EnumType lookup ( const word key,
const dictionary dict 
) const
inline

Definition at line 345 of file Enum.H.


The documentation for this class was generated from the following files: