Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:28

0001 #ifndef BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP
0002 #define BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP
0003 
0004 // MS compatible compilers support #pragma once
0005 #if defined(_MSC_VER)
0006 # pragma once
0007 #endif
0008 
0009 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0010 // basic_xml_grammar.hpp
0011 
0012 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
0013 // Use, modification and distribution is subject to the Boost Software
0014 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0015 // http://www.boost.org/LICENSE_1_0.txt)
0016 
0017 //  See http://www.boost.org for updates, documentation, and revision history.
0018 
0019 // this module is derived from simplexml.cpp - an example shipped as part of
0020 // the spirit parser.  This example contains the following notice:
0021 /*=============================================================================
0022     simplexml.cpp
0023 
0024     Spirit V1.3
0025     URL: http://spirit.sourceforge.net/
0026 
0027     Copyright (c) 2001, Daniel C. Nuffer
0028 
0029     This software is provided 'as-is', without any express or implied
0030     warranty. In no event will the copyright holder be held liable for
0031     any damages arising from the use of this software.
0032 
0033     Permission is granted to anyone to use this software for any purpose,
0034     including commercial applications, and to alter it and redistribute
0035     it freely, subject to the following restrictions:
0036 
0037     1.  The origin of this software must not be misrepresented; you must
0038         not claim that you wrote the original software. If you use this
0039         software in a product, an acknowledgment in the product documentation
0040         would be appreciated but is not required.
0041 
0042     2.  Altered source versions must be plainly marked as such, and must
0043         not be misrepresented as being the original software.
0044 
0045     3.  This notice may not be removed or altered from any source
0046         distribution.
0047 =============================================================================*/
0048 #include <string>
0049 
0050 #include <boost/config.hpp>
0051 #include <boost/detail/workaround.hpp>
0052 
0053 #include <boost/spirit/include/classic_rule.hpp>
0054 #include <boost/spirit/include/classic_chset.hpp>
0055 
0056 #include <boost/archive/basic_archive.hpp>
0057 #include <boost/serialization/tracking.hpp>
0058 #include <boost/serialization/version.hpp>
0059 
0060 namespace boost {
0061 namespace archive {
0062 
0063 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
0064 // XML grammar parsing
0065 
0066 template<class CharType>
0067 class BOOST_SYMBOL_VISIBLE basic_xml_grammar {
0068 public:
0069     // The following is not necessary according to DR45, but at least
0070     // one compiler (Compaq C++ 6.5 in strict_ansi mode) chokes otherwise.
0071     struct return_values;
0072     friend struct return_values;
0073 
0074 private:
0075     typedef typename std::basic_istream<CharType> IStream;
0076     typedef typename std::basic_string<CharType> StringType;
0077     typedef typename boost::spirit::classic::chset<CharType> chset_t;
0078     typedef typename boost::spirit::classic::chlit<CharType> chlit_t;
0079     typedef typename boost::spirit::classic::scanner<
0080         typename  std::basic_string<CharType>::iterator
0081     > scanner_t;
0082     typedef typename boost::spirit::classic::rule<scanner_t> rule_t;
0083     // Start grammar definition
0084     rule_t
0085         Reference,
0086         Eq,
0087         STag,
0088         ETag,
0089         LetterOrUnderscoreOrColon,
0090         AttValue,
0091         CharRef1,
0092         CharRef2,
0093         CharRef,
0094         AmpRef,
0095         LTRef,
0096         GTRef,
0097         AposRef,
0098         QuoteRef,
0099         CharData,
0100         CharDataChars,
0101         content,
0102         AmpName,
0103         LTName,
0104         GTName,
0105         ClassNameChar,
0106         ClassName,
0107         Name,
0108         XMLDecl,
0109         XMLDeclChars,
0110         DocTypeDecl,
0111         DocTypeDeclChars,
0112         ClassIDAttribute,
0113         ObjectIDAttribute,
0114         ClassNameAttribute,
0115         TrackingAttribute,
0116         VersionAttribute,
0117         UnusedAttribute,
0118         Attribute,
0119         SignatureAttribute,
0120         SerializationWrapper,
0121         NameHead,
0122         NameTail,
0123         AttributeList,
0124         S;
0125 
0126     // XML Character classes
0127     chset_t
0128         BaseChar,
0129         Ideographic,
0130         Char,
0131         Letter,
0132         Digit,
0133         CombiningChar,
0134         Extender,
0135         Sch,
0136         NameChar;
0137 
0138     void init_chset();
0139 
0140     bool my_parse(
0141         IStream & is,
0142         const rule_t &rule_,
0143         const CharType delimiter = L'>'
0144     ) const ;
0145 public:
0146     struct return_values {
0147         StringType object_name;
0148         StringType contents;
0149         //class_id_type class_id;
0150         int_least16_t class_id;
0151         //object_id_type object_id;
0152         uint_least32_t object_id;
0153         //version_type version;
0154         unsigned int version;
0155         tracking_type tracking_level;
0156         StringType class_name;
0157         return_values() :
0158             version(0),
0159             tracking_level(false)
0160         {}
0161     } rv;
0162     bool parse_start_tag(IStream & is) /*const*/;
0163     bool parse_end_tag(IStream & is) const;
0164     bool parse_string(IStream & is, StringType & s) /*const*/;
0165     void init(IStream & is);
0166     bool windup(IStream & is);
0167     basic_xml_grammar();
0168 };
0169 
0170 } // namespace archive
0171 } // namespace boost
0172 
0173 #endif // BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP