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

JSON primitive types mapper. More...

#include <primitiveMapper.hpp>

Inheritance diagram for anch::json::PrimitiveMapper< T >:
Collaboration diagram for anch::json::PrimitiveMapper< T >:

Public Member Functions

 PrimitiveMapper (const PrimitiveMapper &other)=delete
 PrimitiveMapper (PrimitiveMapper &&other)=delete
const anch::json::GenericMapper< PrimitiveMapper< T >, T > & generic () const
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) const
Public Member Functions inherited from anch::json::GenericMapper< PrimitiveMapper< T >, T >
bool deserialize (std::optional< T > &value, anch::json::ReaderContext &context) const

Additional Inherited Members

Protected Member Functions inherited from anch::json::GenericMapper< PrimitiveMapper< T >, T >
 GenericMapper ()
virtual ~GenericMapper ()

Detailed Description

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

JSON primitive types mapper.

JSON primitive types does not have any fields.

Template Parameters
Tthe object type
Author
Vincent Lachenal
Since
0.1

Constructor & Destructor Documentation

◆ PrimitiveMapper() [1/2]

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

Forbids PrimitiveMapper copy constructor

Parameters
otherthe other mapper not to copy

◆ PrimitiveMapper() [2/2]

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

Forbids PrimitiveMapper move constructor

Parameters
otherthe other mapper not to move

Member Function Documentation

◆ deserialize()

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

Deserialize JSON value

Parameters
valuethe value to set
contextthe mapping context
Returns
\false when value is null , false otherwise

◆ generic()

template<typename T>
const anch::json::GenericMapper< PrimitiveMapper< T >, T > & anch::json::PrimitiveMapper< T >::generic ( ) const

Get generic mapper implementation

Returns
*this

◆ serialize() [1/7]

template<typename T>
bool anch::json::PrimitiveMapper< 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::PrimitiveMapper< 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 map (as std::map ) attribute

Parameters
valuethe map 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::PrimitiveMapper< 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 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 set , false otherwise

◆ serialize() [4/7]

template<typename T>
bool anch::json::PrimitiveMapper< 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::PrimitiveMapper< 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::PrimitiveMapper< 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::PrimitiveMapper< 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: