Is there any way to remove the extra 6 bytes that are put in the begin of the serialization data when serializing with Boost Serialization ? I just want to use the serialization mechanism, I don't want any version, object tracking or any other header information.
Boost serialization version information
900 views Asked by Tarantula At
3
There are 3 answers
0
On
If you want to omit version information for all classes (resulting in a more space efficient, but less robust archive), you can combine the BOOST_CLASS_IMPLEMENTATION macro with the default behavior:
namespace boost {
namespace serialization {
template <class T>
struct implementation_level_impl< const T >
{
template<class U>
struct traits_class_level {
typedef BOOST_DEDUCED_TYPENAME U::level type;
};
typedef mpl::integral_c_tag tag;
typedef
BOOST_DEDUCED_TYPENAME mpl::eval_if<
is_base_and_derived<boost::serialization::basic_traits, T>,
traits_class_level< T >,
//else
BOOST_DEDUCED_TYPENAME mpl::eval_if<
is_fundamental< T >,
mpl::int_<primitive_type>,
//else
BOOST_DEDUCED_TYPENAME mpl::eval_if<
mpl::or_<is_class< T >, is_array< T> >,
mpl::int_<object_serializable>,
//else
BOOST_DEDUCED_TYPENAME mpl::eval_if<
is_enum< T >,
mpl::int_<primitive_type>,
//else
mpl::int_<not_serializable>
>
>
>
>::type type;
BOOST_STATIC_CONSTANT(int, value = type::value);
};
}
}
I solved my problem using the implementation level:
By doing this, the serialization will not include the version in front of the raw serialized data.