PLCnext API Documentation 23.6.0.37
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Arp::EnumDictionaryBase< T > Class Template Reference

The class implements an adapter for enums to define the string literals of the enum entries. More...

#include <EnumDictionaryBase.hxx>

Inheritance diagram for Arp::EnumDictionaryBase< T >:
Inheritance graph

Public Member Functions

 EnumDictionaryBase (const InitializerList &fields)
 
 EnumDictionaryBase (const char *invalidValueString, const InitializerList &fields)
 

Protected Types

using Fields = std::map< T, const char * >
 
using InitializerList = std::initializer_list< typename Fields::value_type >
 
using U = typename std::underlying_type< T >::type
 

Protected Member Functions

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...
 

Protected Attributes

Fields fields
 
String invalidValueString
 

Static Protected Attributes

static const T zeroValue = static_cast<T>(0)
 

Detailed Description

template<class T>
class Arp::EnumDictionaryBase< T >

The class implements an adapter for enums to define the string literals of the enum entries.

Template Parameters
TThe 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;.

Member Function Documentation

◆ TryGetEnumStringInternal()

template<class T >
bool Arp::EnumDictionaryBase< T >::TryGetEnumStringInternal ( value,
const char *&  pResult 
) const
inlineprotected

Returns the string of the specified enum value or nullptr if the value could not be found.

Parameters
valueThe enum value of enum T to get the associated string from.
pResultThe string of the as argument passed enum value or nullptr if it could not be found.
Parameters
value
Returns
true on success, otherwise false.

◆ TryGetEnumValueInternal()

template<class T >
bool Arp::EnumDictionaryBase< T >::TryGetEnumValueInternal ( const char *  fieldName,
T &  value 
) const
inlineprotected

Tries to get the enum value of the specified string.

Parameters
fieldNameThe string to get the associated enum value from.
valueThe resulting enum value.
Returns
true on success, otherwise false.

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