1 #ifndef BOOST_SERIALIZATION_SERIALIZATION_HPP
2 #define BOOST_SERIALIZATION_SERIALIZATION_HPP
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
9 #if defined(_MSC_VER) && (_MSC_VER >= 1310)
10 # pragma warning (disable : 4675) // suppress ADL warning
13 #include <boost/config.hpp>
14 #include <boost/serialization/strong_typedef.hpp>
15 #include <boost/serialization/pfto.hpp>
16 #include <boost/serialization/throw_exception.hpp>
17 #include <boost/serialization/nvp.hpp>
19 // incremented for each "release"
20 #define BOOST_SERIALIZATION_LIBRARY_VERSION 19
22 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
23 // serialization.hpp: interface for serialization system.
25 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
26 // Use, modification and distribution is subject to the Boost Software
27 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
28 // http://www.boost.org/LICENSE_1_0.txt)
30 // See http://www.boost.org for updates, documentation, and revision history.
32 //////////////////////////////////////////////////////////////////////
33 // public interface to serialization.
35 /////////////////////////////////////////////////////////////////////////////
36 // layer 0 - intrusive verison
37 // declared and implemented for each user defined class to be serialized
40 // serialize(Archive &ar, const unsigned int file_version){
41 // ar & base_object<base>(*this) & member1 & member2 ... ;
44 /////////////////////////////////////////////////////////////////////////////
45 // layer 1 - layer that routes member access through the access class.
46 // this is what permits us to grant access to private class member functions
47 // by specifying friend class boost::serialization::access
49 #include <boost/serialization/access.hpp>
51 /////////////////////////////////////////////////////////////////////////////
52 // layer 2 - default implementation of non-intrusive serialization.
54 // note the usage of function overloading to compensate that C++ does not
55 // currently support Partial Template Specialization for function templates
56 // We have declared the version number as "const unsigned long".
57 // Overriding templates for specific data types should declare the version
58 // number as "const unsigned int". Template matching will first be applied
59 // to functions with the same version types - that is the overloads.
60 // If there is no declared function prototype that matches, the second argument
61 // will be converted to "const unsigned long" and a match will be made with
62 // one of the default template functions below.
65 namespace serialization
{
67 BOOST_STRONG_TYPEDEF(unsigned int, version_type
)
69 // default implemenation - call the member function "serialize"
70 template<class Archive
, class T
>
71 inline void serialize(
72 Archive
& ar
, T
& t
, const BOOST_PFTO
unsigned int file_version
74 access::serialize(ar
, t
, static_cast<unsigned int>(file_version
));
77 // save data required for construction
78 template<class Archive
, class T
>
79 inline void save_construct_data(
82 const BOOST_PFTO
unsigned int /*file_version */
84 // default is to save no data because default constructor
85 // requires no arguments.
88 // load data required for construction and invoke constructor in place
89 template<class Archive
, class T
>
90 inline void load_construct_data(
93 const BOOST_PFTO
unsigned int /*file_version*/
95 // default just uses the default constructor. going
96 // through access permits usage of otherwise private default
98 access::construct(ar
, t
);
101 /////////////////////////////////////////////////////////////////////////////
102 // layer 3 - move call into serialization namespace so that ADL will function
103 // in the manner we desire.
105 // on compilers which don't implement ADL. only the current namespace
106 // i.e. boost::serialization will be searched.
108 // on compilers which DO implement ADL
109 // serialize overrides can be in any of the following
111 // 1) same namepace as Archive
112 // 2) same namespace as T
113 // 3) boost::serialization
115 // Due to Martin Ecker
117 template<class Archive
, class T
>
118 inline void serialize_adl(
121 const unsigned int file_version
123 // note usage of function overloading to delay final resolution
124 // until the point of instantiation. This works around the two-phase
125 // lookup "feature" which inhibits redefintion of a default function
126 // template implementation. Due to Robert Ramey
128 // Note that this trick generates problems for compiles which don't support
129 // PFTO, suppress it here. As far as we know, there are no compilers
130 // which fail to support PFTO while supporting two-phase lookup.
131 #if ! defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
132 const version_type
v(file_version
);
135 serialize(ar
, t
, file_version
);
139 template<class Archive
, class T
>
140 inline void save_construct_data_adl(
143 const unsigned int file_version
146 #if ! defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
147 const version_type
v(file_version
);
148 save_construct_data(ar
, t
, v
);
150 save_construct_data(ar
, t
, file_version
);
154 template<class Archive
, class T
>
155 inline void load_construct_data_adl(
158 const unsigned int file_version
161 #if ! defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
162 const version_type
v(file_version
);
163 load_construct_data(ar
, t
, v
);
165 load_construct_data(ar
, t
, file_version
);
169 } // namespace serialization
172 #endif //BOOST_SERIALIZATION_SERIALIZATION_HPP