1 #ifndef BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP
2 #define BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP
4 // MS compatible compilers support #pragma once
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // basic_xml_grammar.hpp
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13 // Use, modification and distribution is subject to the Boost Software
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
17 // See http://www.boost.org for updates, documentation, and revision history.
19 // this module is derived from simplexml.cpp - an example shipped as part of
20 // the spirit parser. This example contains the following notice:
21 /*=============================================================================
25 URL: http://spirit.sourceforge.net/
27 Copyright (c) 2001, Daniel C. Nuffer
29 This software is provided 'as-is', without any express or implied
30 warranty. In no event will the copyright holder be held liable for
31 any damages arising from the use of this software.
33 Permission is granted to anyone to use this software for any purpose,
34 including commercial applications, and to alter it and redistribute
35 it freely, subject to the following restrictions:
37 1. The origin of this software must not be misrepresented; you must
38 not claim that you wrote the original software. If you use this
39 software in a product, an acknowledgment in the product documentation
40 would be appreciated but is not required.
42 2. Altered source versions must be plainly marked as such, and must
43 not be misrepresented as being the original software.
45 3. This notice may not be removed or altered from any source
47 =============================================================================*/
50 #include <boost/config.hpp>
51 #include <boost/detail/workaround.hpp>
53 #include <boost/spirit/include/classic_rule.hpp>
54 #include <boost/spirit/include/classic_chset.hpp>
56 #include <boost/archive/basic_archive.hpp>
57 #include <boost/serialization/tracking.hpp>
58 #include <boost/serialization/version.hpp>
63 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
64 // XML grammar parsing
66 template<class CharType>
67 class basic_xml_grammar {
69 // The following is not necessary according to DR45, but at least
70 // one compiler (Compaq C++ 6.5 in strict_ansi mode) chokes otherwise.
72 friend struct return_values;
75 typedef typename std::basic_istream<CharType> IStream;
76 typedef typename std::basic_string<CharType> StringType;
77 typedef typename boost::spirit::classic::chset<CharType> chset_t;
78 typedef typename boost::spirit::classic::chlit<CharType> chlit_t;
79 typedef typename boost::spirit::classic::scanner<
80 typename std::basic_string<CharType>::iterator
82 typedef typename boost::spirit::classic::rule<scanner_t> rule_t;
83 // Start grammar definition
89 LetterOrUnderscoreOrColon,
120 SerializationWrapper,
126 // XML Character classes
143 const CharType delimiter = L'>'
146 struct return_values {
147 StringType object_name;
149 //class_id_type class_id;
150 int_least16_t class_id;
151 //object_id_type object_id;
152 uint_least32_t object_id;
153 //version_type version;
154 unsigned int version;
155 tracking_type tracking_level;
156 StringType class_name;
159 tracking_level(false)
162 bool parse_start_tag(IStream & is) /*const*/;
163 bool parse_end_tag(IStream & is) const;
164 bool parse_string(IStream & is, StringType & s) /*const*/;
165 void init(IStream & is);
166 bool windup(IStream & is);
170 } // namespace archive
173 #endif // BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP