18 #ifndef LUNCHBOX_ANYSERIALIZATION_H
19 #define LUNCHBOX_ANYSERIALIZATION_H
21 #include <lunchbox/any.h>
23 #include <servus/uint128_t.h>
25 #include <boost/mpl/list.hpp>
26 #include <boost/mpl/for_each.hpp>
28 #include <boost/serialization/export.hpp>
29 #include <boost/serialization/extended_type_info.hpp>
37 #define SERIALIZABLEANY( CLASS ) \
38 BOOST_CLASS_EXPORT( lunchbox::Any::holder< CLASS > )
44 typedef boost::mpl::list< int8_t, uint8_t,
49 bool, std::string, servus::uint128_t >
podTypes;
56 template<
class Archive >
57 struct registerWrapper
59 explicit registerWrapper( Archive& ar ) : ar_( ar ) {}
62 template<
typename T >
65 ar_.template register_type< Any::holder< T > >();
74 template<
class TypeList,
class Archive >
77 boost::mpl::for_each< TypeList >( registerWrapper< Archive >( ar ) );
84 template<
class Archive,
class Object,
class Stream >
88 registerTypelist< podTypes >( ar );
96 template<
class Archive,
class Object,
class Stream >
97 void saveAny( Object&
object, Stream& stream )
100 registerTypelist< podTypes >( ar );
108 template<
class Archive,
class Object,
class Stream >
109 void loadAny( Object&
object, Stream& stream )
111 Archive ar( stream );
112 registerTypelist< podTypes >( ar );
void registerTypelist(Archive &ar)
Registers the types from the given type list for serializing it inside a lunchbox::Any through the gi...
Basic type definitions not provided by the operating system.
boost::mpl::list< int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, float, double, bool, std::string, servus::uint128_t > podTypes
List of supported POD types for lunchbox::Any serialization.
void serializeAny(Object &object, Stream &stream)
Serializes the given object which can be a lunchbox::Any through the given archive type to/from the g...
Abstraction layer and common utilities for multi-threaded programming.
void saveAny(Object &object, Stream &stream)
Saves the given object which can be a lunchbox::Any through the given archive type to/from the given ...
void loadAny(Object &object, Stream &stream)
Loads the given object which can be a lunchbox::Any through the given archive type to/from the given ...