jsonserial2  2.0
 All Classes Functions Typedefs Enumerations
Public Member Functions | List of all members
jsonserial::JSonUserClass< C > Class Template Reference

Class that declares a user-defined class. More...

Inheritance diagram for jsonserial::JSonUserClass< C >:
jsonserial::JSonClass

Public Member Functions

template<typename Super >
JSonUserClassextends ()
 Declares a superclass (the template argument is the superclass).
 
template<typename Var >
JSonUserClassaddMember (JKString &name, Var &var)
 Declares a static or a non-member variable. More...
 
template<typename Var , typename T >
JSonUserClassaddMember (JKString &name, Var T::*var)
 Declares a member variable. More...
 
template<typename Set , typename Get >
JSonUserClassaddMember (JKString &name, void(C::*setter)(Set), Get(C::*getter)() const)
 Declares a member variable using accessors. More...
 
JSonUserClassaddMember (JKString &name, std::function< void(C &, JSonSerial &, JKString &value)> read, std::function< void(const C &, JSonSerial &)> write)
 Declares a member variable and custom functions for serializing it. More...
 
template<typename Var >
JSonUserClassaddMember (JKString &name, Var C::*var, std::function< typename makeptr< Var >::type(C &)> creator)
 Declares a member variable and a custom allocator. More...
 
template<typename Var >
JSonUserClassaddMember (JKString &name, Var C::*var, std::function< typename makearrayptr< Var >::type(C &)> element_creator)
 Declares a member variable that is an array or container and a custom element allocator. More...
 
JSonUserClasspostRead (std::function< void(C &)> fun)
 Calls a function once all members have been read. More...
 
JSonUserClasspostWrite (std::function< void(const C &)> fun)
 Calls a function once all members have been written. More...
 
JKString & className () const override
 Name of the C++ class.
 

Detailed Description

template<class C>
class jsonserial::JSonUserClass< C >

Class that declares a user-defined class.

Member Function Documentation

template<class C>
template<typename Var >
JSonUserClass& jsonserial::JSonUserClass< C >::addMember ( JKString &  name,
Var &  var 
)

Declares a static or a non-member variable.

name is the UTF8 name of the variable in the JSON file, var is the variable

template<class C>
template<typename Var , typename T >
JSonUserClass& jsonserial::JSonUserClass< C >::addMember ( JKString &  name,
Var T::*  var 
)

Declares a member variable.

name is the UTF8 name of the variable in the JSON file, var a pointer to the member

template<class C>
template<typename Set , typename Get >
JSonUserClass& jsonserial::JSonUserClass< C >::addMember ( JKString &  name,
void(C::*)(Set)  setter,
Get(C::*)() const  getter 
)

Declares a member variable using accessors.

name is the UTF8 name of the variable in the JSON file, setter its modifier, getter its accessor

Warning
this means of accessing member variables involves restrictions, see documentation.
template<class C>
JSonUserClass& jsonserial::JSonUserClass< C >::addMember ( JKString &  name,
std::function< void(C &, JSonSerial &, JKString &value)>  read,
std::function< void(const C &, JSonSerial &)>  write 
)

Declares a member variable and custom functions for serializing it.

This method allows serializing a variable in a client-specific way. name is the UTF8 name of the variable in the JSON file, read the function for reading the variable in the JSON file, and write the function for writing it.

template<class C>
template<typename Var >
JSonUserClass& jsonserial::JSonUserClass< C >::addMember ( JKString &  name,
Var C::*  var,
std::function< typename makeptr< Var >::type(C &)>  creator 
)

Declares a member variable and a custom allocator.

This method is needed when the variable is pointer which corresponding pointee does not have a no-argument constructor. name is the UTF8 name of the variable in the JSON file, var a pointer to the member, creator the function that will create the pointee (that must be returned as a pointer).

template<class C>
template<typename Var >
JSonUserClass& jsonserial::JSonUserClass< C >::addMember ( JKString &  name,
Var C::*  var,
std::function< typename makearrayptr< Var >::type(C &)>  element_creator 
)

Declares a member variable that is an array or container and a custom element allocator.

This method is needed when the variable is std container or a C array and its elements do not have a no-argument constructor. name is the UTF8 name of the variable in the JSON file, var a pointer to the member, creator the function that will create each element (that must be returned as a pointer).

template<class C>
JSonUserClass& jsonserial::JSonUserClass< C >::postRead ( std::function< void(C &)>  fun)
inline

Calls a function once all members have been read.

This function can be a lambda, a static method, a non-member function or a member function, See the documentation for appropriate arguments.

template<class C>
JSonUserClass& jsonserial::JSonUserClass< C >::postWrite ( std::function< void(const C &)>  fun)
inline

Calls a function once all members have been written.

This function can be a lambda, a static method, a non-member function or a member function, See the documentation for appropriate arguments.


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