]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/include/boost/archive/impl/basic_text_iarchive.ipp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / serialization / include / boost / archive / impl / basic_text_iarchive.ipp
1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2 // basic_text_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 <algorithm>
12 #include <cstring>
13
14 #include <boost/config.hpp>
15 #if defined(BOOST_NO_STDC_NAMESPACE)
16 namespace std{
17 using ::memcpy;
18 }
19 #endif
20
21 #include <boost/detail/workaround.hpp>
22 #include <boost/serialization/string.hpp>
23 #include <boost/archive/basic_text_iarchive.hpp>
24
25 namespace boost {
26 namespace archive {
27
28 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
29 // implementation of text_text_archive
30
31 template<class Archive>
32 BOOST_ARCHIVE_OR_WARCHIVE_DECL void
33 basic_text_iarchive<Archive>::load_override(class_name_type & t){
34 std::string cn;
35 cn.reserve(BOOST_SERIALIZATION_MAX_KEY_SIZE);
36 load_override(cn);
37 if(cn.size() > (BOOST_SERIALIZATION_MAX_KEY_SIZE - 1))
38 boost::serialization::throw_exception(
39 archive_exception(archive_exception::invalid_class_name)
40 );
41 std::memcpy(t, cn.data(), cn.size());
42 // borland tweak
43 t.t[cn.size()] = '\0';
44 }
45
46 template<class Archive>
47 BOOST_ARCHIVE_OR_WARCHIVE_DECL void
48 basic_text_iarchive<Archive>::init(void){
49 // read signature in an archive version independent manner
50 std::string file_signature;
51 * this->This() >> file_signature;
52 if(file_signature != BOOST_ARCHIVE_SIGNATURE())
53 boost::serialization::throw_exception(
54 archive_exception(archive_exception::invalid_signature)
55 );
56
57 // make sure the version of the reading archive library can
58 // support the format of the archive being read
59 library_version_type input_library_version;
60 * this->This() >> input_library_version;
61
62 #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
63 this->set_library_version(input_library_version);
64 #else
65 detail::basic_iarchive::set_library_version(input_library_version);
66 #endif
67
68 // extra little .t is to get around borland quirk
69 if(BOOST_ARCHIVE_VERSION() < input_library_version)
70 boost::serialization::throw_exception(
71 archive_exception(archive_exception::unsupported_version)
72 );
73 }
74
75 } // namespace archive
76 } // namespace boost