JSON Voorhees
Killer JSON for C++
|
An adapter for enumeration types. More...
#include <jsonv/serialization_util.hpp>
Public Member Functions | |
template<typename TForwardIterator > | |
enum_adapter (std::string enum_name, TForwardIterator first, TForwardIterator last) | |
Create an adapter with mapping values from the range [first, last) . More... | |
enum_adapter (std::string enum_name, std::initializer_list< std::pair< TEnum, value >> mapping) | |
Public Member Functions inherited from jsonv::adapter_for< TEnum > | |
virtual const std::type_info & | get_type () const override |
Get the run-time type this extractor knows how to extract. More... | |
virtual void | extract (const extraction_context &context, const value &from, void *into) const override |
Extract a the type from a value into a region of memory. More... | |
virtual value | to_json (const serialization_context &context, const void *from) const override |
Create a value from the value in the given region of memory. More... | |
Protected Member Functions | |
virtual TEnum | create (const extraction_context &context, const value &from) const override |
virtual value | to_json (const serialization_context &, const TEnum &from) const override |
An adapter for enumeration types.
The most common use of this is to map enum
values in C++ to string values in a JSON representation (and vice versa).
TEnum | The type to map. This is not restricted to C++ enumerations (types defined with the enum keyword), but any type you wish to restrict to a subset of values. |
FEnumComp | bool (*)(TEnum, TEnum) – a strict ordering for TEnum values. |
FValueComp | bool (*)(value, value) – a strict ordering for value objects. By default, this is a case-sensitive comparison, but this can be replaced with anything you desire (for example, use value_less_icase to ignore case in extracting from JSON). |
Definition at line 437 of file serialization_util.hpp.
|
inlineexplicit |
Create an adapter with mapping values from the range [first, last)
.
TForwardIterator | An iterator yielding the type std::pair<jsonv::value, TEnum>> |
Definition at line 446 of file serialization_util.hpp.