18 #ifndef INCLUDE_SF_VARIANT_HPP 19 #define INCLUDE_SF_VARIANT_HPP 21 #include <boost/variant.hpp> 23 #include <boost/mpl/front.hpp> 24 #include <boost/mpl/pop_front.hpp> 25 #include <boost/mpl/eval_if.hpp> 26 #include <boost/mpl/identity.hpp> 27 #include <boost/mpl/size.hpp> 28 #include <boost/mpl/empty.hpp> 34 class VariantSerializer :
public boost::static_visitor<>
41 void operator()(
const T &t)
const 51 struct VariantDeserializer
71 using namespace boost::mpl;
74 typedef BOOST_DEDUCED_TYPENAME front<S>::type head_type;
81 typedef BOOST_DEDUCED_TYPENAME pop_front<S>::type type;
82 VariantDeserializer<type>::load(ar, which - 1, v);
93 using namespace boost::mpl;
95 typedef BOOST_DEDUCED_TYPENAME eval_if<empty<S>,
96 boost::mpl::identity<LoadNull>,
97 boost::mpl::identity<Load>
100 typex::invoke(ar, which, v);
105 template< BOOST_VARIANT_ENUM_PARAMS(
class T) >
108 boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) > & v,
114 VariantSerializer variantSerializer(ar);
115 v.apply_visitor(variantSerializer);
122 typedef BOOST_DEDUCED_TYPENAME
123 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types types;
125 if(which >= boost::mpl::size<types>::value)
128 RCF::RcfError_VariantDeserialization,
130 boost::mpl::size<types>::value);
135 VariantDeserializer<types>::load(ar, which, v);
140 #endif // ! INCLUDE_SF_VARIANT_HPP Represents an archive, in which serialized objects are stored.
Definition: Archive.hpp:31
Base class for all RCF exceptions.
Definition: Exception.hpp:67
Definition: ByteBuffer.hpp:188
bool isWrite() const
Returns true if this archive is being written to.