williamr@2: #ifndef BOOST_SERIALIZATION_SERIALIZATION_HPP williamr@2: #define BOOST_SERIALIZATION_SERIALIZATION_HPP williamr@2: williamr@2: // MS compatible compilers support #pragma once williamr@2: #if defined(_MSC_VER) && (_MSC_VER >= 1020) williamr@2: # pragma once williamr@2: #endif williamr@2: williamr@2: #if defined(_MSC_VER) && (_MSC_VER >= 1310) williamr@2: # pragma warning (disable : 4675) // suppress ADL warning williamr@2: #endif williamr@2: williamr@2: #include // size_t williamr@2: #include williamr@2: #if defined(BOOST_NO_STDC_NAMESPACE) williamr@2: namespace std{ williamr@2: using ::size_t; williamr@2: } // namespace std williamr@2: #endif williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: // incremented for each "release" williamr@2: #define BOOST_SERIALIZATION_LIBRARY_VERSION 19 williamr@2: williamr@2: /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 williamr@2: // serialization.hpp: interface for serialization system. williamr@2: williamr@2: // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . williamr@2: // Use, modification and distribution is subject to the Boost Software williamr@2: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at williamr@2: // http://www.boost.org/LICENSE_1_0.txt) williamr@2: williamr@2: // See http://www.boost.org for updates, documentation, and revision history. williamr@2: williamr@2: ////////////////////////////////////////////////////////////////////// williamr@2: // public interface to serialization. williamr@2: williamr@2: ///////////////////////////////////////////////////////////////////////////// williamr@2: // layer 0 - intrusive verison williamr@2: // declared and implemented for each user defined class to be serialized williamr@2: // williamr@2: // template williamr@2: // serialize(Archive &ar, const unsigned int file_version){ williamr@2: // ar & base_object(*this) & member1 & member2 ... ; williamr@2: // } williamr@2: williamr@2: ///////////////////////////////////////////////////////////////////////////// williamr@2: // layer 1 - layer that routes member access through the access class. williamr@2: // this is what permits us to grant access to private class member functions williamr@2: // by specifying friend class boost::serialization::access williamr@2: williamr@2: #include williamr@2: williamr@2: ///////////////////////////////////////////////////////////////////////////// williamr@2: // layer 2 - default implementation of non-intrusive serialization. williamr@2: // williamr@2: // note the usage of function overloading to compensate that C++ does not williamr@2: // currently support Partial Template Specialization for function templates williamr@2: // We have declared the version number as "const unsigned long". williamr@2: // Overriding templates for specific data types should declare the version williamr@2: // number as "const unsigned int". Template matching will first be applied williamr@2: // to functions with the same version types - that is the overloads. williamr@2: // If there is no declared function prototype that matches, the second argument williamr@2: // will be converted to "const unsigned long" and a match will be made with williamr@2: // one of the default template functions below. williamr@2: williamr@2: namespace boost { williamr@2: namespace serialization { williamr@2: williamr@2: BOOST_STRONG_TYPEDEF(unsigned int, version_type) williamr@2: williamr@2: // default implemenation - call the member function "serialize" williamr@2: template williamr@2: inline void serialize( williamr@2: Archive & ar, T & t, const BOOST_PFTO unsigned int file_version williamr@2: ){ williamr@2: access::serialize(ar, t, static_cast(file_version)); williamr@2: } williamr@2: williamr@2: // save data required for construction williamr@2: template williamr@2: inline void save_construct_data( williamr@2: Archive & /*ar*/, williamr@2: const T * /*t*/, williamr@2: const BOOST_PFTO unsigned int /*file_version */ williamr@2: ){ williamr@2: // default is to save no data because default constructor williamr@2: // requires no arguments. williamr@2: } williamr@2: williamr@2: // load data required for construction and invoke constructor in place williamr@2: template williamr@2: inline void load_construct_data( williamr@2: Archive & ar, williamr@2: T * t, williamr@2: const BOOST_PFTO unsigned int /*file_version*/ williamr@2: ){ williamr@2: // default just uses the default constructor. going williamr@2: // through access permits usage of otherwise private default williamr@2: // constructor williamr@2: access::construct(ar, t); williamr@2: } williamr@2: williamr@2: ///////////////////////////////////////////////////////////////////////////// williamr@2: // layer 3 - move call into serialization namespace so that ADL will function williamr@2: // in the manner we desire. williamr@2: // williamr@2: // on compilers which don't implement ADL. only the current namespace williamr@2: // i.e. boost::serialization will be searched. williamr@2: // williamr@2: // on compilers which DO implement ADL williamr@2: // serialize overrides can be in any of the following williamr@2: // williamr@2: // 1) same namepace as Archive williamr@2: // 2) same namespace as T williamr@2: // 3) boost::serialization williamr@2: // williamr@2: // Due to Martin Ecker williamr@2: williamr@2: template williamr@2: inline void serialize_adl( williamr@2: Archive & ar, williamr@2: T & t, williamr@2: const unsigned int file_version williamr@2: ){ williamr@2: // note usage of function overloading to delay final resolution williamr@2: // until the point of instantiation. This works around the two-phase williamr@2: // lookup "feature" which inhibits redefintion of a default function williamr@2: // template implementation. Due to Robert Ramey williamr@2: // williamr@2: // Note that this trick generates problems for compiles which don't support williamr@2: // PFTO, suppress it here. As far as we know, there are no compilers williamr@2: // which fail to support PFTO while supporting two-phase lookup. williamr@2: #if ! defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) williamr@2: const version_type v(file_version); williamr@2: serialize(ar, t, v); williamr@2: #else williamr@2: serialize(ar, t, file_version); williamr@2: #endif williamr@2: } williamr@2: williamr@2: template williamr@2: inline void save_construct_data_adl( williamr@2: Archive & ar, williamr@2: const T * t, williamr@2: const unsigned int file_version williamr@2: ){ williamr@2: // see above williamr@2: #if ! defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) williamr@2: const version_type v(file_version); williamr@2: save_construct_data(ar, t, v); williamr@2: #else williamr@2: save_construct_data(ar, t, file_version); williamr@2: #endif williamr@2: } williamr@2: williamr@2: template williamr@2: inline void load_construct_data_adl( williamr@2: Archive & ar, williamr@2: T * t, williamr@2: const unsigned int file_version williamr@2: ){ williamr@2: // see above comment williamr@2: #if ! defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) williamr@2: const version_type v(file_version); williamr@2: load_construct_data(ar, t, v); williamr@2: #else williamr@2: load_construct_data(ar, t, file_version); williamr@2: #endif williamr@2: } williamr@2: williamr@2: } // namespace serialization williamr@2: } // namespace boost williamr@2: williamr@2: #endif //BOOST_SERIALIZATION_SERIALIZATION_HPP