source: NonGTP/Xerces/xerces/include/xercesc/framework/XMLEntityHandler.hpp @ 358

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

xerces added

Line 
1/*
2 * Copyright 1999-2000,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: XMLEntityHandler.hpp,v $
19  * Revision 1.8  2004/09/08 13:55:59  peiyongz
20  * Apache License Version 2.0
21  *
22  * Revision 1.7  2003/10/30 21:37:31  knoaman
23  * Enhanced Entity Resolver Support. Thanks to David Cargill.
24  *
25  * Revision 1.6  2003/03/07 18:08:10  tng
26  * Return a reference instead of void for operator=
27  *
28  * Revision 1.5  2002/11/04 15:00:21  tng
29  * C++ Namespace Support.
30  *
31  * Revision 1.4  2002/06/06 20:41:51  tng
32  * Regression fix: should assign the returned InputSource from resolveEntity to srcToFill.
33  *
34  * Revision 1.3  2002/05/31 15:14:07  tng
35  * Fix doxygen documentation.
36  *
37  * Revision 1.2  2002/05/29 21:47:08  knoaman
38  * DOM L3 LS: DOMInputSource, DOMEntityResolver, DOMImplementationLS and DOMBuilder
39  *
40  * Revision 1.1.1.1  2002/02/01 22:21:51  peiyongz
41  * sane_include
42  *
43  * Revision 1.7  2000/03/02 19:54:25  roddey
44  * This checkin includes many changes done while waiting for the
45  * 1.1.0 code to be finished. I can't list them all here, but a list is
46  * available elsewhere.
47  *
48  * Revision 1.6  2000/02/24 20:00:23  abagchi
49  * Swat for removing Log from API docs
50  *
51  * Revision 1.5  2000/02/16 21:42:58  aruna1
52  * API Doc++ summary changes in
53  *
54  * Revision 1.4  2000/02/15 01:21:31  roddey
55  * Some initial documentation improvements. More to come...
56  *
57  * Revision 1.3  2000/02/06 07:47:48  rahulj
58  * Year 2K copyright swat.
59  *
60  * Revision 1.2  1999/12/15 19:46:28  roddey
61  * Got rid of redundant 'const' on bool return value. Some compilers choke on this
62  * and its not useful anyway.
63  *
64  * Revision 1.1.1.1  1999/11/09 01:08:33  twl
65  * Initial checkin
66  *
67  * Revision 1.2  1999/11/08 20:44:38  rahul
68  * Swat for adding in Product name and CVS comment log variable.
69  *
70  */
71
72
73#if !defined(XMLENTITYHANDLER_HPP)
74#define XMLENTITYHANDLER_HPP
75
76#include <xercesc/util/XercesDefs.hpp>
77
78XERCES_CPP_NAMESPACE_BEGIN
79
80class InputSource;
81class XMLBuffer;
82class XMLResourceIdentifier;
83
84/**
85 *  This abstract class is a callback mechanism for the scanner. By creating
86 *  a derivative of this class and plugging into the scanner, the scanner
87 *  will call back on the object's methods to entity events.
88 *
89 *  This class is primarily for use by those writing their own parser classes.
90 *  If you use the standard parser classes, DOMParser and SAXParser, you won't
91 *  use this API. You will instead use a similar mechanism defined by the SAX
92 *  API, called EntityResolver.
93 */
94class XMLPARSER_EXPORT XMLEntityHandler
95{
96public:
97    // -----------------------------------------------------------------------
98    //  Constructors are hidden, only the virtual destructor is exposed
99    // -----------------------------------------------------------------------
100
101    /** @name Destructor */
102    //@{
103
104    /**
105      * Default destructor
106      */
107    virtual ~XMLEntityHandler()
108    {
109    }
110    //@}
111
112
113    // -----------------------------------------------------------------------
114    //  The virtual entity handler interface
115    // -----------------------------------------------------------------------
116    /** @name The pure virtual methods in this interface. */
117    //@{
118
119    /**
120      * This method get called after the scanner has finished reading from
121      * the given input source while processing external entity references.
122      *
123      * @param inputSource The input source for the entity
124      */
125    virtual void endInputSource(const InputSource& inputSource) = 0;
126
127    /**
128      * This method allows the passes the scanned systemId to the entity
129      * handler, thereby giving it a chance to provide any customized
130      * handling like resolving relative path names. The scanner first
131      * calls this method before calling <code>resolveEntity</code>.
132      *
133      * @param systemId The system id extracted by the scanner from the
134      *                 input source.
135      * @param toFill The buffer in which the fully expanded system id needs
136      *               to be stored.
137      */
138    virtual bool expandSystemId
139    (
140        const   XMLCh* const    systemId
141        ,       XMLBuffer&      toFill
142    ) = 0;
143
144    /**
145      * This method allows the entity handler to reset itself, so that
146      * it can be used again. It is called prior to a new document parse
147      * operation.
148      */
149    virtual void resetEntities() = 0;
150
151    /**
152      * This method allows the entity handler to provide customized
153      * application specific entity resolution. This method is defined
154      * by SAX 1.0 API.
155      *
156      * <i>Only one resolveEntity method will be used.  If both setEntityResolver and
157      * setXMLEntityResolver are called, then the last one is used.</i>
158      *
159      * @param publicId A const pointer to a Unicode string representing the
160      *                 public id of the entity just parsed.
161      * @param systemId A const pointer to a Unicode string representing the
162      *                 system id of the entity just parsed.
163      * @param baseURI  A const pointer to a Unicode string representing the
164      *                 base URI of the entity just parsed,
165      *                 or <code>null</code> if there is no base URI.
166      * @return The value returned by the SAX resolveEntity method or
167      *         NULL otherwise to indicate no processing was done.
168      *         The returned InputSource is owned by the parser which is
169      *         responsible to clean up the memory.
170      */
171    virtual InputSource* resolveEntity
172    (
173        const   XMLCh* const    publicId
174        , const XMLCh* const    systemId
175        , const XMLCh* const    baseURI = 0
176    ) = 0;
177
178    /**
179      * This method allows the entity handler to provide customized
180      * application specific entity resolution.
181      *
182      * <i>Only one resolveEntity method will be used.  If both setEntityResolver and
183      * setXMLEntityResolver are called, then the last one is used.</i>
184      *
185      * @param resourceIdentifier An object containing the type of
186      *        resource to be resolved and the associated data members
187      *        corresponding to this type.
188      * @return The value returned by the resolveEntity method or
189      *         NULL otherwise to indicate no processing was done.
190      *         The returned InputSource is owned by the parser which is
191      *         responsible to clean up the memory.
192      */
193    virtual InputSource* resolveEntity
194    (
195        XMLResourceIdentifier* resourceIdentifier
196    ) = 0;
197
198    /**
199      * This method will be called before the scanner starts reading
200      * from an input source while processing external entity references.
201      *
202      * @param inputSource The external input source.
203      */
204    virtual void startInputSource(const InputSource& inputSource) = 0;
205    //@}
206
207
208protected :
209    // -----------------------------------------------------------------------
210    //  Hidden Constructors
211    // -----------------------------------------------------------------------
212    /** @name Constructor */
213    //@{
214
215    /**
216      * Protected default constructor
217      */
218    XMLEntityHandler()
219    {
220    }
221    //@}
222
223
224
225private:
226    // -----------------------------------------------------------------------
227    //  Unimplemented constructors and destructor
228    // -----------------------------------------------------------------------
229    XMLEntityHandler(const XMLEntityHandler&);
230    XMLEntityHandler& operator=(const XMLEntityHandler&);
231};
232
233XERCES_CPP_NAMESPACE_END
234
235#endif
Note: See TracBrowser for help on using the repository browser.