matador::basic_json_mapper< T, S > Class Template Reference

A base class for all kind of json mapping. More...

#include <basic_json_mapper.hpp>

Inherits matador::generic_json_parser< basic_json_mapper< T, S > >.

Public Types

typedef generic_json_parser< basic_json_mapper< T, S > > base
 

Public Member Functions

 basic_json_mapper ()
 
object_from_string (const char *str)
 
void object_from_string (const char *str, T *obj)
 
std::vector< T > array_from_string (const char *str)
 

Additional Inherited Members

- Protected Member Functions inherited from matador::generic_json_parser< basic_json_mapper< T, S > >
 generic_json_parser ()=default
 
void on_parse_object (bool check_for_eos)
 
void on_parse_array (bool check_for_eos)
 
void on_begin_object ()
 
void on_object_key (const std::string &)
 
void on_end_object ()
 
void on_begin_array ()
 
void on_end_array ()
 
void on_string (const std::string &)
 
void on_integer (long long)
 
void on_real (double)
 
void on_bool (bool)
 
void on_null ()
 
void sync_cursor (const char *cursor)
 

Detailed Description

template<class T, class S>
class matador::basic_json_mapper< T, S >

A base class for all kind of json mapping.

The class acts as a boilerplate for all concrete json mapping classes (

See also
json_mapper and
json_object_mapper)

It uses internally a generic json parser in combination with a given serialization class type S to map a json string to an object of type T.

Template Parameters
TType of the object to which the json string is mapped
SThe internally used serialization class type

Member Typedef Documentation

◆ base

template<class T , class S >
typedef generic_json_parser<basic_json_mapper<T, S> > matador::basic_json_mapper< T, S >::base

Shortcut to this base class

Constructor & Destructor Documentation

◆ basic_json_mapper()

template<class T , class S >
matador::basic_json_mapper< T, S >::basic_json_mapper ( )
inline

Creates the basic json mapper

Member Function Documentation

◆ array_from_string()

template<class T , class S >
std::vector< T > matador::basic_json_mapper< T, S >::array_from_string ( const char *  str)
inline

Maps a given json string to an array of objects of type type. if the json string doesn't contain an array a

See also
json_exception is thrown
Parameters
strThe json array string to parse
Returns
List of mapped objects

◆ object_from_string() [1/2]

template<class T , class S >
T matador::basic_json_mapper< T, S >::object_from_string ( const char *  str)
inline

Maps a given json string to an new object of type T.

Parameters
strJson string to parse and map
Returns
The mapped object

◆ object_from_string() [2/2]

template<class T , class S >
void matador::basic_json_mapper< T, S >::object_from_string ( const char *  str,
T *  obj 
)
inline

Maps a given json string to the given object of type T.

Parameters
strJson string to parse and map
objThe object to map

The documentation for this class was generated from the following file:
  • matador/json/basic_json_mapper.hpp