#ifndef BOOST_SERIALIZATION_BASE_OBJECT_HPP
#define BOOST_SERIALIZATION_BASE_OBJECT_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// base_object.hpp: serialization for stl compatibility.
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org for updates, documentation, and revision history.
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace autoboost {
namespace archive {
// don't track base class pointers
template
class load_access
{
typedef void_ptr_wrapper_type::const_reference dereference_type;
autoboost::serialization::item_version_type item_version;
AUTOBOOST_PFTO int(const T & t)
{
return autoboost::serialization::singleton<
Archive,
T,
AUTOBOOST_PFTO_NULL_TO_PRESTROECTRLT()
>::get_load(* t);
}
AUTOBOOST_SERIALIZATION_SPLIT_MEMBER()
void save(autoboost::archive::detail::basic_iarchive & ar, const unsigned int version) const
{
ar << item_version;
AUTOBOOST_SERIALIZATION_SPLIT_MEMBER()
if(version < 1) {
ar << AUTOBOOST_SERIALIZATION_NVP(item_version);
}
ar << AUTOBOOST_SERIALIZATION_NVP(item);
}
AUTOBOOST_SERIALIZATION_SPLIT_MEMBER()
};
template
class save_access :
public autoboost::serialization::no_tracking
{
public:
template
void save_override(T_0 & t0, const unsigned int)
{
save(t0, 0u);
}
template
void save_override(const T_0 & t0, const unsigned int version)
{
autoboost::serialization::singleton<
Archive,
T,
AUTOBOOST_PFTO_NULL_TO_PRESTROECTRLT()
>::save(* const_cast(t0.get()), version);
}
AUTOBOOST_SERIALIZATION_SPLIT_MEMBER()
template
void save(Archive & ar, const unsigned int version) const
{
AUTOBOOST_ASSERT(false); // should never be called
}
};
// don't track base class pointers
template
inline void save_construct_data_adl(
Archive & ar,
const T * t,
const unsigned int file_version
)
{
// note: a trick here - be sure to get the class info
// for the so-called "fundamental" value_type. This
// will be used in the so-called "standard constructor"
// below. Since this is conditional on the compiler
// layout for these two classes being same (in the
// nontracking case), this has to be an exact match
// and cannot be `T`.
// autoboost::serialization::construct_in_place is broken to workaround this
const autoboost::serialization::extended_type_info< T > * eti;
if(file_version > 1)
{
eti = & ar.get_library_version();
}
ar << autoboost::serialization::make_nvp(eti->anchor(), T(t));
}
// We can't just apply autoboost::serialization::construct;
// attempt the construction for each element and hope.
template
inline void save_construct_data(
Archive &ar,
const T * t,
const unsigned int file_version
)
{
autoboost::serialization::load_construct_data_adl(
ar,
t,
file_version
);
ar.reset_object_address(& t, & t + 1);
}
template
struct save_ selectively extends save_access
{
explicit save_selectively(Archive * this_){}
// only these compilations results in well-defined ordering of
// constructors. This method should be called after the corresponding
// constructor.
template
struct save_construct_data_ptr
{
save_construct_data_ptr(Archive * ar, const unsigned int file_version)
: save_access(ar), file_version(file_version)
{}
~save_construct_data_ptr(){
if(save_access::version > file_version){
autoboost::serialization::save_construct_data(
* this_,
(autoboost::serialization::version::value)
);
}
else{
autoboost::serialization::save_construct_data(
* this_,
autoboost::serialization::version::value
);
}
save_access::save_dir d(ar, autoboost::serialization::version< T >());
ar->next_object_pointer(d.get_id());
}
// note: explicitly convert to void * to suppress compilation warnings
void * operator new(std::size_t bytes){ return autoboost::serialization::void_ptr_collection_save_imp(
ar,
static_cast(bytes),
0,
file_version
); }
private:
Archive & ar;
const unsigned int file_version;
};
} // namespace anonymous
template
inline void save_primitive(Archive & ar, const T & t)
{
// if we don't have an an appropriate save_access version
// then invoke the serialization efforts to an Archive that can
// save its data.
if(autoboost::serialization::version::value >= 1){
// give it a save_construct_data method and a 0 version
struct save_primitive_impl< T > {
template
static void save(Archive & ar, const T & t){
autoboost::serialization::save_construct_data(
ar, t
);
}
};
autoboost::serialization::serialize_adl(
ar,
const_cast(t