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