Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / archive / impl / basic_xml_grammar.hpp @ 2486

History | View | Annotate | Download (5 kB)

1 2486 sjacqu01
#ifndef BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP
2 2486 sjacqu01
#define BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP
3 2486 sjacqu01
4 2486 sjacqu01
// MS compatible compilers support #pragma once
5 2486 sjacqu01
#if defined(_MSC_VER)
6 2486 sjacqu01
# pragma once
7 2486 sjacqu01
#endif
8 2486 sjacqu01
9 2486 sjacqu01
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 2486 sjacqu01
// basic_xml_grammar.hpp
11 2486 sjacqu01
12 2486 sjacqu01
// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13 2486 sjacqu01
// Use, modification and distribution is subject to the Boost Software
14 2486 sjacqu01
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 2486 sjacqu01
// http://www.boost.org/LICENSE_1_0.txt)
16 2486 sjacqu01
17 2486 sjacqu01
//  See http://www.boost.org for updates, documentation, and revision history.
18 2486 sjacqu01
19 2486 sjacqu01
// this module is derived from simplexml.cpp - an example shipped as part of
20 2486 sjacqu01
// the spirit parser.  This example contains the following notice:
21 2486 sjacqu01
/*=============================================================================
22 2486 sjacqu01
    simplexml.cpp
23 2486 sjacqu01

24 2486 sjacqu01
    Spirit V1.3
25 2486 sjacqu01
    URL: http://spirit.sourceforge.net/
26 2486 sjacqu01

27 2486 sjacqu01
    Copyright (c) 2001, Daniel C. Nuffer
28 2486 sjacqu01

29 2486 sjacqu01
    This software is provided 'as-is', without any express or implied
30 2486 sjacqu01
    warranty. In no event will the copyright holder be held liable for
31 2486 sjacqu01
    any damages arising from the use of this software.
32 2486 sjacqu01

33 2486 sjacqu01
    Permission is granted to anyone to use this software for any purpose,
34 2486 sjacqu01
    including commercial applications, and to alter it and redistribute
35 2486 sjacqu01
    it freely, subject to the following restrictions:
36 2486 sjacqu01

37 2486 sjacqu01
    1.  The origin of this software must not be misrepresented; you must
38 2486 sjacqu01
        not claim that you wrote the original software. If you use this
39 2486 sjacqu01
        software in a product, an acknowledgment in the product documentation
40 2486 sjacqu01
        would be appreciated but is not required.
41 2486 sjacqu01

42 2486 sjacqu01
    2.  Altered source versions must be plainly marked as such, and must
43 2486 sjacqu01
        not be misrepresented as being the original software.
44 2486 sjacqu01

45 2486 sjacqu01
    3.  This notice may not be removed or altered from any source
46 2486 sjacqu01
        distribution.
47 2486 sjacqu01
=============================================================================*/
48 2486 sjacqu01
#include <string>
49 2486 sjacqu01
50 2486 sjacqu01
#include <boost/config.hpp>
51 2486 sjacqu01
#include <boost/detail/workaround.hpp>
52 2486 sjacqu01
53 2486 sjacqu01
#include <boost/spirit/include/classic_rule.hpp>
54 2486 sjacqu01
#include <boost/spirit/include/classic_chset.hpp>
55 2486 sjacqu01
56 2486 sjacqu01
#include <boost/archive/basic_archive.hpp>
57 2486 sjacqu01
#include <boost/serialization/tracking.hpp>
58 2486 sjacqu01
#include <boost/serialization/version.hpp>
59 2486 sjacqu01
60 2486 sjacqu01
namespace boost {
61 2486 sjacqu01
namespace archive {
62 2486 sjacqu01
63 2486 sjacqu01
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
64 2486 sjacqu01
// XML grammar parsing
65 2486 sjacqu01
66 2486 sjacqu01
template<class CharType>
67 2486 sjacqu01
class basic_xml_grammar {
68 2486 sjacqu01
public:
69 2486 sjacqu01
    // The following is not necessary according to DR45, but at least
70 2486 sjacqu01
    // one compiler (Compaq C++ 6.5 in strict_ansi mode) chokes otherwise.
71 2486 sjacqu01
    struct return_values;
72 2486 sjacqu01
    friend struct return_values;
73 2486 sjacqu01
74 2486 sjacqu01
private:
75 2486 sjacqu01
    typedef typename std::basic_istream<CharType> IStream;
76 2486 sjacqu01
    typedef typename std::basic_string<CharType> StringType;
77 2486 sjacqu01
    typedef typename boost::spirit::classic::chset<CharType> chset_t;
78 2486 sjacqu01
    typedef typename boost::spirit::classic::chlit<CharType> chlit_t;
79 2486 sjacqu01
    typedef typename boost::spirit::classic::scanner<
80 2486 sjacqu01
        typename  std::basic_string<CharType>::iterator
81 2486 sjacqu01
    > scanner_t;
82 2486 sjacqu01
    typedef typename boost::spirit::classic::rule<scanner_t> rule_t;
83 2486 sjacqu01
    // Start grammar definition
84 2486 sjacqu01
    rule_t
85 2486 sjacqu01
        Reference,
86 2486 sjacqu01
        Eq,
87 2486 sjacqu01
        STag,
88 2486 sjacqu01
        ETag,
89 2486 sjacqu01
        LetterOrUnderscoreOrColon,
90 2486 sjacqu01
        AttValue,
91 2486 sjacqu01
        CharRef1,
92 2486 sjacqu01
        CharRef2,
93 2486 sjacqu01
        CharRef,
94 2486 sjacqu01
        AmpRef,
95 2486 sjacqu01
        LTRef,
96 2486 sjacqu01
        GTRef,
97 2486 sjacqu01
        AposRef,
98 2486 sjacqu01
        QuoteRef,
99 2486 sjacqu01
        CharData,
100 2486 sjacqu01
        CharDataChars,
101 2486 sjacqu01
        content,
102 2486 sjacqu01
        AmpName,
103 2486 sjacqu01
        LTName,
104 2486 sjacqu01
        GTName,
105 2486 sjacqu01
        ClassNameChar,
106 2486 sjacqu01
        ClassName,
107 2486 sjacqu01
        Name,
108 2486 sjacqu01
        XMLDecl,
109 2486 sjacqu01
        XMLDeclChars,
110 2486 sjacqu01
        DocTypeDecl,
111 2486 sjacqu01
        DocTypeDeclChars,
112 2486 sjacqu01
        ClassIDAttribute,
113 2486 sjacqu01
        ObjectIDAttribute,
114 2486 sjacqu01
        ClassNameAttribute,
115 2486 sjacqu01
        TrackingAttribute,
116 2486 sjacqu01
        VersionAttribute,
117 2486 sjacqu01
        UnusedAttribute,
118 2486 sjacqu01
        Attribute,
119 2486 sjacqu01
        SignatureAttribute,
120 2486 sjacqu01
        SerializationWrapper,
121 2486 sjacqu01
        NameHead,
122 2486 sjacqu01
        NameTail,
123 2486 sjacqu01
        AttributeList,
124 2486 sjacqu01
        S;
125 2486 sjacqu01
126 2486 sjacqu01
    // XML Character classes
127 2486 sjacqu01
    chset_t
128 2486 sjacqu01
        BaseChar,
129 2486 sjacqu01
        Ideographic,
130 2486 sjacqu01
        Char,
131 2486 sjacqu01
        Letter,
132 2486 sjacqu01
        Digit,
133 2486 sjacqu01
        CombiningChar,
134 2486 sjacqu01
        Extender,
135 2486 sjacqu01
        Sch,
136 2486 sjacqu01
        NameChar;
137 2486 sjacqu01
138 2486 sjacqu01
    void init_chset();
139 2486 sjacqu01
140 2486 sjacqu01
    bool my_parse(
141 2486 sjacqu01
        IStream & is,
142 2486 sjacqu01
        const rule_t &rule_,
143 2486 sjacqu01
        const CharType delimiter = L'>'
144 2486 sjacqu01
    ) const ;
145 2486 sjacqu01
public:
146 2486 sjacqu01
    struct return_values {
147 2486 sjacqu01
        StringType object_name;
148 2486 sjacqu01
        StringType contents;
149 2486 sjacqu01
        //class_id_type class_id;
150 2486 sjacqu01
        int_least16_t class_id;
151 2486 sjacqu01
        //object_id_type object_id;
152 2486 sjacqu01
        uint_least32_t object_id;
153 2486 sjacqu01
        //version_type version;
154 2486 sjacqu01
        unsigned int version;
155 2486 sjacqu01
        tracking_type tracking_level;
156 2486 sjacqu01
        StringType class_name;
157 2486 sjacqu01
        return_values() :
158 2486 sjacqu01
            version(0),
159 2486 sjacqu01
            tracking_level(false)
160 2486 sjacqu01
        {}
161 2486 sjacqu01
    } rv;
162 2486 sjacqu01
    bool parse_start_tag(IStream & is) /*const*/;
163 2486 sjacqu01
    bool parse_end_tag(IStream & is) const;
164 2486 sjacqu01
    bool parse_string(IStream & is, StringType & s) /*const*/;
165 2486 sjacqu01
    void init(IStream & is);
166 2486 sjacqu01
    void windup(IStream & is);
167 2486 sjacqu01
    basic_xml_grammar();
168 2486 sjacqu01
};
169 2486 sjacqu01
170 2486 sjacqu01
} // namespace archive
171 2486 sjacqu01
} // namespace boost
172 2486 sjacqu01
173 2486 sjacqu01
#endif // BOOST_ARCHIVE_BASIC_XML_GRAMMAR_HPP