[857] | 1 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
---|
| 2 | // basic_binary_iarchive.ipp:
|
---|
| 3 |
|
---|
| 4 | // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
---|
| 5 | // Use, modification and distribution is subject to the Boost Software
|
---|
| 6 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
| 7 | // http://www.boost.org/LICENSE_1_0.txt)
|
---|
| 8 |
|
---|
| 9 | // See http://www.boost.org for updates, documentation, and revision history.
|
---|
| 10 | #include <string>
|
---|
| 11 | #include <cassert>
|
---|
| 12 | #include <algorithm>
|
---|
| 13 | #include <cstring>
|
---|
| 14 |
|
---|
| 15 | #include <boost/config.hpp> // for BOOST_DEDUCED_TYPENAME
|
---|
| 16 | #if defined(BOOST_NO_STDC_NAMESPACE)
|
---|
| 17 | namespace std{
|
---|
| 18 | using ::memcpy;
|
---|
| 19 | }
|
---|
| 20 | #endif
|
---|
| 21 |
|
---|
| 22 | #include <boost/detail/workaround.hpp>
|
---|
| 23 |
|
---|
| 24 | #include <boost/archive/basic_binary_iarchive.hpp>
|
---|
| 25 | //#include <boost/serialization/extended_type_info.hpp>
|
---|
| 26 |
|
---|
| 27 | namespace boost {
|
---|
| 28 | namespace archive {
|
---|
| 29 |
|
---|
| 30 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
---|
| 31 | // implementation of binary_binary_archive
|
---|
| 32 | template<class Archive>
|
---|
| 33 | BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
---|
| 34 | basic_binary_iarchive<Archive>::load_override(class_name_type & t, int){
|
---|
| 35 | std::string cn;
|
---|
| 36 | cn.reserve(BOOST_SERIALIZATION_MAX_KEY_SIZE);
|
---|
| 37 | load_override(cn, 0);
|
---|
| 38 | if(cn.size() > (BOOST_SERIALIZATION_MAX_KEY_SIZE - 1))
|
---|
| 39 | boost::throw_exception(
|
---|
| 40 | archive_exception(archive_exception::invalid_class_name)
|
---|
| 41 | );
|
---|
| 42 | std::memcpy(t, cn.data(), cn.size());
|
---|
| 43 | // borland tweak
|
---|
| 44 | t.t[cn.size()] = '\0';
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | template<class Archive>
|
---|
| 48 | BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
---|
| 49 | basic_binary_iarchive<Archive>::init(){
|
---|
| 50 | // read signature in an archive version independent manner
|
---|
| 51 | std::string file_signature;
|
---|
| 52 | * this->This() >> file_signature;
|
---|
| 53 | if(file_signature != ARCHIVE_SIGNATURE())
|
---|
| 54 | boost::throw_exception(
|
---|
| 55 | archive_exception(archive_exception::invalid_signature)
|
---|
| 56 | );
|
---|
| 57 |
|
---|
| 58 | // make sure the version of the reading archive library can
|
---|
| 59 | // support the format of the archive being read
|
---|
| 60 | version_type input_library_version;
|
---|
| 61 | * this->This() >> input_library_version;
|
---|
| 62 |
|
---|
| 63 | #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
|
---|
| 64 | this->set_library_version(input_library_version);
|
---|
| 65 | #else
|
---|
| 66 | #if ! BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
|
---|
| 67 | detail::
|
---|
| 68 | #endif
|
---|
| 69 | basic_iarchive::set_library_version(input_library_version);
|
---|
| 70 | #endif
|
---|
| 71 |
|
---|
| 72 | // extra little .t is to get around borland quirk
|
---|
| 73 | if(ARCHIVE_VERSION() < input_library_version.t)
|
---|
| 74 | boost::throw_exception(
|
---|
| 75 | archive_exception(archive_exception::unsupported_version)
|
---|
| 76 | );
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | } // namespace archive
|
---|
| 80 | } // namespace boost
|
---|