AnCH Framework 0.1
Another C++ Hack Framework
 
Loading...
Searching...
No Matches
anch::json::ObjectMapper< T > Class Template Reference

JSON complex object mapper. More...

#include <mapper.hpp>

+ Collaboration diagram for anch::json::ObjectMapper< T >:

Public Member Functions

 ObjectMapper (const ObjectMapper &other)=delete
 
 ObjectMapper (ObjectMapper &&other)=delete
 
bool serialize (const T &value, std::ostream &out, const anch::json::MappingOptions &options, const std::optional< std::string > &field=EMPTY_FIELD)
 
bool serialize (const T *const value, std::ostream &out, const anch::json::MappingOptions &options, const std::optional< std::string > &field=EMPTY_FIELD)
 
bool serialize (const std::optional< T > &value, std::ostream &out, const anch::json::MappingOptions &options, const std::optional< std::string > &field=EMPTY_FIELD)
 
bool serialize (const std::vector< T > &value, std::ostream &out, const anch::json::MappingOptions &options, const std::optional< std::string > &field=EMPTY_FIELD)
 
bool serialize (const std::list< T > &value, std::ostream &out, const anch::json::MappingOptions &options, const std::optional< std::string > &field=EMPTY_FIELD)
 
bool serialize (const std::set< T > &value, std::ostream &out, const anch::json::MappingOptions &options, const std::optional< std::string > &field=EMPTY_FIELD)
 
bool serialize (const std::map< std::string, T > &value, std::ostream &out, const anch::json::MappingOptions &options, const std::optional< std::string > &field=EMPTY_FIELD)
 
bool deserialize (T &value, anch::json::ReaderContext &context)
 
bool deserialize (std::optional< T > &value, anch::json::ReaderContext &context)
 
bool deserialize (T *value, anch::json::ReaderContext &context)
 
bool deserialize (std::vector< T > &value, anch::json::ReaderContext &context)
 
bool deserialize (std::list< T > &value, anch::json::ReaderContext &context)
 
bool deserialize (std::set< T > &value, anch::json::ReaderContext &context)
 
bool deserialize (std::map< std::string, T > &value, anch::json::ReaderContext &context)
 

Friends

template<typename U>
void anch::json::registerObject (ObjectMapper< U > &)
 

Detailed Description

template<typename T>
class anch::json::ObjectMapper< T >

JSON complex object mapper.

This is a generic template header implementation.
Type has to be a class or a structure. The fields have to be registered through the registerObject function implementation for the specific type.

Template Parameters
Tthe object type
Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

◆ ObjectMapper() [1/2]

template<typename T>
anch::json::ObjectMapper< T >::ObjectMapper ( const ObjectMapper< T > & other)
delete

Forbids ObjectMapper copy constructor

◆ ObjectMapper() [2/2]

template<typename T>
anch::json::ObjectMapper< T >::ObjectMapper ( ObjectMapper< T > && other)
delete

Forbids ObjectMapper move constructor

Member Function Documentation

◆ deserialize() [1/7]

template<typename T>
bool anch::json::ObjectMapper< T >::deserialize ( std::list< T > & value,
anch::json::ReaderContext & context )

Deserialize JSON

Parameters
valuethe value to write in
contextthe mapper context
Returns
true

◆ deserialize() [2/7]

template<typename T>
bool anch::json::ObjectMapper< T >::deserialize ( std::map< std::string, T > & value,
anch::json::ReaderContext & context )

Deserialize JSON

Parameters
valuethe value to write in
contextthe mapper context

◆ deserialize() [3/7]

template<typename T>
bool anch::json::ObjectMapper< T >::deserialize ( std::optional< T > & value,
anch::json::ReaderContext & context )

Deserialize JSON

Parameters
valuethe value to write in
contextthe mapper context
Returns
false when null found, true otherwise

◆ deserialize() [4/7]

template<typename T>
bool anch::json::ObjectMapper< T >::deserialize ( std::set< T > & value,
anch::json::ReaderContext & context )

Deserialize JSON

Parameters
valuethe value to write in
contextthe mapper context
Returns
true

