Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:34:30

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  * 
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  * 
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_GRAMMAR_HPP)
0023 #define XERCESC_INCLUDE_GUARD_GRAMMAR_HPP
0024 
0025 #include <limits.h>
0026 
0027 #include <xercesc/framework/XMLElementDecl.hpp>
0028 #include <xercesc/framework/XMLEntityDecl.hpp>
0029 #include <xercesc/framework/XMLNotationDecl.hpp>
0030 
0031 #include <xercesc/internal/XSerializable.hpp>
0032 
0033 XERCES_CPP_NAMESPACE_BEGIN
0034 
0035 class XMLGrammarDescription;
0036 
0037 //
0038 // This abstract class specifies the interface for a Grammar
0039 //
0040 
0041 class VALIDATORS_EXPORT Grammar : public XSerializable, public XMemory
0042 {
0043 public:
0044 
0045     // -----------------------------------------------------------------------
0046     //  Class Specific Types
0047     //
0048     //  DTDGrammarType    - Indicate this Grammar is built from a DTD.
0049     //  SchemaGrammarType - Indicate this Grammar is built from a Schema.
0050     //
0051     //  TOP_LEVEL_SCOPE - outermost scope level (i.e. global) of a declaration.
0052     //                    For DTD, all element decls and attribute decls always
0053     //                    have TOP_LEVEL_SCOPE.  For schema, it may vary if
0054     //                    it is inside a complex type.
0055     //
0056     //  UNKNOWN_SCOPE   - unknown scope level.  None of the decls should have this.
0057     //
0058     // -----------------------------------------------------------------------
0059     enum GrammarType {
0060         DTDGrammarType
0061       , SchemaGrammarType
0062       , UnKnown
0063     };
0064 
0065     enum {
0066         // These are well-known values that must simply be larger
0067         // than any reasonable scope
0068          UNKNOWN_SCOPE      = UINT_MAX - 0
0069        , TOP_LEVEL_SCOPE    = UINT_MAX - 1
0070     };
0071 
0072     // -----------------------------------------------------------------------
0073     //  Constructors and Destructor
0074     // -----------------------------------------------------------------------
0075     virtual ~Grammar(){};
0076 
0077     // -----------------------------------------------------------------------
0078     //  Virtual Getter methods
0079     // -----------------------------------------------------------------------
0080     virtual GrammarType getGrammarType() const =0;
0081     virtual const XMLCh* getTargetNamespace() const =0;
0082     virtual bool getValidated() const = 0;
0083 
0084     // Element Decl
0085 
0086     // this method should only be used while the grammar is being
0087     // constructed, not while it is being used
0088     // in a validation episode!
0089     virtual XMLElementDecl* findOrAddElemDecl
0090     (
0091         const   unsigned int    uriId
0092         , const XMLCh* const    baseName
0093         , const XMLCh* const    prefixName
0094         , const XMLCh* const    qName
0095         , unsigned int          scope
0096         ,       bool&           wasAdded
0097     ) = 0;
0098 
0099     virtual XMLSize_t getElemId
0100     (
0101         const   unsigned int    uriId
0102         , const XMLCh* const    baseName
0103         , const XMLCh* const    qName
0104         , unsigned int          scope
0105     )   const = 0;
0106 
0107     virtual const XMLElementDecl* getElemDecl
0108     (
0109         const   unsigned int    uriId
0110         , const XMLCh* const    baseName
0111         , const XMLCh* const    qName
0112         , unsigned int          scope
0113     )   const = 0;
0114 
0115     virtual XMLElementDecl* getElemDecl
0116     (
0117         const   unsigned int    uriId
0118         , const XMLCh* const    baseName
0119         , const XMLCh* const    qName
0120         , unsigned int          scope
0121     ) = 0;
0122 
0123     virtual const XMLElementDecl* getElemDecl
0124     (
0125         const   unsigned int    elemId
0126     )   const = 0;
0127 
0128     virtual XMLElementDecl* getElemDecl
0129     (
0130         const   unsigned int    elemId
0131     ) = 0;
0132 
0133     // Notation
0134     virtual const XMLNotationDecl* getNotationDecl
0135     (
0136         const   XMLCh* const    notName
0137     )   const=0;
0138 
0139     virtual XMLNotationDecl* getNotationDecl
0140     (
0141         const   XMLCh* const    notName
0142     )=0;
0143 
0144     // -----------------------------------------------------------------------
0145     //  Virtual Setter methods
0146     // -----------------------------------------------------------------------
0147     virtual XMLElementDecl* putElemDecl
0148     (
0149         const   unsigned int    uriId
0150         , const XMLCh* const    baseName
0151         , const XMLCh* const    prefixName
0152         , const XMLCh* const    qName
0153         , unsigned int          scope
0154         , const bool            notDeclared = false
0155     ) = 0;
0156 
0157     virtual XMLSize_t putElemDecl
0158     (
0159         XMLElementDecl* const elemDecl
0160         , const bool          notDeclared = false
0161     )   = 0;
0162 
0163     virtual XMLSize_t putNotationDecl
0164     (
0165         XMLNotationDecl* const notationDecl
0166     )   const=0;
0167 
0168     virtual void setValidated(const bool newState) = 0;
0169 
0170     // -----------------------------------------------------------------------
0171     //  Virtual methods
0172     // -----------------------------------------------------------------------
0173     virtual void reset()=0;
0174 
0175     virtual void                    setGrammarDescription( XMLGrammarDescription*) = 0;
0176     virtual XMLGrammarDescription*  getGrammarDescription() const = 0;
0177 
0178     /***
0179      * Support for Serialization/De-serialization
0180      ***/
0181     DECL_XSERIALIZABLE(Grammar)
0182 
0183     static void     storeGrammar(XSerializeEngine&        serEng
0184                                , Grammar* const           grammar);
0185 
0186     static Grammar* loadGrammar(XSerializeEngine& serEng);
0187 
0188 protected :
0189     // -----------------------------------------------------------------------
0190     //  Hidden constructors
0191     // -----------------------------------------------------------------------
0192     Grammar(){};
0193 
0194 private:
0195     // -----------------------------------------------------------------------
0196     //  Unimplemented constructors and operators
0197     // -----------------------------------------------------------------------
0198     Grammar(const Grammar&);
0199     Grammar& operator=(const Grammar&);
0200 };
0201 
0202 XERCES_CPP_NAMESPACE_END
0203 
0204 #endif