source: NonGTP/Xerces/xerces-c_2_8_0/include/xercesc/framework/XMLEntityHandler.hpp @ 2674

Revision 2674, 6.4 KB checked in by mattausch, 16 years ago (diff)
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 /*
19 * $Id: XMLEntityHandler.hpp 568078 2007-08-21 11:43:25Z amassari $
20 */
21
22
23#if !defined(XMLENTITYHANDLER_HPP)
24#define XMLENTITYHANDLER_HPP
25
26#include <xercesc/util/XercesDefs.hpp>
27
28XERCES_CPP_NAMESPACE_BEGIN
29
30class InputSource;
31class XMLBuffer;
32class XMLResourceIdentifier;
33
34/**
35 *  This abstract class is a callback mechanism for the scanner. By creating
36 *  a derivative of this class and plugging into the scanner, the scanner
37 *  will call back on the object's methods to entity events.
38 *
39 *  This class is primarily for use by those writing their own parser classes.
40 *  If you use the standard parser classes, DOMParser and SAXParser, you won't
41 *  use this API. You will instead use a similar mechanism defined by the SAX
42 *  API, called EntityResolver.
43 */
44class XMLPARSER_EXPORT XMLEntityHandler
45{
46public:
47    // -----------------------------------------------------------------------
48    //  Constructors are hidden, only the virtual destructor is exposed
49    // -----------------------------------------------------------------------
50
51    /** @name Destructor */
52    //@{
53
54    /**
55      * Default destructor
56      */
57    virtual ~XMLEntityHandler()
58    {
59    }
60    //@}
61
62
63    // -----------------------------------------------------------------------
64    //  The virtual entity handler interface
65    // -----------------------------------------------------------------------
66    /** @name The pure virtual methods in this interface. */
67    //@{
68
69    /**
70      * This method get called after the scanner has finished reading from
71      * the given input source while processing external entity references.
72      *
73      * @param inputSource The input source for the entity
74      */
75    virtual void endInputSource(const InputSource& inputSource) = 0;
76
77    /**
78      * This method allows the passes the scanned systemId to the entity
79      * handler, thereby giving it a chance to provide any customized
80      * handling like resolving relative path names. The scanner first
81      * calls this method before calling <code>resolveEntity</code>.
82      *
83      * @param systemId The system id extracted by the scanner from the
84      *                 input source.
85      * @param toFill The buffer in which the fully expanded system id needs
86      *               to be stored.
87      */
88    virtual bool expandSystemId
89    (
90        const   XMLCh* const    systemId
91        ,       XMLBuffer&      toFill
92    ) = 0;
93
94    /**
95      * This method allows the entity handler to reset itself, so that
96      * it can be used again. It is called prior to a new document parse
97      * operation.
98      */
99    virtual void resetEntities() = 0;
100
101    /**
102      * This method allows the entity handler to provide customized
103      * application specific entity resolution. This method is defined
104      * by SAX 1.0 API.
105      *
106      * <i>Only one resolveEntity method will be used.  If both setEntityResolver and
107      * setXMLEntityResolver are called, then the last one is used.</i>
108      *
109      * @param publicId A const pointer to a Unicode string representing the
110      *                 public id of the entity just parsed.
111      * @param systemId A const pointer to a Unicode string representing the
112      *                 system id of the entity just parsed.
113      * @param baseURI  A const pointer to a Unicode string representing the
114      *                 base URI of the entity just parsed,
115      *                 or <code>null</code> if there is no base URI.
116      * @return The value returned by the SAX resolveEntity method or
117      *         NULL otherwise to indicate no processing was done.
118      *         The returned InputSource is owned by the parser which is
119      *         responsible to clean up the memory.
120      */
121    virtual InputSource* resolveEntity
122    (
123        const   XMLCh* const    publicId
124        , const XMLCh* const    systemId
125        , const XMLCh* const    baseURI = 0
126    ) = 0;
127
128    /**
129      * This method allows the entity handler to provide customized
130      * application specific entity resolution.
131      *
132      * <i>Only one resolveEntity method will be used.  If both setEntityResolver and
133      * setXMLEntityResolver are called, then the last one is used.</i>
134      *
135      * @param resourceIdentifier An object containing the type of
136      *        resource to be resolved and the associated data members
137      *        corresponding to this type.
138      * @return The value returned by the resolveEntity method or
139      *         NULL otherwise to indicate no processing was done.
140      *         The returned InputSource is owned by the parser which is
141      *         responsible to clean up the memory.
142      */
143    virtual InputSource* resolveEntity
144    (
145        XMLResourceIdentifier* resourceIdentifier
146    ) = 0;
147
148    /**
149      * This method will be called before the scanner starts reading
150      * from an input source while processing external entity references.
151      *
152      * @param inputSource The external input source.
153      */
154    virtual void startInputSource(const InputSource& inputSource) = 0;
155    //@}
156
157
158protected :
159    // -----------------------------------------------------------------------
160    //  Hidden Constructors
161    // -----------------------------------------------------------------------
162    /** @name Constructor */
163    //@{
164
165    /**
166      * Protected default constructor
167      */
168    XMLEntityHandler()
169    {
170    }
171    //@}
172
173
174
175private:
176    // -----------------------------------------------------------------------
177    //  Unimplemented constructors and destructor
178    // -----------------------------------------------------------------------
179    XMLEntityHandler(const XMLEntityHandler&);
180    XMLEntityHandler& operator=(const XMLEntityHandler&);
181};
182
183XERCES_CPP_NAMESPACE_END
184
185#endif
Note: See TracBrowser for help on using the repository browser.