◆ deserialize() [5/7]

template<typename T>
bool anch::json::ObjectMapper< T >::deserialize ( std::vector< T > & value,
anch::json::ReaderContext & context )

Deserialize JSON

Parameters
valuethe value to write in
inputthe input stream to parse
optionsthe options to use
Returns
true

◆ deserialize() [6/7]

template<typename T>
bool anch::json::ObjectMapper< T >::deserialize ( T & value,
anch::json::ReaderContext & context )

Deserialize JSON

Parameters
valuethe value to write in
contextthe mapper context
Returns
false when null found, true otherwise

◆ deserialize() [7/7]

template<typename T>
bool anch::json::ObjectMapper< T >::deserialize ( T * value,
anch::json::ReaderContext & context )

Deserialize JSON

Parameters
valuethe value to write in
contextthe mapper context
Returns
false when null found, true otherwise

◆ serialize() [1/7]

template<typename T>
bool anch::json::ObjectMapper< T >::serialize ( const std::list< T > & value,
std::ostream & out,
const anch::json::MappingOptions & options,
const std::optional< std::string > & field = EMPTY_FIELD )

Serialize array (as std::list ) attribute

Parameters
valuethe array attribute to serialize
outthe output stream to write the attribute
optionsthe options to use
fieldthe attribute's field name
Returns
true

◆ serialize() [2/7]

template<typename T>
bool anch::json::ObjectMapper< T >::serialize ( const std::map< std::string, T > & value,
std::ostream & out,
const anch::json::MappingOptions & options,
const std::optional< std::string > & field = EMPTY_FIELD )

Serialize array (as std::map ) attribute

Parameters
valuethe array attribute to serialize
outthe output stream to write the attribute
optionsthe options to use
fieldthe attribute's field name
Returns
true

◆ serialize() [3/7]

template<typename T>
bool anch::json::ObjectMapper< T >::serialize ( const std::optional< T > & value,
std::ostream & out,
const anch::json::MappingOptions & options,
const std::optional< std::string > & field = EMPTY_FIELD )

Serialize optional attribute

Parameters
valuethe optional attribute to serialize
outthe output stream to write the attribute
optionsthe options to use
fieldthe attribute's field name
Returns
true if attribute is not empty, false otherwise

◆ serialize() [4/7]

template<typename T>
bool anch::json::ObjectMapper< T >::serialize ( const std::set< T > & value,
std::ostream & out,
const anch::json::MappingOptions & options,
const std::optional< std::string > & field = EMPTY_FIELD )

Serialize array (as std::set ) attribute

Parameters
valuethe array attribute to serialize
outthe output stream to write the attribute
optionsthe options to use
fieldthe attribute's field name
Returns
true

◆ serialize() [5/7]

template<typename T>
bool anch::json::ObjectMapper< T >::serialize ( const std::vector< T > & value,
std::ostream & out,
const anch::json::MappingOptions & options,
const std::optional< std::string > & field = EMPTY_FIELD )

Serialize array (as std::vector ) attribute

Parameters
valuethe array attribute to serialize
outthe output stream to write the attribute
optionsthe options to use
fieldthe attribute's field name
Returns
true

◆ serialize() [6/7]

template<typename T>
bool anch::json::ObjectMapper< T >::serialize ( const T & value,
std::ostream & out,
const anch::json::MappingOptions & options,
const std::optional< std::string > & field = EMPTY_FIELD )

Serialize reference attribute

Parameters
valuethe reference attribute to serialize
outthe output stream to write the attribute
optionsthe options to use
fieldthe attribute's field name
Returns
true

◆ serialize() [7/7]

template<typename T>
bool anch::json::ObjectMapper< T >::serialize ( const T *const value,
std::ostream & out,
const anch::json::MappingOptions & options,
const std::optional< std::string > & field = EMPTY_FIELD )

Serialize pointer attribute

Parameters
valuethe pointer attribute to serialize
outthe output stream to write the attribute
optionsthe options to use
fieldthe attribute's field name
Returns
true if attribute is not NULL, false otherwise

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