## Struct template value_serializer<T, std::enable_if_t< std::is_enum_v< T > >>

zeep::value_serializer<T, std::enable_if_t< std::is_enum_v< T > >> — value_serializer for enum values

## Synopsis

    // 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;
    };

## Description

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 functions

1.     static 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.

2.     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.

3.     static value_serializer & instance(const char * name = nullptr);

4.     static const char * type_name();

5.     static std::string to_string(T value);

6.     static T from_string(const std::string & value);

7.     static bool empty();

### `value_serializer` public member functions

1.     value_serializer & operator()(T v, const std::string & name);

2.     value_serializer & operator()(const std::string & name, T v);