Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:29

0001 #ifndef BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP
0002 #define BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP
0003 
0004 // MS compatible compilers support #pragma once
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #endif
0008 
0009 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0010 // basic_binary_iarchive.hpp
0011 //
0012 // archives stored as native binary - this should be the fastest way
0013 // to archive the state of a group of objects.  It makes no attempt to
0014 // convert to any canonical form.
0015 
0016 // IN GENERAL, ARCHIVES CREATED WITH THIS CLASS WILL NOT BE READABLE
0017 // ON PLATFORM APART FROM THE ONE THEY ARE CREATED ON
0018 
0019 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
0020 // Use, modification and distribution is subject to the Boost Software
0021 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0022 // http://www.boost.org/LICENSE_1_0.txt)
0023 
0024 //  See http://www.boost.org for updates, documentation, and revision history.
0025 
0026 #include <boost/config.hpp>
0027 #include <boost/detail/workaround.hpp>
0028 
0029 #include <boost/archive/basic_archive.hpp>
0030 #include <boost/archive/detail/common_iarchive.hpp>
0031 #include <boost/serialization/collection_size_type.hpp>
0032 #include <boost/serialization/string.hpp>
0033 #include <boost/serialization/library_version_type.hpp>
0034 #include <boost/serialization/item_version_type.hpp>
0035 #include <boost/integer_traits.hpp>
0036 
0037 #ifdef BOOST_MSVC
0038 #  pragma warning(push)
0039 #  pragma warning(disable : 4511 4512)
0040 #endif
0041 
0042 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
0043 
0044 namespace boost {
0045 namespace archive {
0046 
0047 namespace detail {
0048     template<class Archive> class interface_iarchive;
0049 } // namespace detail
0050 
0051 /////////////////////////////////////////////////////////////////////////
0052 // class basic_binary_iarchive - read serialized objects from a input binary stream
0053 template<class Archive>
0054 class BOOST_SYMBOL_VISIBLE basic_binary_iarchive :
0055     public detail::common_iarchive<Archive>
0056 {
0057 #ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
0058 public:
0059 #else
0060 protected:
0061     #if BOOST_WORKAROUND(BOOST_MSVC, < 1500)
0062         // for some inexplicable reason insertion of "class" generates compile erro
0063         // on msvc 7.1
0064         friend detail::interface_iarchive<Archive>;
0065     #else
0066         friend class detail::interface_iarchive<Archive>;
0067     #endif
0068 #endif
0069     // intermediate level to support override of operators
0070     // fot templates in the absence of partial function
0071     // template ordering. If we get here pass to base class
0072     // note extra nonsense to sneak it pass the borland compilers
0073     typedef detail::common_iarchive<Archive> detail_common_iarchive;
0074     template<class T>
0075     void load_override(T & t){
0076       this->detail_common_iarchive::load_override(t);
0077     }
0078 
0079     // include these to trap a change in binary format which
0080     // isn't specifically handled
0081     // upto 32K classes
0082     BOOST_STATIC_ASSERT(sizeof(class_id_type) == sizeof(int_least16_t));
0083     BOOST_STATIC_ASSERT(sizeof(class_id_reference_type) == sizeof(int_least16_t));
0084     // upto 2G objects
0085     BOOST_STATIC_ASSERT(sizeof(object_id_type) == sizeof(uint_least32_t));
0086     BOOST_STATIC_ASSERT(sizeof(object_reference_type) == sizeof(uint_least32_t));
0087 
0088     // binary files don't include the optional information
0089     void load_override(class_id_optional_type & /* t */){}
0090 
0091     void load_override(tracking_type & t, int /*version*/){
0092         boost::serialization::library_version_type lv = this->get_library_version();
0093         if(boost::serialization::library_version_type(6) < lv){
0094             int_least8_t x=0;
0095             * this->This() >> x;
0096             t = boost::archive::tracking_type(x);
0097         }
0098         else{
0099             bool x=0;
0100             * this->This() >> x;
0101             t = boost::archive::tracking_type(x);
0102         }
0103     }
0104     void load_override(class_id_type & t){
0105         boost::serialization::library_version_type lv = this->get_library_version();
0106         /*
0107          * library versions:
0108          *   boost 1.39 -> 5
0109          *   boost 1.43 -> 7
0110          *   boost 1.47 -> 9
0111          *
0112          *
0113          * 1) in boost 1.43 and inferior, class_id_type is always a 16bit value, with no check on the library version
0114          *   --> this means all archives with version v <= 7 are written with a 16bit class_id_type
0115          * 2) in boost 1.44 this load_override has disappeared (and thus boost 1.44 is not backward compatible at all !!)
0116          * 3) recent boosts reintroduced load_override with a test on the version :
0117          *     - v > 7 : this->detail_common_iarchive::load_override(t, version)
0118          *     - v > 6 : 16bit
0119          *     - other : 32bit
0120          *   --> which is obviously incorrect, see point 1
0121          *
0122          * the fix here decodes class_id_type on 16bit for all v <= 7, which seems to be the correct behaviour ...
0123          */
0124         if(boost::serialization::library_version_type (7) < lv){
0125             this->detail_common_iarchive::load_override(t);
0126         }
0127         else{
0128             int_least16_t x=0;
0129             * this->This() >> x;
0130             t = boost::archive::class_id_type(x);
0131         }
0132     }
0133     void load_override(class_id_reference_type & t){
0134         load_override(static_cast<class_id_type &>(t));
0135     }
0136 
0137     void load_override(version_type & t){
0138         boost::serialization::library_version_type  lv = this->get_library_version();
0139         if(boost::serialization::library_version_type(7) < lv){
0140             this->detail_common_iarchive::load_override(t);
0141         }
0142         else
0143         if(boost::serialization::library_version_type(6) < lv){
0144             uint_least8_t x=0;
0145             * this->This() >> x;
0146             t = boost::archive::version_type(x);
0147         }
0148         else
0149         if(boost::serialization::library_version_type(5) < lv){
0150             uint_least16_t x=0;
0151             * this->This() >> x;
0152             t = boost::archive::version_type(x);
0153         }
0154         else
0155         if(boost::serialization::library_version_type(2) < lv){
0156             // upto 255 versions
0157             unsigned char x=0;
0158             * this->This() >> x;
0159             t = version_type(x);
0160         }
0161         else{
0162             unsigned int x=0;
0163             * this->This() >> x;
0164             t = boost::archive::version_type(x);
0165         }
0166     }
0167 
0168     void load_override(boost::serialization::item_version_type & t){
0169         boost::serialization::library_version_type lv = this->get_library_version();
0170 //        if(boost::serialization::library_version_type(7) < lvt){
0171         if(boost::serialization::library_version_type(6) < lv){
0172             this->detail_common_iarchive::load_override(t);
0173         }
0174         else
0175         if(boost::serialization::library_version_type(6) < lv){
0176             uint_least16_t x=0;
0177             * this->This() >> x;
0178             t = boost::serialization::item_version_type(x);
0179         }
0180         else{
0181             unsigned int x=0;
0182             * this->This() >> x;
0183             t = boost::serialization::item_version_type(x);
0184         }
0185     }
0186 
0187     void load_override(serialization::collection_size_type & t){
0188         if(boost::serialization::library_version_type(5) < this->get_library_version()){
0189             this->detail_common_iarchive::load_override(t);
0190         }
0191         else{
0192             unsigned int x=0;
0193             * this->This() >> x;
0194             t = serialization::collection_size_type(x);
0195         }
0196     }
0197 
0198     BOOST_ARCHIVE_OR_WARCHIVE_DECL void
0199     load_override(class_name_type & t);
0200     BOOST_ARCHIVE_OR_WARCHIVE_DECL void
0201     init();
0202 
0203     basic_binary_iarchive(unsigned int flags) :
0204         detail::common_iarchive<Archive>(flags)
0205     {}
0206 };
0207 
0208 } // namespace archive
0209 } // namespace boost
0210 
0211 #ifdef BOOST_MSVC
0212 #pragma warning(pop)
0213 #endif
0214 
0215 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
0216 
0217 #endif // BOOST_ARCHIVE_BASIC_BINARY_IARCHIVE_HPP