Loading [MathJax]/extensions/TeX/AMSsymbols.js
Radium Engine  1.7.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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{
31 public:
33 m_valueToString { pairs } {}
34
35 std::string getEnumerator( EnumBaseType v ) const { return m_valueToString( v ); }
36 EnumBaseType getEnumerator( const std::string& v ) const { return m_valueToString.key( v ); }
37 std::vector<std::string> getEnumerators() const {
39 keys.reserve( m_valueToString.size() );
40 for ( const auto& p : m_valueToString ) {
41 keys.push_back( p.second );
42 }
43 return keys;
44 }
45
46 private:
47 Core::Utils::BijectiveAssociation<EnumBaseType, std::string> m_valueToString;
48};
49
50} // namespace Utils
51} // namespace Core
52} // namespace Ra
size_t size() const
Gets the size of the association, i.e. the numer of <Key, Value> pairs.
key_type key(const value_type &value) const
Gets the key associated to a value.
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:4
T push_back(T... args)
T reserve(T... args)