Radium Engine  1.5.20
Loading...
Searching...
No Matches
EnumConverter.hpp
1#pragma once
2
3#include <Core/CoreMacros.hpp>
4
5#include <Core/Utils/BijectiveAssociation.hpp>
6
7#include <initializer_list>
8#include <vector>
9
10namespace Ra {
11namespace Core {
12namespace Utils {
13
23template <typename EnumBaseType>
25{
30 public:
32
33 std::string getEnumerator( EnumBaseType v ) const;
34 EnumBaseType getEnumerator( const std::string& v ) const;
35 std::vector<std::string> getEnumerators() const;
36
37 private:
39};
40
41/* -------------------------------------------------------------------------------------------
42 * Implementation of template functions
43 * -----------------------------------------------------------------------------------------*/
44
45template <typename EnumBaseType>
49
50template <typename EnumBaseType>
52 return m_valueToString( v );
53}
54
55template <typename EnumBaseType>
56EnumBaseType EnumConverter<EnumBaseType>::getEnumerator( const std::string& v ) const {
57 return m_valueToString.key( v );
58}
59
60template <typename EnumBaseType>
63 keys.reserve( m_valueToString.size() );
64 for ( const auto& p : m_valueToString ) {
65 keys.push_back( p.second );
66 }
67 return keys;
68}
69
70} // namespace Utils
71} // namespace Core
72} // namespace Ra
Bijective association between two sets {keys} and {values} having the same cardinality....
This class manage the bijective association between string and integral representation of an enumerat...
EnumConverter(std::initializer_list< std::pair< EnumBaseType, std::string > > pairs)
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3
T push_back(T... args)
T reserve(T... args)