source: NonGTP/Xerces/xerces/include/xercesc/validators/common/Grammar.hpp @ 358

Revision 358, 8.1 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 2001,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * $Log: Grammar.hpp,v $
19 * Revision 1.11  2004/09/08 13:56:51  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.10  2004/01/29 11:51:21  cargilld
23 * Code cleanup changes to get rid of various compiler diagnostic messages.
24 *
25 * Revision 1.9  2003/10/29 16:19:47  peiyongz
26 * storeGrammar()/loadGrammar added
27 *
28 * Revision 1.8  2003/10/14 15:19:24  peiyongz
29 * Implementation of Serialization/Deserialization
30 *
31 * Revision 1.7  2003/09/22 19:47:14  neilg
32 * change Grammar::putElemDecl(XMLElementDecl, bool) so that it does not require the Grammar object to be const.  Also, mark findOrAddGrammar as being dangerous in multithreaded situations
33 *
34 * Revision 1.6  2003/07/31 17:07:33  peiyongz
35 * Grammar embed grammar description
36 *
37 * Revision 1.5  2003/05/15 18:48:27  knoaman
38 * Partial implementation of the configurable memory manager.
39 *
40 * Revision 1.4  2002/11/04 14:54:58  tng
41 * C++ Namespace Support.
42 *
43 * Revision 1.3  2002/07/11 18:17:43  knoaman
44 * Grammar caching/preparsing - initial implementation.
45 *
46 * Revision 1.2  2002/07/05 17:08:10  tng
47 * [Bug 10119] Grammar::getGrammarType need a const modifier
48 *
49 * Revision 1.1.1.1  2002/02/01 22:22:38  peiyongz
50 * sane_include
51 *
52 * Revision 1.6  2001/09/14 14:50:22  tng
53 * Schema: Fix some wildcard bugs, and some retrieving qualified/unqualified element decl problems.
54 *
55 * Revision 1.5  2001/05/28 20:56:18  tng
56 * Schema: Move getTargetNamespace as virtual function in base class Grammar
57 *
58 * Revision 1.4  2001/05/11 13:27:18  tng
59 * Copyright update.
60 *
61 * Revision 1.3  2001/05/03 20:34:40  tng
62 * Schema: SchemaValidator update
63 *
64 * Revision 1.2  2001/04/19 18:17:31  tng
65 * Schema: SchemaValidator update, and use QName in Content Model
66 *
67 * Revision 1.1  2001/03/21 21:56:27  tng
68 * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
69 *
70 */
71
72
73
74#if !defined(GRAMMAR_HPP)
75#define GRAMMAR_HPP
76
77#include <xercesc/framework/XMLElementDecl.hpp>
78#include <xercesc/framework/XMLEntityDecl.hpp>
79#include <xercesc/framework/XMLNotationDecl.hpp>
80
81#include <xercesc/internal/XSerializable.hpp>
82
83XERCES_CPP_NAMESPACE_BEGIN
84
85class XMLGrammarDescription;
86
87//
88// This abstract class specifies the interface for a Grammar
89//
90
91class VALIDATORS_EXPORT Grammar : public XSerializable, public XMemory
92{
93public:
94
95    // -----------------------------------------------------------------------
96    //  Class Specific Types
97    //
98    //  DTDGrammarType    - Indicate this Grammar is built from a DTD.
99    //  SchemaGrammarType - Indicate this Grammar is built from a Schema.
100    //
101    //  TOP_LEVEL_SCOPE - outermost scope level (i.e. global) of a declaration.
102    //                    For DTD, all element decls and attribute decls always
103    //                    have TOP_LEVEL_SCOPE.  For schema, it may varies if
104    //                    it is inside a complex type.
105    //
106    //  UNKNOWN_SCOPE   - unknown scope level.  None of the decls should have this.
107    //
108    // -----------------------------------------------------------------------
109    enum GrammarType {
110        DTDGrammarType
111      , SchemaGrammarType
112      , UnKnown
113    };
114
115    enum {
116         UNKNOWN_SCOPE = -2
117       , TOP_LEVEL_SCOPE = -1
118    };
119
120    // -----------------------------------------------------------------------
121    //  Constructors and Destructor
122    // -----------------------------------------------------------------------
123    virtual ~Grammar(){};
124
125    // -----------------------------------------------------------------------
126    //  Virtual Getter methods
127    // -----------------------------------------------------------------------
128    virtual GrammarType getGrammarType() const =0;
129    virtual const XMLCh* getTargetNamespace() const =0;
130    virtual bool getValidated() const = 0;
131
132    // Element Decl
133
134    // this method should only be used while the grammar is being
135    // constructed, not while it is being used
136    // in a validation episode!
137    virtual XMLElementDecl* findOrAddElemDecl
138    (
139        const   unsigned int    uriId
140        , const XMLCh* const    baseName
141        , const XMLCh* const    prefixName
142        , const XMLCh* const    qName
143        , unsigned int          scope
144        ,       bool&           wasAdded
145    ) = 0;
146
147    virtual unsigned int getElemId
148    (
149        const   unsigned int    uriId
150        , const XMLCh* const    baseName
151        , const XMLCh* const    qName
152        , unsigned int          scope
153    )   const = 0;
154
155    virtual const XMLElementDecl* getElemDecl
156    (
157        const   unsigned int    uriId
158        , const XMLCh* const    baseName
159        , const XMLCh* const    qName
160        , unsigned int          scope
161    )   const = 0;
162
163    virtual XMLElementDecl* getElemDecl
164    (
165        const   unsigned int    uriId
166        , const XMLCh* const    baseName
167        , const XMLCh* const    qName
168        , unsigned int          scope
169    ) = 0;
170
171    virtual const XMLElementDecl* getElemDecl
172    (
173        const   unsigned int    elemId
174    )   const = 0;
175
176    virtual XMLElementDecl* getElemDecl
177    (
178        const   unsigned int    elemId
179    ) = 0;
180
181    // Notation
182    virtual const XMLNotationDecl* getNotationDecl
183    (
184        const   XMLCh* const    notName
185    )   const=0;
186
187    virtual XMLNotationDecl* getNotationDecl
188    (
189        const   XMLCh* const    notName
190    )=0;
191
192    // -----------------------------------------------------------------------
193    //  Virtual Setter methods
194    // -----------------------------------------------------------------------
195    virtual XMLElementDecl* putElemDecl
196    (
197        const   unsigned int    uriId
198        , const XMLCh* const    baseName
199        , const XMLCh* const    prefixName
200        , const XMLCh* const    qName
201        , unsigned int          scope
202        , const bool            notDeclared = false
203    ) = 0;
204
205    virtual unsigned int putElemDecl
206    (
207        XMLElementDecl* const elemDecl
208        , const bool          notDeclared = false
209    )   = 0;
210
211    virtual unsigned int putNotationDecl
212    (
213        XMLNotationDecl* const notationDecl
214    )   const=0;
215
216    virtual void setValidated(const bool newState) = 0;
217
218    // -----------------------------------------------------------------------
219    //  Virtual methods
220    // -----------------------------------------------------------------------
221    virtual void reset()=0;
222
223    virtual void                    setGrammarDescription( XMLGrammarDescription*) = 0;
224    virtual XMLGrammarDescription*  getGrammarDescription() const = 0;
225
226    /***
227     * Support for Serialization/De-serialization
228     ***/
229    DECL_XSERIALIZABLE(Grammar)
230
231        static void     storeGrammar(XSerializeEngine&        serEng
232                               , Grammar* const           grammar);
233
234        static Grammar* loadGrammar(XSerializeEngine& serEng);
235
236protected :
237    // -----------------------------------------------------------------------
238    //  Hidden constructors
239    // -----------------------------------------------------------------------
240    Grammar(){};
241
242private:
243    // -----------------------------------------------------------------------
244    //  Unimplemented constructors and operators
245    // -----------------------------------------------------------------------
246    Grammar(const Grammar&);
247    Grammar& operator=(const Grammar&);
248};
249
250XERCES_CPP_NAMESPACE_END
251
252#endif
Note: See TracBrowser for help on using the repository browser.