18 #ifndef LUNCHBOX_ANYSERIALIZATION_H
19 #define LUNCHBOX_ANYSERIALIZATION_H
21 #include <lunchbox/any.h>
23 #include <lunchbox/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,
56 template<
class Archive >
57 struct registerWrapper
59 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 );