AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
anch::json::JSONMapper Class Reference

JSON mapper with mapping options. More...

#include <json.hpp>

Collaboration diagram for anch::json::JSONMapper:

Public Member Functions

 JSONMapper ()=delete
 JSONMapper (const anch::json::MappingOptions &options)
virtual ~JSONMapper ()
template<typename T>
void serialize (const T &value, std::ostream &out)
template<template< typename > typename C, typename T>
void serialize (const C< T > &value, std::ostream &out)
template<typename T>
void serialize (anch::Flux< T > &value, std::ostream &out)
template<typename T>
void serialize (const std::map< std::string, T > &value, std::ostream &out)
template<typename T>
std::string serialize (const T &value)
template<template< typename > typename C, typename T>
std::string serialize (const C< T > &value)
template<typename T>
std::string serialize (const std::map< std::string, T > &value)
template<typename T>
void deserialize (T &value, std::istream &input)
template<typename T>
deserialize (std::istream &input)
template<template< typename > typename C, typename T>
void deserialize (C< T > &values, std::istream &input)
template<typename T>
void deserialize (std::map< std::string, T > &values, std::istream &input)

Detailed Description

JSON mapper with mapping options.

JSON mapper declaration which will always use same mapping options

Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

◆ JSONMapper() [1/2]

anch::json::JSONMapper::JSONMapper ( )
delete

Forbids JSONMapper default constructor

◆ JSONMapper() [2/2]

anch::json::JSONMapper::JSONMapper ( const anch::json::MappingOptions & options)

JSONMapper constructor

Parameters
optionsthe mapping options

◆ ~JSONMapper()

virtual anch::json::JSONMapper::~JSONMapper ( )
virtual

JSONMapper destructor

Member Function Documentation

◆ deserialize() [1/4]

template<template< typename > typename C, typename T>
void anch::json::JSONMapper::deserialize ( C< T > & values,
std::istream & input )

Deserialize objects (it can also work with std::optional, std::shared_ptr, ...)

Template Parameters
Tthe object's type
Cthe container's type
Parameters
valuesthe values to fill
inputthe input stream to parse
Returns
true

◆ deserialize() [2/4]

template<typename T>
T anch::json::JSONMapper::deserialize ( std::istream & input)

Deserialize object

Template Parameters
Tthe object type
Parameters
inputthe input stream to parse
Returns
the deserialized object by copy

◆ deserialize() [3/4]

template<typename T>
void anch::json::JSONMapper::deserialize ( std::map< std::string, T > & values,
std::istream & input )

Deserialize objects

Template Parameters
Tthe object type
Parameters
valuesthe values to fill
inputthe input stream to parse

◆ deserialize() [4/4]

template<typename T>
void anch::json::JSONMapper::deserialize ( T & value,
std::istream & input )

Deserialize object

Template Parameters
Tthe object type
Parameters
valuethe value to fill
inputthe input stream to parse
Returns
true when value has been found, false otherwise

◆ serialize() [1/7]

template<typename T>
void anch::json::JSONMapper::serialize ( anch::Flux< T > & value,
std::ostream & out )

Serialize object's flux.
Error handler has to be set before this method call when needed. Consumer and finalize functions are set in this method.
This method will lock the processing until anch::Flux::finalize method has not be called (or error happened and throw itself).

Template Parameters
Tthe object type
Parameters
valuethe objects to serialize
outthe output stream to write in

◆ serialize() [2/7]

template<template< typename > typename C, typename T>
std::string anch::json::JSONMapper::serialize ( const C< T > & value)

Serialize objects (it can also work with std::optional, std::shared_ptr, ...)

Template Parameters
Tthe object's type
Cthe container's type
Parameters
valuethe object to serialize
Returns
the serialized objects as std::string

◆ serialize() [3/7]

template<template< typename > typename C, typename T>
void anch::json::JSONMapper::serialize ( const C< T > & value,
std::ostream & out )

Serialize objects (it can also work with std::optional, std::shared_ptr, ...)

Template Parameters
Tthe object's type
Cthe container's type
Parameters
valuethe objects to serialize
outthe output stream to write in

◆ serialize() [4/7]

template<typename T>
std::string anch::json::JSONMapper::serialize ( const std::map< std::string, T > & value)

Serialize objects

Template Parameters
Tthe object type
Parameters
valuethe object to serialize
Returns
the serialized objects as std::string

◆ serialize() [5/7]

template<typename T>
void anch::json::JSONMapper::serialize ( const std::map< std::string, T > & value,
std::ostream & out )

Serialize objects

Template Parameters
Tthe object type
Parameters
valuethe objects to serialize
outthe output stream to write in

◆ serialize() [6/7]

template<typename T>
std::string anch::json::JSONMapper::serialize ( const T & value)

Serialize object

Template Parameters
Tthe object type
Parameters
valuethe object to serialize
Returns
the serialized object as std::string

◆ serialize() [7/7]

template<typename T>
void anch::json::JSONMapper::serialize ( const T & value,
std::ostream & out )

Serialize object

Template Parameters
Tthe object type
Parameters
valuethe object to serialize
outthe output stream to write in

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