CppCMS
Static Public Member Functions | List of all members
cppcms::serialization_traits< Object > Struct Template Reference

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)
 

Detailed Description

template<typename Object>
struct cppcms::serialization_traits< 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

Member Function Documentation

template<typename Object >
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)

Referenced by cppcms::session_interface::fetch_data(), and cppcms::cache_interface::fetch_data().

template<typename Object >
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)

Referenced by cppcms::session_interface::store_data(), and cppcms::cache_interface::store_data().


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