Chris@16: #ifndef BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP Chris@16: #define BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP Chris@16: Chris@16: // MS compatible compilers support #pragma once Chris@101: #if defined(_MSC_VER) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 Chris@16: // basic_xml_grammar.hpp Chris@16: Chris@16: // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . Chris@16: // Use, modification and distribution is subject to the Boost Software Chris@16: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // See http://www.boost.org for updates, documentation, and revision history. Chris@16: Chris@16: // this module is derived from simplexml.cpp - an example shipped as part of Chris@16: // the spirit parser. This example contains the following notice: Chris@16: /*============================================================================= Chris@16: simplexml.cpp Chris@16: Chris@16: Spirit V1.3 Chris@16: URL: http://spirit.sourceforge.net/ Chris@16: Chris@16: Copyright (c) 2001, Daniel C. Nuffer Chris@16: Chris@16: This software is provided 'as-is', without any express or implied Chris@16: warranty. In no event will the copyright holder be held liable for Chris@16: any damages arising from the use of this software. Chris@16: Chris@16: Permission is granted to anyone to use this software for any purpose, Chris@16: including commercial applications, and to alter it and redistribute Chris@16: it freely, subject to the following restrictions: Chris@16: Chris@16: 1. The origin of this software must not be misrepresented; you must Chris@16: not claim that you wrote the original software. If you use this Chris@16: software in a product, an acknowledgment in the product documentation Chris@16: would be appreciated but is not required. Chris@16: Chris@16: 2. Altered source versions must be plainly marked as such, and must Chris@16: not be misrepresented as being the original software. Chris@16: Chris@16: 3. This notice may not be removed or altered from any source Chris@16: distribution. Chris@16: =============================================================================*/ Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace archive { Chris@16: Chris@16: /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 Chris@16: // XML grammar parsing Chris@16: Chris@16: template Chris@16: class basic_xml_grammar { Chris@16: public: Chris@16: // The following is not necessary according to DR45, but at least Chris@16: // one compiler (Compaq C++ 6.5 in strict_ansi mode) chokes otherwise. Chris@16: struct return_values; Chris@16: friend struct return_values; Chris@16: Chris@16: private: Chris@16: typedef BOOST_DEDUCED_TYPENAME std::basic_istream IStream; Chris@16: typedef BOOST_DEDUCED_TYPENAME std::basic_string StringType; Chris@16: typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::chset chset_t; Chris@16: typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::chlit chlit_t; Chris@16: typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::scanner< Chris@16: BOOST_DEDUCED_TYPENAME std::basic_string::iterator Chris@16: > scanner_t; Chris@16: typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::rule rule_t; Chris@16: // Start grammar definition Chris@16: rule_t Chris@16: Reference, Chris@16: Eq, Chris@16: STag, Chris@16: ETag, Chris@16: LetterOrUnderscoreOrColon, Chris@16: AttValue, Chris@16: CharRef1, Chris@16: CharRef2, Chris@16: CharRef, Chris@16: AmpRef, Chris@16: LTRef, Chris@16: GTRef, Chris@16: AposRef, Chris@16: QuoteRef, Chris@16: CharData, Chris@16: CharDataChars, Chris@16: content, Chris@16: AmpName, Chris@16: LTName, Chris@16: GTName, Chris@16: ClassNameChar, Chris@16: ClassName, Chris@16: Name, Chris@16: XMLDecl, Chris@16: XMLDeclChars, Chris@16: DocTypeDecl, Chris@16: DocTypeDeclChars, Chris@16: ClassIDAttribute, Chris@16: ObjectIDAttribute, Chris@16: ClassNameAttribute, Chris@16: TrackingAttribute, Chris@16: VersionAttribute, Chris@16: UnusedAttribute, Chris@16: Attribute, Chris@16: SignatureAttribute, Chris@16: SerializationWrapper, Chris@16: NameHead, Chris@16: NameTail, Chris@16: AttributeList, Chris@16: S; Chris@16: Chris@16: // XML Character classes Chris@16: chset_t Chris@16: BaseChar, Chris@16: Ideographic, Chris@16: Char, Chris@16: Letter, Chris@16: Digit, Chris@16: CombiningChar, Chris@16: Extender, Chris@16: Sch, Chris@16: NameChar; Chris@16: Chris@16: void init_chset(); Chris@16: Chris@16: bool my_parse( Chris@16: IStream & is, Chris@16: const rule_t &rule_, Chris@16: const CharType delimiter = L'>' Chris@16: ) const ; Chris@16: public: Chris@16: struct return_values { Chris@16: StringType object_name; Chris@16: StringType contents; Chris@16: //class_id_type class_id; Chris@16: int_least16_t class_id; Chris@16: //object_id_type object_id; Chris@16: uint_least32_t object_id; Chris@16: //version_type version; Chris@16: unsigned int version; Chris@16: tracking_type tracking_level; Chris@16: StringType class_name; Chris@16: return_values() : Chris@16: version(0), Chris@16: tracking_level(false) Chris@16: {} Chris@16: } rv; Chris@16: bool parse_start_tag(IStream & is) /*const*/; Chris@16: bool parse_end_tag(IStream & is) const; Chris@16: bool parse_string(IStream & is, StringType & s) /*const*/; Chris@16: void init(IStream & is); Chris@16: void windup(IStream & is); Chris@16: basic_xml_grammar(); Chris@16: }; Chris@16: Chris@16: } // namespace archive Chris@16: } // namespace boost Chris@16: Chris@16: #endif // BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP