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 <cstddef> // size_t
14 #include <boost/config.hpp>
15 #if defined(BOOST_NO_STDC_NAMESPACE)
21 #include <boost/strong_typedef.hpp>
22 #include <boost/pfto.hpp>
23 #include <boost/throw_exception.hpp>
24 #include <boost/serialization/nvp.hpp>
26 // incremented for each "release"
27 #define BOOST_SERIALIZATION_LIBRARY_VERSION 19
29 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
30 // serialization.hpp: interface for serialization system.
32 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
33 // Use, modification and distribution is subject to the Boost Software
34 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
35 // http://www.boost.org/LICENSE_1_0.txt)
37 // See http://www.boost.org for updates, documentation, and revision history.
39 //////////////////////////////////////////////////////////////////////
40 // public interface to serialization.
42 /////////////////////////////////////////////////////////////////////////////
43 // layer 0 - intrusive verison
44 // declared and implemented for each user defined class to be serialized
47 // serialize(Archive &ar, const unsigned int file_version){
48 // ar & base_object<base>(*this) & member1 & member2 ... ;
51 /////////////////////////////////////////////////////////////////////////////
52 // layer 1 - layer that routes member access through the access class.
53 // this is what permits us to grant access to private class member functions
54 // by specifying friend class boost::serialization::access
56 #include <boost/serialization/access.hpp>
58 /////////////////////////////////////////////////////////////////////////////
59 // layer 2 - default implementation of non-intrusive serialization.
61 // note the usage of function overloading to compensate that C++ does not
62 // currently support Partial Template Specialization for function templates
63 // We have declared the version number as "const unsigned long".
64 // Overriding templates for specific data types should declare the version
65 // number as "const unsigned int". Template matching will first be applied
66 // to functions with the same version types - that is the overloads.
67 // If there is no declared function prototype that matches, the second argument
68 // will be converted to "const unsigned long" and a match will be made with
69 // one of the default template functions below.
72 namespace serialization {
74 BOOST_STRONG_TYPEDEF(unsigned int, version_type)
76 // default implemenation - call the member function "serialize"
77 template<class Archive, class T>
78 inline void serialize(
79 Archive & ar, T & t, const BOOST_PFTO unsigned int file_version
81 access::serialize(ar, t, static_cast<unsigned int>(file_version));
84 // save data required for construction
85 template<class Archive, class T>
86 inline void save_construct_data(
89 const BOOST_PFTO unsigned int /*file_version */
91 // default is to save no data because default constructor
92 // requires no arguments.
95 // load data required for construction and invoke constructor in place
96 template<class Archive, class T>
97 inline void load_construct_data(
100 const BOOST_PFTO unsigned int /*file_version*/
102 // default just uses the default constructor. going
103 // through access permits usage of otherwise private default
105 access::construct(ar, t);
108 /////////////////////////////////////////////////////////////////////////////
109 // layer 3 - move call into serialization namespace so that ADL will function
110 // in the manner we desire.
112 // on compilers which don't implement ADL. only the current namespace
113 // i.e. boost::serialization will be searched.
115 // on compilers which DO implement ADL
116 // serialize overrides can be in any of the following
118 // 1) same namepace as Archive
119 // 2) same namespace as T
120 // 3) boost::serialization
122 // Due to Martin Ecker
124 template<class Archive, class T>
125 inline void serialize_adl(
128 const unsigned int file_version
130 // note usage of function overloading to delay final resolution
131 // until the point of instantiation. This works around the two-phase
132 // lookup "feature" which inhibits redefintion of a default function
133 // template implementation. Due to Robert Ramey
135 // Note that this trick generates problems for compiles which don't support
136 // PFTO, suppress it here. As far as we know, there are no compilers
137 // which fail to support PFTO while supporting two-phase lookup.
138 #if ! defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
139 const version_type v(file_version);
142 serialize(ar, t, file_version);
146 template<class Archive, class T>
147 inline void save_construct_data_adl(
150 const unsigned int file_version
153 #if ! defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
154 const version_type v(file_version);
155 save_construct_data(ar, t, v);
157 save_construct_data(ar, t, file_version);
161 template<class Archive, class T>
162 inline void load_construct_data_adl(
165 const unsigned int file_version
168 #if ! defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
169 const version_type v(file_version);
170 load_construct_data(ar, t, v);
172 load_construct_data(ar, t, file_version);
176 } // namespace serialization
179 #endif //BOOST_SERIALIZATION_SERIALIZATION_HPP