![]() |
zeep::value_serializer<T, std::enable_if_t< std::is_enum_v< T > >> — value_serializer for enum values
// In header: <zeep/value-serializer.hpp> template<typename T> struct value_serializer<T, std::enable_if_t< std::is_enum_v< T > >> { // types typedef std::map< T, std::string > value_map_type; typedef typename value_map_type::value_type value_map_value_type; // public static functions static void init(const char *, std::initializer_list< value_map_value_type >); static void init(std::initializer_list< value_map_value_type >); static value_serializer & instance(const char * = nullptr); static const char * type_name(); static std::string to_string(T); static T from_string(const std::string &); static bool empty(); // public member functions value_serializer & operator()(T, const std::string &); value_serializer & operator()(const std::string &, T); // public data members std::string m_type_name; value_map_type m_value_map; };
This class is used to (de-)serialize enum values. To map enum values to a string you should use the singleton instance accessible through instance() and then call the operator() members assinging each of the enum values with their respective string.
A recent addition is the init() call to initialize the instance
value_serializer
public static functionsstatic void init(const char * name, std::initializer_list< value_map_value_type > values);Initialize a new instance of
value_serializer
for this enum, with name and a set of name/value pairs. static void init(std::initializer_list< value_map_value_type > values);Initialize a new anonymous instance of
value_serializer
for this enum with a set of name/value pairs. static value_serializer & instance(const char * name = nullptr);
static const char * type_name();
static std::string to_string(T value);
static T from_string(const std::string & value);
static bool empty();
value_serializer
public member functionsvalue_serializer & operator()(T v, const std::string & name);
value_serializer & operator()(const std::string & name, T v);