Loading...
Searching...
No Matches
JsValueTypeConverter< ValueType, MapType, UseInt64 > Class Template Reference

A helper class that can convert recursive JsValue structures to identical structures using a different container type. More...

#include <converter.h>

Static Public Member Functions

static ValueType Convert (const JsValue &value)
 Converts the given value recursively to a structure using the value and map types specified by the ValueType and MapType class template parameters.
 

Detailed Description

template<class ValueType, class MapType, bool UseInt64 = true>
class JsValueTypeConverter< ValueType, MapType, UseInt64 >

A helper class that can convert recursive JsValue structures to identical structures using a different container type.

The destination container type is determined by the ValueType template parameter, while the type to map objects to is determined by the MapType template parameter.

It is expected that the class ValueType is default constructable. A default constructed ValueType is used to represent JSON null. The value type must also support construction from the fundamental bool, string, real and integer types supported by JsValue.

JsArray values are converted to std::vector<ValueType>, and JsObject values are converted to the MapType. MapType must have a value type of ValueType, and support operator[] assignment.

If the UseInt64 template parameter is true (default), value types converted from JsValue::IntType hold uint64_t or int64_t. If the parameter is false, all IntType values are converted to int. Note that this may cause truncation if the JsValue holds values too large to be stored in an int on this platform.

Definition at line 79 of file converter.h.

Member Function Documentation

◆ Convert()

static ValueType Convert ( const JsValue value)
inlinestatic

Converts the given value recursively to a structure using the value and map types specified by the ValueType and MapType class template parameters.

Definition at line 86 of file converter.h.


The documentation for this class was generated from the following file: