1 #ifndef BOOST_ARCHIVE_BASIC_ARCHIVE_HPP
2 #define BOOST_ARCHIVE_BASIC_ARCHIVE_HPP
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13 // Use, modification and distribution is subject to the Boost Software
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
17 // See http://www.boost.org for updates, documentation, and revision history.
19 #include <boost/assert.hpp>
20 #include <boost/config.hpp>
21 #include <boost/cstdint.hpp> // size_t
22 #include <boost/noncopyable.hpp>
23 #include <boost/integer_traits.hpp>
25 #include <boost/archive/detail/auto_link_archive.hpp>
26 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
32 #pragma warning( push )
33 #pragma warning( disable : 4244 4267 )
36 /* NOTE : Warning : Warning : Warning : Warning : Warning
37 * Don't ever changes this. If you do, they previously created
38 * binary archives won't be readable !!!
40 class library_version_type
{
42 typedef uint_least16_t base_type
;
45 library_version_type(): t(0) {};
46 explicit library_version_type(const unsigned int & t_
) : t(t_
){
47 BOOST_ASSERT(t_
<= boost::integer_traits
<base_type
>::const_max
);
49 library_version_type(const library_version_type
& t_
) :
52 library_version_type
& operator=(const library_version_type
& rhs
){
56 // used for text output
57 operator base_type () const {
60 // used for text input
61 operator base_type
& (){
64 bool operator==(const library_version_type
& rhs
) const {
67 bool operator<(const library_version_type
& rhs
) const {
72 BOOST_ARCHIVE_DECL(library_version_type
)
73 BOOST_ARCHIVE_VERSION();
77 typedef uint_least32_t base_type
;
80 // should be private - but MPI fails if it's not!!!
81 version_type(): t(0) {};
82 explicit version_type(const unsigned int & t_
) : t(t_
){
83 BOOST_ASSERT(t_
<= boost::integer_traits
<base_type
>::const_max
);
85 version_type(const version_type
& t_
) :
88 version_type
& operator=(const version_type
& rhs
){
92 // used for text output
93 operator base_type () const {
96 // used for text intput
97 operator base_type
& (){
100 bool operator==(const version_type
& rhs
) const {
103 bool operator<(const version_type
& rhs
) const {
108 class class_id_type
{
110 typedef int_least16_t base_type
;
113 // should be private - but then can't use BOOST_STRONG_TYPE below
114 class_id_type() : t(0) {};
115 explicit class_id_type(const int t_
) : t(t_
){
116 BOOST_ASSERT(t_
<= boost::integer_traits
<base_type
>::const_max
);
118 explicit class_id_type(const std::size_t t_
) : t(t_
){
119 // BOOST_ASSERT(t_ <= boost::integer_traits<base_type>::const_max);
121 class_id_type(const class_id_type
& t_
) :
124 class_id_type
& operator=(const class_id_type
& rhs
){
129 // used for text output
130 operator int () const {
133 // used for text input
134 operator int_least16_t &() {
137 bool operator==(const class_id_type
& rhs
) const {
140 bool operator<(const class_id_type
& rhs
) const {
145 #define NULL_POINTER_TAG boost::archive::class_id_type(-1)
147 class object_id_type
{
149 typedef uint_least32_t base_type
;
152 object_id_type(): t(0) {};
153 explicit object_id_type(const unsigned int & t_
) : t(t_
){
154 BOOST_ASSERT(t_
<= boost::integer_traits
<base_type
>::const_max
);
156 object_id_type(const object_id_type
& t_
) :
159 object_id_type
& operator=(const object_id_type
& rhs
){
163 // used for text output
164 operator uint_least32_t () const {
167 // used for text input
168 operator uint_least32_t & () {
171 bool operator==(const object_id_type
& rhs
) const {
174 bool operator<(const object_id_type
& rhs
) const {
179 #if defined(_MSC_VER)
180 #pragma warning( pop )
183 struct tracking_type
{
185 explicit tracking_type(const bool t_
= false)
188 tracking_type(const tracking_type
& t_
)
191 operator bool () const {
197 tracking_type
& operator=(const bool t_
){
201 bool operator==(const tracking_type
& rhs
) const {
204 bool operator==(const bool & rhs
) const {
207 tracking_type
& operator=(const tracking_type
& rhs
){
213 struct class_name_type
:
214 private boost::noncopyable
217 operator const char * & () const {
218 return const_cast<const char * &>(t
);
223 explicit class_name_type(const char *key_
)
224 : t(const_cast<char *>(key_
)){}
225 explicit class_name_type(char *key_
)
227 class_name_type
& operator=(const class_name_type
& rhs
){
234 no_header
= 1, // suppress archive header info
235 no_codecvt
= 2, // suppress alteration of codecvt facet
236 no_xml_tag_checking
= 4, // suppress checking of xml tags
237 no_tracking
= 8, // suppress ALL tracking
241 BOOST_ARCHIVE_DECL(const char *)
242 BOOST_ARCHIVE_SIGNATURE();
244 /* NOTE : Warning : Warning : Warning : Warning : Warning
245 * If any of these are changed to different sized types,
246 * binary_iarchive won't be able to read older archives
247 * unless you rev the library version and include conditional
248 * code based on the library version. There is nothing
249 * inherently wrong in doing this - but you have to be super
250 * careful because it's easy to get wrong and start breaking
254 #define BOOST_ARCHIVE_STRONG_TYPEDEF(T, D) \
255 class D : public T { \
257 explicit D(const T tt) : T(tt){} \
261 BOOST_ARCHIVE_STRONG_TYPEDEF(class_id_type
, class_id_reference_type
)
262 BOOST_ARCHIVE_STRONG_TYPEDEF(class_id_type
, class_id_optional_type
)
263 BOOST_ARCHIVE_STRONG_TYPEDEF(object_id_type
, object_reference_type
)
265 }// namespace archive
268 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
270 #include <boost/serialization/level.hpp>
272 // set implementation level to primitive for all types
273 // used internally by the serialization library
275 BOOST_CLASS_IMPLEMENTATION(boost::archive::library_version_type
, primitive_type
)
276 BOOST_CLASS_IMPLEMENTATION(boost::archive::version_type
, primitive_type
)
277 BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_type
, primitive_type
)
278 BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_reference_type
, primitive_type
)
279 BOOST_CLASS_IMPLEMENTATION(boost::archive::class_id_optional_type
, primitive_type
)
280 BOOST_CLASS_IMPLEMENTATION(boost::archive::class_name_type
, primitive_type
)
281 BOOST_CLASS_IMPLEMENTATION(boost::archive::object_id_type
, primitive_type
)
282 BOOST_CLASS_IMPLEMENTATION(boost::archive::object_reference_type
, primitive_type
)
283 BOOST_CLASS_IMPLEMENTATION(boost::archive::tracking_type
, primitive_type
)
285 #include <boost/serialization/is_bitwise_serializable.hpp>
287 // set types used internally by the serialization library
288 // to be bitwise serializable
290 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::library_version_type
)
291 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::version_type
)
292 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_id_type
)
293 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_id_reference_type
)
294 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_id_optional_type
)
295 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::class_name_type
)
296 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::object_id_type
)
297 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::object_reference_type
)
298 BOOST_IS_BITWISE_SERIALIZABLE(boost::archive::tracking_type
)
300 #endif //BOOST_ARCHIVE_BASIC_ARCHIVE_HPP