source: NonGTP/Boost/boost/archive/impl/basic_xml_iarchive.ipp @ 857

Revision 857, 3.4 KB checked in by igarcia, 19 years ago (diff)
Line 
1/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2// basic_xml_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
11#include <cassert>
12#include <algorithm>
13
14#include <boost/throw_exception.hpp>
15
16#include <boost/archive/basic_xml_iarchive.hpp>
17#include <boost/serialization/tracking.hpp>
18//#include <boost/serialization/extended_type_info.hpp>
19
20namespace boost {
21namespace archive {
22
23/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
24// implementation of xml_text_archive
25
26template<class Archive>
27BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
28basic_xml_iarchive<Archive>::load_start(const char *name){
29    // if there's no name
30    if(NULL == name)
31        return;
32    bool result = this->This()->gimpl->parse_start_tag(this->This()->get_is());
33    if(true != result){
34        boost::throw_exception(
35            archive_exception(archive_exception::stream_error)
36        );
37    }
38    // don't check start tag at highest level
39    ++depth;
40    return;
41}
42
43template<class Archive>
44BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
45basic_xml_iarchive<Archive>::load_end(const char *name){
46    // if there's no name
47    if(NULL == name)
48        return;
49    bool result = this->This()->gimpl->parse_end_tag(this->This()->get_is());
50    if(true != result){
51        boost::throw_exception(
52            archive_exception(archive_exception::stream_error)
53        );
54    }
55   
56    // don't check start tag at highest level
57    if(0 == --depth)
58        return;
59       
60    if(0 != (this->get_flags() & no_xml_tag_checking)){
61        // double check that the tag matches what is expected - useful for debug
62        if(0 != name[this->This()->gimpl->rv.object_name.size()]
63        || ! std::equal(
64                this->This()->gimpl->rv.object_name.begin(),
65                this->This()->gimpl->rv.object_name.end(),
66                name
67            )
68        ){
69            boost::throw_exception(
70                archive_exception(archive_exception::stream_error)
71            );
72        }
73    }
74}
75
76template<class Archive>
77BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
78basic_xml_iarchive<Archive>::load_override(object_id_type & t, int){
79    t = this->This()->gimpl->rv.object_id;
80}
81
82template<class Archive>
83BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
84basic_xml_iarchive<Archive>::load_override(version_type & t, int){
85    t = this->This()->gimpl->rv.version;
86}
87
88template<class Archive>
89BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
90basic_xml_iarchive<Archive>::load_override(class_id_type & t, int){
91    t = this->This()->gimpl->rv.class_id;
92}
93
94template<class Archive>
95BOOST_ARCHIVE_OR_WARCHIVE_DECL(void)
96basic_xml_iarchive<Archive>::load_override(tracking_type & t, int){
97    t = this->This()->gimpl->rv.tracking_level;
98}
99
100template<class Archive>
101BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
102basic_xml_iarchive<Archive>::basic_xml_iarchive(unsigned int flags) :
103    detail::common_iarchive<Archive>(flags),
104    depth(0)
105{}
106template<class Archive>
107BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
108basic_xml_iarchive<Archive>::~basic_xml_iarchive(){}
109
110} // namespace archive
111} // namespace boost
Note: See TracBrowser for help on using the repository browser.