1 #ifndef BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP
2 #define BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_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
10 // basic_binary_iarchive.hpp
12 // archives stored as native binary - this should be the fastest way
13 // to archive the state of a group of obects. It makes no attempt to
14 // convert to any canonical form.
16 // IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE
17 // ON PLATFORM APART FROM THE ONE THEY ARE CREATED ON
19 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
20 // Use, modification and distribution is subject to the Boost Software
21 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
22 // http://www.boost.org/LICENSE_1_0.txt)
24 // See http://www.boost.org for updates, documentation, and revision history.
26 #include <boost/config.hpp>
27 #include <boost/detail/workaround.hpp>
28 #include <boost/serialization/pfto.hpp>
30 #include <boost/archive/basic_archive.hpp>
31 #include <boost/archive/detail/common_iarchive.hpp>
32 #include <boost/serialization/collection_size_type.hpp>
33 #include <boost/serialization/string.hpp>
34 #include <boost/serialization/item_version_type.hpp>
35 #include <boost/integer_traits.hpp>
38 # pragma warning(push)
39 # pragma warning(disable : 4511 4512)
42 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
47 /////////////////////////////////////////////////////////////////////////
48 // class basic_binary_iarchive - read serialized objects from a input binary stream
49 template<class Archive
>
50 class basic_binary_iarchive
:
51 public detail::common_iarchive
<Archive
>
54 #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
56 #elif defined(BOOST_MSVC)
57 // for some inexplicable reason insertion of "class" generates compile erro
59 friend detail::interface_iarchive
<Archive
>;
61 friend class detail::interface_iarchive
<Archive
>;
63 // intermediate level to support override of operators
64 // fot templates in the absence of partial function
65 // template ordering. If we get here pass to base class
66 // note extra nonsense to sneak it pass the borland compiers
67 typedef detail::common_iarchive
<Archive
> detail_common_iarchive
;
69 void load_override(T
& t
, BOOST_PFTO
int version
){
70 this->detail_common_iarchive::load_override(t
, static_cast<int>(version
));
73 // include these to trap a change in binary format which
74 // isn't specifically handled
76 BOOST_STATIC_ASSERT(sizeof(class_id_type
) == sizeof(int_least16_t));
77 BOOST_STATIC_ASSERT(sizeof(class_id_reference_type
) == sizeof(int_least16_t));
79 BOOST_STATIC_ASSERT(sizeof(object_id_type
) == sizeof(uint_least32_t));
80 BOOST_STATIC_ASSERT(sizeof(object_reference_type
) == sizeof(uint_least32_t));
82 // binary files don't include the optional information
83 void load_override(class_id_optional_type
& /* t */, int){}
85 void load_override(tracking_type
& t
, int /*version*/){
86 library_version_type lvt
= this->get_library_version();
87 if(boost::archive::library_version_type(6) < lvt
){
90 t
= boost::archive::tracking_type(x
);
95 t
= boost::archive::tracking_type(x
);
98 void load_override(class_id_type
& t
, int version
){
99 library_version_type lvt
= this->get_library_version();
100 if(boost::archive::library_version_type(7) < lvt
){
101 this->detail_common_iarchive::load_override(t
, version
);
104 if(boost::archive::library_version_type(6) < lvt
){
107 t
= boost::archive::class_id_type(x
);
112 t
= boost::archive::class_id_type(x
);
115 void load_override(class_id_reference_type
& t
, int version
){
116 load_override(static_cast<class_id_type
&>(t
), version
);
119 void load_override(class_id_reference_type
& t
, int version
){
120 library_version_type lvt
= this->get_library_version();
121 if(boost::archive::library_version_type(7) < lvt
){
122 this->detail_common_iarchive::load_override(t
, version
);
125 if(boost::archive::library_version_type(6) < lvt
){
128 t
= boost::archive::class_id_reference_type(
129 boost::archive::class_id_type(x
)
135 t
= boost::archive::class_id_reference_type(
136 boost::archive::class_id_type(x
)
142 void load_override(version_type
& t
, int version
){
143 library_version_type lvt
= this->get_library_version();
144 if(boost::archive::library_version_type(7) < lvt
){
145 this->detail_common_iarchive::load_override(t
, version
);
148 if(boost::archive::library_version_type(6) < lvt
){
151 t
= boost::archive::version_type(x
);
154 if(boost::archive::library_version_type(5) < lvt
){
157 t
= boost::archive::version_type(x
);
160 if(boost::archive::library_version_type(2) < lvt
){
169 t
= boost::archive::version_type(x
);
173 void load_override(boost::serialization::item_version_type
& t
, int version
){
174 library_version_type lvt
= this->get_library_version();
175 // if(boost::archive::library_version_type(7) < lvt){
176 if(boost::archive::library_version_type(6) < lvt
){
177 this->detail_common_iarchive::load_override(t
, version
);
180 if(boost::archive::library_version_type(6) < lvt
){
183 t
= boost::serialization::item_version_type(x
);
188 t
= boost::serialization::item_version_type(x
);
192 void load_override(serialization::collection_size_type
& t
, int version
){
193 if(boost::archive::library_version_type(5) < this->get_library_version()){
194 this->detail_common_iarchive::load_override(t
, version
);
199 t
= serialization::collection_size_type(x
);
203 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
204 load_override(class_name_type
& t
, int);
205 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
208 basic_binary_iarchive(unsigned int flags
) :
209 detail::common_iarchive
<Archive
>(flags
)
213 } // namespace archive
220 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
222 #endif // BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP