Chris@16
|
1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
Chris@16
|
2 // basic_xml_iarchive.ipp:
|
Chris@16
|
3
|
Chris@16
|
4 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
Chris@16
|
5 // Use, modification and distribution is subject to the Boost Software
|
Chris@16
|
6 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8
|
Chris@16
|
9 // See http://www.boost.org for updates, documentation, and revision history.
|
Chris@16
|
10
|
Chris@16
|
11 #include <boost/assert.hpp>
|
Chris@16
|
12 #include <cstddef> // NULL
|
Chris@16
|
13 #include <algorithm>
|
Chris@16
|
14
|
Chris@16
|
15 #include <boost/serialization/throw_exception.hpp>
|
Chris@16
|
16 #include <boost/archive/xml_archive_exception.hpp>
|
Chris@16
|
17 #include <boost/archive/basic_xml_iarchive.hpp>
|
Chris@16
|
18 #include <boost/serialization/tracking.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 namespace boost {
|
Chris@16
|
21 namespace archive {
|
Chris@16
|
22
|
Chris@16
|
23 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
Chris@16
|
24 // implementation of xml_text_archive
|
Chris@16
|
25
|
Chris@16
|
26 template<class Archive>
|
Chris@16
|
27 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
28 basic_xml_iarchive<Archive>::load_start(const char *name){
|
Chris@16
|
29 // if there's no name
|
Chris@16
|
30 if(NULL == name)
|
Chris@16
|
31 return;
|
Chris@16
|
32 bool result = this->This()->gimpl->parse_start_tag(this->This()->get_is());
|
Chris@16
|
33 if(true != result){
|
Chris@16
|
34 boost::serialization::throw_exception(
|
Chris@16
|
35 archive_exception(archive_exception::input_stream_error)
|
Chris@16
|
36 );
|
Chris@16
|
37 }
|
Chris@16
|
38 // don't check start tag at highest level
|
Chris@16
|
39 ++depth;
|
Chris@16
|
40 return;
|
Chris@16
|
41 }
|
Chris@16
|
42
|
Chris@16
|
43 template<class Archive>
|
Chris@16
|
44 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
45 basic_xml_iarchive<Archive>::load_end(const char *name){
|
Chris@16
|
46 // if there's no name
|
Chris@16
|
47 if(NULL == name)
|
Chris@16
|
48 return;
|
Chris@16
|
49 bool result = this->This()->gimpl->parse_end_tag(this->This()->get_is());
|
Chris@16
|
50 if(true != result){
|
Chris@16
|
51 boost::serialization::throw_exception(
|
Chris@16
|
52 archive_exception(archive_exception::input_stream_error)
|
Chris@16
|
53 );
|
Chris@16
|
54 }
|
Chris@16
|
55
|
Chris@16
|
56 // don't check start tag at highest level
|
Chris@16
|
57 if(0 == --depth)
|
Chris@16
|
58 return;
|
Chris@16
|
59
|
Chris@16
|
60 if(0 == (this->get_flags() & no_xml_tag_checking)){
|
Chris@16
|
61 // double check that the tag matches what is expected - useful for debug
|
Chris@16
|
62 if(0 != name[this->This()->gimpl->rv.object_name.size()]
|
Chris@16
|
63 || ! std::equal(
|
Chris@16
|
64 this->This()->gimpl->rv.object_name.begin(),
|
Chris@16
|
65 this->This()->gimpl->rv.object_name.end(),
|
Chris@16
|
66 name
|
Chris@16
|
67 )
|
Chris@16
|
68 ){
|
Chris@16
|
69 boost::serialization::throw_exception(
|
Chris@16
|
70 xml_archive_exception(
|
Chris@16
|
71 xml_archive_exception::xml_archive_tag_mismatch,
|
Chris@16
|
72 name
|
Chris@16
|
73 )
|
Chris@16
|
74 );
|
Chris@16
|
75 }
|
Chris@16
|
76 }
|
Chris@16
|
77 }
|
Chris@16
|
78
|
Chris@16
|
79 template<class Archive>
|
Chris@16
|
80 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
81 basic_xml_iarchive<Archive>::load_override(object_id_type & t, int){
|
Chris@16
|
82 t = object_id_type(this->This()->gimpl->rv.object_id);
|
Chris@16
|
83 }
|
Chris@16
|
84
|
Chris@16
|
85 template<class Archive>
|
Chris@16
|
86 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
87 basic_xml_iarchive<Archive>::load_override(version_type & t, int){
|
Chris@16
|
88 t = version_type(this->This()->gimpl->rv.version);
|
Chris@16
|
89 }
|
Chris@16
|
90
|
Chris@16
|
91 template<class Archive>
|
Chris@16
|
92 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
93 basic_xml_iarchive<Archive>::load_override(class_id_type & t, int){
|
Chris@16
|
94 t = class_id_type(this->This()->gimpl->rv.class_id);
|
Chris@16
|
95 }
|
Chris@16
|
96
|
Chris@16
|
97 template<class Archive>
|
Chris@16
|
98 BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
|
Chris@16
|
99 basic_xml_iarchive<Archive>::load_override(tracking_type & t, int){
|
Chris@16
|
100 t = this->This()->gimpl->rv.tracking_level;
|
Chris@16
|
101 }
|
Chris@16
|
102
|
Chris@16
|
103 template<class Archive>
|
Chris@16
|
104 BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
Chris@16
|
105 basic_xml_iarchive<Archive>::basic_xml_iarchive(unsigned int flags) :
|
Chris@16
|
106 detail::common_iarchive<Archive>(flags),
|
Chris@16
|
107 depth(0)
|
Chris@16
|
108 {}
|
Chris@16
|
109 template<class Archive>
|
Chris@16
|
110 BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
|
Chris@16
|
111 basic_xml_iarchive<Archive>::~basic_xml_iarchive(){}
|
Chris@16
|
112
|
Chris@16
|
113 } // namespace archive
|
Chris@16
|
114 } // namespace boost
|