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

Revision 358, 9.2 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 * $Id: Wrapper4InputSource.hpp,v 1.10 2004/09/08 13:55:58 peiyongz Exp $
19 */
20
21
22#ifndef WRAPPER4INPUTSOURCE_HPP
23#define WRAPPER4INPUTSOURCE_HPP
24
25#include <xercesc/dom/DOMInputSource.hpp>
26#include <xercesc/util/PlatformUtils.hpp>
27
28XERCES_CPP_NAMESPACE_BEGIN
29
30class InputSource;
31
32
33/**
34  * Wrap a SAX InputSource object to a DOM InputSource.
35  */
36class XMLPARSER_EXPORT Wrapper4InputSource: public DOMInputSource
37{
38public:
39    /** @name Constructors and Destructor */
40    //@{
41
42  /**
43    * Constructor
44    *
45    * Wrap a SAX InputSource and pretend it to be a DOMInputSource.
46    * By default, the wrapper will adopt the SAX InputSource that is wrapped.
47    *
48    * @param  inputSource  The SAX InputSource to be wrapped
49    * @param  adoptFlag    Indicates if the wrapper should adopt the wrapped
50    *                      SAX InputSource. Default is true.
51    * @param manager The MemoryManager to use to allocate objects
52    */
53    Wrapper4InputSource(InputSource* const inputSource
54                        , const bool adoptFlag = true
55                        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
56
57  /**
58    * Destructor
59    *
60    */
61    virtual ~Wrapper4InputSource();
62    //@}
63
64
65    // -----------------------------------------------------------------------
66    /** @name Virtual input source interface */
67    //@{
68  /**
69    * <p><b>"Experimental - subject to change"</b></p>
70    *
71    * Makes the byte stream for this input source.
72    *
73    * <p>The function will call the makeStream of the wrapped input source.
74    * The returned stream becomes the parser's property.</p>
75    *
76    * @see BinInputStream
77    */
78    BinInputStream* makeStream() const;
79
80    //@}
81
82    // -----------------------------------------------------------------------
83    /** @name Getter methods */
84    //@{
85  /**
86    * <p><b>"Experimental - subject to change"</b></p>
87    *
88    * An input source can be set to force the parser to assume a particular
89    * encoding for the data that input source reprsents, via the setEncoding()
90    * method. This method will delegate to the wrapped input source to return
91    * name of the encoding that is to be forced. If the encoding has never
92    * been forced, it returns a null pointer.
93    *
94    * @return The forced encoding, or null if none was supplied.
95    * @see #setEncoding
96    */
97    const XMLCh* getEncoding() const;
98
99
100  /**
101    * <p><b>"Experimental - subject to change"</b></p>
102    *
103    * Get the public identifier for this input source. Delegated to the
104    * wrapped input source object.
105    *
106    * @return The public identifier, or null if none was supplied.
107    * @see #setPublicId
108    */
109    const XMLCh* getPublicId() const;
110
111
112  /**
113    * <p><b>"Experimental - subject to change"</b></p>
114    *
115    * Get the system identifier for this input source. Delegated to the
116    * wrapped input source object.
117    *
118    * <p>If the system ID is a URL, it will be fully resolved.</p>
119    *
120    * @return The system identifier.
121    * @see #setSystemId
122    */
123    const XMLCh* getSystemId() const;
124
125   /**
126     * Get the base URI to be used for resolving relative URIs to absolute
127     * URIs. If the baseURI is itself a relative URI, the behavior is
128     * implementation dependent. Delegated to the wrapped intput source
129     * object.
130     *
131     * <p><b>"Experimental - subject to change"</b></p>
132     *
133     * @return The base URI.
134     * @see #setBaseURI
135     * @since DOM Level 3
136     */
137    const XMLCh* getBaseURI() const;
138
139 /**
140    * <p><b>"Experimental - subject to change"</b></p>
141    *
142    * Get the flag that indicates if the parser should issue fatal error if this input source
143    * is not found. Delegated to the wrapped input source object.
144    *
145    * @return True if the parser should issue fatal error if this input source is not found.
146    *         False if the parser issue warning message instead.
147    * @see #setIssueFatalErrorIfNotFound
148    */
149    bool getIssueFatalErrorIfNotFound() const;
150
151    //@}
152
153
154    // -----------------------------------------------------------------------
155    /** @name Setter methods */
156    //@{
157
158  /**
159    * <p><b>"Experimental - subject to change"</b></p>
160    *
161    * Set the encoding which will be required for use with the XML text read
162    * via a stream opened by this input source. This will update the wrapped
163    * input source object.
164    *
165    * <p>This is usually not set, allowing the encoding to be sensed in the
166    * usual XML way. However, in some cases, the encoding in the file is known
167    * to be incorrect because of intermediate transcoding, for instance
168    * encapsulation within a MIME document.
169    *
170    * @param encodingStr The name of the encoding to force.
171    */
172    void setEncoding(const XMLCh* const encodingStr);
173
174
175  /**
176    * <p><b>"Experimental - subject to change"</b></p>
177    *
178    * Set the public identifier for this input source. This will update the
179    * wrapped input source object.
180    *
181    * <p>The public identifier is always optional: if the application writer
182    * includes one, it will be provided as part of the location information.</p>
183    *
184    * @param publicId The public identifier as a string.
185    * @see Locator#getPublicId
186    * @see SAXParseException#getPublicId
187    * @see #getPublicId
188    */
189    void setPublicId(const XMLCh* const publicId);
190
191  /**
192    * <p><b>"Experimental - subject to change"</b></p>
193    *
194    * Set the system identifier for this input source. This will update the
195    * wrapped input source object.
196    *
197    * <p>The system id is always required. The public id may be used to map
198    * to another system id, but the system id must always be present as a fall
199    * back.</p>
200    *
201    * <p>If the system ID is a URL, it must be fully resolved.</p>
202    *
203    * @param systemId The system identifier as a string.
204    * @see #getSystemId
205    * @see Locator#getSystemId
206    * @see SAXParseException#getSystemId
207    */
208    void setSystemId(const XMLCh* const systemId);
209
210   /**
211    * Set the base URI to be used for resolving relative URIs to absolute
212    * URIs. If the baseURI is itself a relative URI, the behavior is
213    * implementation dependent. This will update the wrapped input source
214    * object.
215    *
216    * <p><b>"Experimental - subject to change"</b></p>
217    *
218    * @param baseURI The base URI.
219    * @see #getBaseURI
220    * @since DOM Level 3
221    */
222    void setBaseURI(const XMLCh* const baseURI);
223
224  /**
225    * <p><b>"Experimental - subject to change"</b></p>
226    *
227    * Indicates if the parser should issue fatal error if this input source
228    * is not found.  If set to false, the parser issue warning message
229    * instead. This will update the wrapped input source object.
230    *
231    * @param flag  True if the parser should issue fatal error if this input
232    *              source is not found.
233    *              If set to false, the parser issue warning message instead.
234    *              (Default: true)
235    *
236    * @see #getIssueFatalErrorIfNotFound
237    */
238    void setIssueFatalErrorIfNotFound(const bool flag);
239
240   /**
241    * Called to indicate that this DOMInputSource is no longer in use
242    * and that the implementation may relinquish any resources associated with it.
243    *
244    * Access to a released object will lead to unexpected result.
245    */
246    void              release();
247
248    //@}
249
250
251private:
252    // -----------------------------------------------------------------------
253    //  Unimplemented constructors and operators
254    // -----------------------------------------------------------------------
255    Wrapper4InputSource(const Wrapper4InputSource&);
256    Wrapper4InputSource& operator=(const Wrapper4InputSource&);
257
258    // -----------------------------------------------------------------------
259    //  Private data members
260    // -----------------------------------------------------------------------
261    bool         fAdoptInputSource;
262    InputSource* fInputSource;
263};
264
265
266// ---------------------------------------------------------------------------
267//  Wrapper4InputSource: Getter methods
268// ---------------------------------------------------------------------------
269inline const XMLCh* Wrapper4InputSource::getBaseURI() const
270{
271    return 0; // REVISIT - should we return an empty string?
272}
273
274// ---------------------------------------------------------------------------
275//  Wrapper4InputSource: Setter methods
276// ---------------------------------------------------------------------------
277inline void Wrapper4InputSource::setBaseURI(const XMLCh* const)
278{
279}
280
281XERCES_CPP_NAMESPACE_END
282
283#endif
Note: See TracBrowser for help on using the repository browser.