CppCMS
|
This is the traits class for serialization traits. More...
#include <cppcms/serialization_classes.h>
Static Public Member Functions | |
static void | load (std::string const &serialized_object, Object &real_object) |
static void | save (Object const &real_object, std::string &serialized_object) |
This is the traits class for serialization traits.
It allows user to use arbitrary serialization libraries or use its own serialization rules, for example you can use boost::serialization.
For this purpose user should specialize the serialization_traits struct for his type.
For example: We want to allow a serialization of a point class:
/ namespace cppcms { template<> struct serialization_traits<point> { void load(std::string const &serialized_object,point &real_object) { std::stringstream ss(serialized_object); ss >> real_object.x >> real_object.y; } void save(point const &real_object,std::string &serialized_object) { std::stringstream ss; ss << real_object.x << ' ' << real_object.y; serialized_object = ss.str(); } }; } // cppcms
static void cppcms::serialization_traits< Object >::load | ( | std::string const & | serialized_object, |
Object & | real_object | ||
) | [static] |
Load real_object from the serialized_object representation (std::string)
static void cppcms::serialization_traits< Object >::save | ( | Object const & | real_object, |
std::string & | serialized_object | ||
) | [static] |
Save real_object to the serialized_object representation (std::string)