PLCnext API Documentation 23.3.0.32
|
The class implements an adapter for enums to define the string literals of the enum entries. More...
#include <EnumDictionary.hxx>
Public Member Functions | |
EnumDictionary (const InitializerList &fields) | |
Constructor passing the enum fields as initializer list. More... | |
EnumDictionary (const char *invalidValueString, const InitializerList &fields) | |
Constructor passing the enum fields as initializer list. More... | |
std::ostream & | WriteEnumString (std::ostream &os, T value) const |
Writes the string of the specified enum value to the given stream. More... | |
std::istream & | ReadEnumValue (std::istream &is, T &value) const |
Tries to return the enum entry of the specified string. More... | |
const char * | GetEnumString (T value) const |
Returns the string of the specified enum entry. More... | |
bool | TryGetEnumString (T value, const char *&pResult) const |
Returns the string of the specified enum value or nullptr if the value could not be found. More... | |
T | GetEnumValue (const char *fieldName) const |
Returns the value of the specified enum string. More... | |
bool | TryGetEnumValue (const char *fieldName, T &value) const |
Tries to get the enum value of the specified string. More... | |
![]() | |
EnumDictionaryBase (const InitializerList &fields) | |
EnumDictionaryBase (const char *invalidValueString, const InitializerList &fields) | |
Protected Types | |
using | Base = EnumDictionaryBase< T > |
using | U = typename Base::U |
using | InitializerList = typename Base::InitializerList |
![]() | |
using | Fields = std::map< T, const char * > |
using | InitializerList = std::initializer_list< typename Fields::value_type > |
using | U = typename std::underlying_type< T >::type |
Additional Inherited Members | |
![]() | |
bool | TryGetEnumStringInternal (T value, const char *&pResult) const |
Returns the string of the specified enum value or nullptr if the value could not be found. More... | |
bool | TryGetEnumValueInternal (const char *fieldName, T &value) const |
Tries to get the enum value of the specified string. More... | |
![]() | |
Fields | fields |
String | invalidValueString |
![]() | |
static const T | zeroValue = static_cast<T>(0) |
The class implements an adapter for enums to define the string literals of the enum entries.
T | The type of the enum. |
This is a helper class to make enums parsable and loggable/formattable. This helper class is specialied for any enum T defining its string literals using EnumStrings<Tgt;.
Arp::EnumDictionary< T >::EnumDictionary | ( | const InitializerList & | fields | ) |
Constructor passing the enum fields as initializer list.
fields | The enum fields as value string pairs. |
Arp::EnumDictionary< T >::EnumDictionary | ( | const char * | invalidValueString, |
const InitializerList & | fields | ||
) |
Constructor passing the enum fields as initializer list.
fields | The enum fields as value string pairs. |
invalidValueString | A string which is used for formatting an invalid enum value. |
|
inline |
Returns the string of the specified enum entry.
value | The enum value of enum T to get the associated string from. |
If the as argument passed value is not defined in the enum.
|
inline |
Returns the value of the specified enum string.
fieldName | The name of the enum field to get the associated string from. |
If the as argument passed field name is not defined in the enum.
|
inline |
Tries to return the enum entry of the specified string.
is | The stream to read the fieldName from to get the associated enum value. |
value | The resulting enum value. |
|
inline |
Returns the string of the specified enum value or nullptr
if the value could not be found.
value | The enum value of enum T to get the associated string from. | ||
pResult | The string of the as argument passed enum value or nullptr if it could not be found.
|
|
inline |
Tries to get the enum value of the specified string.
fieldName | The string to get the associated enum value from. |
value | The resulting enum value. |
true
on success, otherwise false
.std::ostream & Arp::EnumDictionary< T >::WriteEnumString | ( | std::ostream & | os, |
T | value | ||
) | const |
Writes the string of the specified enum value to the given stream.
os | The stream to write the enum string to. |
value | The enum value to write. |
If the field name of the given enum value could not be found, the enum value is written as hex-string to the stream.