source: NonGTP/Xerces/xerces/include/xercesc/internal/WFXMLScanner.hpp @ 358

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

xerces added

Line 
1/*
2 * Copyright 2002,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: WFXMLScanner.hpp,v $
19 * Revision 1.11  2004/09/08 13:56:13  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.10  2004/04/07 14:14:08  peiyongz
23 * make resolveSystemId virutal
24 *
25 * Revision 1.9  2004/01/29 11:46:30  cargilld
26 * Code cleanup changes to get rid of various compiler diagnostic messages.
27 *
28 * Revision 1.8  2003/10/22 20:22:30  knoaman
29 * Prepare for annotation support.
30 *
31 * Revision 1.7  2003/07/10 19:47:24  peiyongz
32 * Stateless Grammar: Initialize scanner with grammarResolver,
33 *                                creating grammar through grammarPool
34 *
35 * Revision 1.6  2003/05/16 21:36:57  knoaman
36 * Memory manager implementation: Modify constructors to pass in the memory manager.
37 *
38 * Revision 1.5  2003/05/15 18:26:29  knoaman
39 * Partial implementation of the configurable memory manager.
40 *
41 * Revision 1.4  2003/03/07 18:08:58  tng
42 * Return a reference instead of void for operator=
43 *
44 * Revision 1.3  2003/01/15 15:49:49  knoaman
45 * Change constant declaration name to match its value.
46 *
47 * Revision 1.2  2003/01/02 16:29:05  knoaman
48 * Modified the way we handle element tags.
49 *
50 * Revision 1.1  2002/12/04 02:01:29  knoaman
51 * Initial checkin.
52 *
53 */
54
55
56#if !defined(WFXMLSCANNER_HPP)
57#define WFXMLSCANNER_HPP
58
59#include <xercesc/internal/XMLScanner.hpp>
60#include <xercesc/util/ValueHashTableOf.hpp>
61#include <xercesc/util/ValueVectorOf.hpp>
62#include <xercesc/validators/DTD/DTDElementDecl.hpp>
63
64XERCES_CPP_NAMESPACE_BEGIN
65
66
67//  This is a a non-validating scanner. No DOCTYPE or XML Schema processing
68//  will take place.
69class XMLPARSER_EXPORT WFXMLScanner : public XMLScanner
70{
71public :
72    // -----------------------------------------------------------------------
73    //  Constructors and Destructor
74    // -----------------------------------------------------------------------
75    WFXMLScanner
76    (
77        XMLValidator* const       valToAdopt
78        , GrammarResolver* const  grammarResolver
79        , MemoryManager* const    manager = XMLPlatformUtils::fgMemoryManager
80    );
81    WFXMLScanner
82    (
83        XMLDocumentHandler* const docHandler
84        , DocTypeHandler* const   docTypeHandler
85        , XMLEntityHandler* const entityHandler
86        , XMLErrorReporter* const errReporter
87        , XMLValidator* const     valToAdopt
88        , GrammarResolver* const  grammarResolver
89        , MemoryManager* const    manager = XMLPlatformUtils::fgMemoryManager
90    );
91    virtual ~WFXMLScanner();
92
93    // -----------------------------------------------------------------------
94    //  XMLScanner public virtual methods
95    // -----------------------------------------------------------------------
96    virtual const XMLCh* getName() const;
97    virtual NameIdPool<DTDEntityDecl>* getEntityDeclPool();
98    virtual const NameIdPool<DTDEntityDecl>* getEntityDeclPool() const;
99    virtual unsigned int resolveQName
100    (
101        const   XMLCh* const        qName
102        ,       XMLBuffer&          prefixBufToFill
103        , const short               mode
104        ,       int&                prefixColonPos
105    );
106    virtual void scanDocument
107    (
108        const   InputSource&    src
109    );
110    virtual bool scanNext(XMLPScanToken& toFill);
111    virtual Grammar* loadGrammar
112    (
113        const   InputSource&    src
114        , const short           grammarType
115        , const bool            toCache = false
116    );
117
118private :
119    // -----------------------------------------------------------------------
120    //  Unimplemented constructors and operators
121    // -----------------------------------------------------------------------
122    WFXMLScanner();
123    WFXMLScanner(const WFXMLScanner&);
124    WFXMLScanner& operator=(const WFXMLScanner&);
125
126    // -----------------------------------------------------------------------
127    //  XMLScanner virtual methods
128    // -----------------------------------------------------------------------
129    virtual void scanCDSection();
130    virtual void scanCharData(XMLBuffer& toToUse);
131    virtual EntityExpRes scanEntityRef
132    (
133        const   bool    inAttVal
134        ,       XMLCh&  firstCh
135        ,       XMLCh&  secondCh
136        ,       bool&   escaped
137    );
138    virtual void scanDocTypeDecl();
139    virtual void scanReset(const InputSource& src);
140    virtual void sendCharData(XMLBuffer& toSend);
141    virtual InputSource* resolveSystemId(const XMLCh* const sysId);
142
143    // -----------------------------------------------------------------------
144    //  Private helper methods
145    // -----------------------------------------------------------------------
146    void commonInit();
147    void cleanUp();
148    unsigned int resolvePrefix
149    (
150        const   XMLCh* const        prefix
151        , const ElemStack::MapModes mode
152    );
153
154    // -----------------------------------------------------------------------
155    //  Private scanning methods
156    // -----------------------------------------------------------------------
157    bool scanAttValue
158    (
159        const   XMLCh* const    attrName
160        ,       XMLBuffer&      toFill
161    );
162    bool scanContent();
163    void scanEndTag(bool& gotData);
164    bool scanStartTag(bool& gotData);
165    bool scanStartTagNS(bool& gotData);
166
167    // -----------------------------------------------------------------------
168    //  Data members
169    //
170    //  fEntityTable
171    //      This the table that contains the default entity entries.
172    //
173    //  fAttrNameHashList
174    //      This contains the hash value for attribute names. It's used when
175    //      checking for duplicate attributes.
176    //
177    //  fAttrNSList
178    //      This contains XMLAttr objects that we need to map their prefixes
179    //      to URIs when namespace is enabled.
180    //
181    // -----------------------------------------------------------------------
182    unsigned int                       fElementIndex;
183    RefVectorOf<XMLElementDecl>*       fElements;
184    ValueHashTableOf<XMLCh>*           fEntityTable;
185    ValueVectorOf<unsigned int>*       fAttrNameHashList;
186    ValueVectorOf<XMLAttr*>*           fAttrNSList;
187    RefHashTableOf<XMLElementDecl>*    fElementLookup; 
188};
189
190inline const XMLCh* WFXMLScanner::getName() const
191{
192    return XMLUni::fgWFXMLScanner;
193}
194
195
196XERCES_CPP_NAMESPACE_END
197
198#endif
Note: See TracBrowser for help on using the repository browser.