8#ifndef ARP_USE_ARP_SYSTEM_CORE
10#include "Arp/Base/Core/Detail/EnumDictionaryBase.hxx"
27class EnumDictionaryBase
30 using Fields = std::map<T, const char*>;
31 using InitializerList = std::initializer_list<typename Fields::value_type>;
32 using U =
typename std::underlying_type<T>::type;
53 String invalidValueString;
56 static const T zeroValue =
static_cast<T
>(0);
68EnumDictionaryBase<T>::EnumDictionaryBase(
const char* invalidValueString,
const InitializerList& fields)
70 , invalidValueString(invalidValueString)
75inline bool EnumDictionaryBase<T>::TryGetEnumStringInternal(T value,
const char*& pResult)
const
78 typename Fields::const_iterator i = this->fields.find(value);
79 if (i == this->fields.end())
89inline bool EnumDictionaryBase<T>::TryGetEnumValueInternal(
const char* fieldName, T& value)
const
91 for (
const auto& item : this->fields)
93 if (::strcmp(item.second, fieldName) == 0)
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.
Definition: EnumDictionaryBase.hxx:94
std::map< T, const char * > Fields
The container type containing the value/name pairs of all enum fields.
Definition: EnumDictionaryBase.hxx:23
bool TryGetEnumValueInternal(const char *fieldName, T &value) const
Tries to get the enum value of the specified string.
Definition: EnumDictionaryBase.hxx:112
std::initializer_list< typename Fields::value_type > InitializerList
The initializer list type of the Fields container.
Definition: EnumDictionaryBase.hxx:24
typename std::underlying_type< T >::type U
The underlying integral type of the enum.
Definition: EnumDictionaryBase.hxx:25
EnumDictionaryBase(const InitializerList &fields)
Constructor passing the enum fields as initializer list.
Definition: EnumDictionaryBase.hxx:54
Root namespace for the PLCnext API