2 #include <Core/CoreMacros.hpp>
4 #include <initializer_list>
6 #include <Core/Utils/BijectiveAssociation.hpp>
20 template <
typename EnumBaseType>
24 explicit EnumConverter( std::initializer_list<std::pair<EnumBaseType, std::string>> pairs );
26 std::string getEnumerator( EnumBaseType v )
const;
27 EnumBaseType getEnumerator(
const std::string& v )
const;
28 std::vector<std::string> getEnumerators()
const;
38 template <
typename EnumBaseType>
40 std::initializer_list<std::pair<EnumBaseType, std::string>> pairs ) :
41 m_valueToString { pairs } {}
43 template <
typename EnumBaseType>
45 return m_valueToString( v );
48 template <
typename EnumBaseType>
50 return m_valueToString.key( v );
53 template <
typename EnumBaseType>
54 std::vector<std::string> EnumConverter<EnumBaseType>::getEnumerators()
const {
55 std::vector<std::string> keys;
56 keys.reserve( m_valueToString.size() );
57 for (
const auto& p : m_valueToString ) {
58 keys.push_back( p.second );
This class manage the bijective association between string and integral representation of an enumerat...