19 #ifndef INCLUDE_SF_VARIANT_HPP 20 #define INCLUDE_SF_VARIANT_HPP 22 #include <boost/variant.hpp> 24 #include <boost/mpl/front.hpp> 25 #include <boost/mpl/pop_front.hpp> 26 #include <boost/mpl/eval_if.hpp> 27 #include <boost/mpl/identity.hpp> 28 #include <boost/mpl/size.hpp> 29 #include <boost/mpl/empty.hpp> 35 class VariantSerializer :
public boost::static_visitor<>
42 void operator()(
const T &t)
const 52 struct VariantDeserializer
72 using namespace boost::mpl;
75 typedef BOOST_DEDUCED_TYPENAME front<S>::type head_type;
82 typedef BOOST_DEDUCED_TYPENAME pop_front<S>::type type;
83 VariantDeserializer<type>::load(ar, which - 1, v);
94 using namespace boost::mpl;
96 typedef BOOST_DEDUCED_TYPENAME eval_if<empty<S>,
97 boost::mpl::identity<LoadNull>,
98 boost::mpl::identity<Load>
101 typex::invoke(ar, which, v);
106 template< BOOST_VARIANT_ENUM_PARAMS(
class T) >
109 boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) > & v,
115 VariantSerializer variantSerializer(ar);
116 v.apply_visitor(variantSerializer);
123 typedef BOOST_DEDUCED_TYPENAME
124 boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types types;
126 if(which >= boost::mpl::size<types>::value)
129 RCF::RcfError_VariantDeserialization,
131 boost::mpl::size<types>::value);
136 VariantDeserializer<types>::load(ar, which, v);
141 #endif // ! INCLUDE_SF_VARIANT_HPP Represents an archive, in which serialized objects are stored.
Definition: Archive.hpp:32
Base class for all RCF exceptions.
Definition: Exception.hpp:64
Definition: ByteBuffer.hpp:189
bool isWrite() const
Returns true if this archive is being written to.