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

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