source: icXML/icXML-devel/src/xercesc/framework/Wrapper4InputSource.hpp @ 2722

Last change on this file since 2722 was 2722, checked in by cameron, 6 years ago

Original Xerces files with import mods for icxercesc

File size: 9.1 KB
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 932887 2010-04-11 13:04:59Z borisk $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_WRAPPER4INPUTSOURCE_HPP)
23#define XERCESC_INCLUDE_GUARD_WRAPPER4INPUTSOURCE_HPP
24
25#include <xercesc/dom/DOMLSInput.hpp>
26#include <icxercesc/util/PlatformUtils.hpp>
27
28XERCES_CPP_NAMESPACE_BEGIN
29
30class InputSource;
31
32
33/**
34  * Wrap a SAX InputSource object and make it behave like DOMLSInput.
35  */
36class XMLPARSER_EXPORT Wrapper4InputSource: public DOMLSInput
37{
38public:
39    /** @name Constructors and Destructor */
40    //@{
41
42  /**
43    * Constructor
44    *
45    * Wrap a SAX InputSource and make it behave like a DOMLSInput.
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    * This wrapper doesn't support string data
70    *
71    */
72    virtual const XMLCh* getStringData() const;
73
74  /**
75    * Makes the byte stream for this input source.
76    *
77    * <p>The function will call the makeStream of the wrapped input source.
78    * The returned stream becomes the parser's property.</p>
79    *
80    * @see InputSource
81    */
82    virtual InputSource* getByteStream() const;
83    //@}
84
85    // -----------------------------------------------------------------------
86    /** @name Getter methods */
87    //@{
88  /**
89    * An input source can be set to force the parser to assume a particular
90    * encoding for the data that input source represents, 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    virtual const XMLCh* getEncoding() const;
99
100
101  /**
102    * Get the public identifier for this input source. Delegated to the
103    * wrapped input source object.
104    *
105    * @return The public identifier, or null if none was supplied.
106    * @see #setPublicId
107    */
108    const XMLCh* getPublicId() const;
109
110
111  /**
112    * Get the system identifier for this input source. Delegated to the
113    * wrapped input source object.
114    *
115    * <p>If the system ID is a URL, it will be fully resolved.</p>
116    *
117    * @return The system identifier.
118    * @see #setSystemId
119    */
120    const XMLCh* getSystemId() const;
121
122   /**
123    * Get the base URI to be used for resolving relative URIs to absolute
124    * URIs. If the baseURI is itself a relative URI, the behavior is
125    * implementation dependent. Delegated to the wrapped intput source
126    * object.
127    *
128    * @return The base URI.
129    * @see #setBaseURI
130    * @since DOM Level 3
131    */
132    const XMLCh* getBaseURI() const;
133
134   /**
135    * Get the flag that indicates if the parser should issue fatal error if this input source
136    * is not found. Delegated to the wrapped input source object.
137    *
138    * @return True if the parser should issue fatal error if this input source is not found.
139    *         False if the parser issue warning message instead.
140    * @see #setIssueFatalErrorIfNotFound
141    */
142    bool getIssueFatalErrorIfNotFound() const;
143
144    //@}
145
146
147    // -----------------------------------------------------------------------
148    /** @name Setter methods */
149    //@{
150  /**
151    * This wrapper only exposes the given InputSource, no setting allowed
152    *
153    */
154    virtual void setStringData(const XMLCh* data);
155
156  /**
157    * This wrapper only exposes the given InputSource, no setting allowed
158    *
159    */
160    virtual void setByteStream(InputSource* stream);
161
162  /**
163    * Set the encoding which will be required for use with the XML text read
164    * via a stream opened by this input source. This will update the wrapped
165    * input source object.
166    *
167    * <p>This is usually not set, allowing the encoding to be sensed in the
168    * usual XML way. However, in some cases, the encoding in the file is known
169    * to be incorrect because of intermediate transcoding, for instance
170    * encapsulation within a MIME document.
171    *
172    * @param encodingStr The name of the encoding to force.
173    */
174    void setEncoding(const XMLCh* const encodingStr);
175
176
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    * Set the system identifier for this input source. This will update the
193    * wrapped input source object.
194    *
195    * <p>The system id is always required. The public id may be used to map
196    * to another system id, but the system id must always be present as a fall
197    * back.</p>
198    *
199    * <p>If the system ID is a URL, it must be fully resolved.</p>
200    *
201    * @param systemId The system identifier as a string.
202    * @see #getSystemId
203    * @see Locator#getSystemId
204    * @see SAXParseException#getSystemId
205    */
206    void setSystemId(const XMLCh* const systemId);
207
208   /**
209    * Set the base URI to be used for resolving relative URIs to absolute
210    * URIs. If the baseURI is itself a relative URI, the behavior is
211    * implementation dependent. This will update the wrapped input source
212    * object.
213    *
214    * @param baseURI The base URI.
215    * @see #getBaseURI
216    * @since DOM Level 3
217    */
218    void setBaseURI(const XMLCh* const baseURI);
219
220  /**
221    * Indicates if the parser should issue fatal error if this input source
222    * is not found.  If set to false, the parser issue warning message
223    * instead. This will update the wrapped input source object.
224    *
225    * @param flag  True if the parser should issue fatal error if this input
226    *              source is not found.
227    *              If set to false, the parser issue warning message instead.
228    *              (Default: true)
229    *
230    * @see #getIssueFatalErrorIfNotFound
231    */
232    void setIssueFatalErrorIfNotFound(bool flag);
233
234   /**
235    * Called to indicate that this DOMInputSource is no longer in use
236    * and that the implementation may relinquish any resources associated with it.
237    *
238    * Access to a released object will lead to unexpected result.
239    */
240    void              release();
241
242    //@}
243
244
245private:
246    // -----------------------------------------------------------------------
247    //  Unimplemented constructors and operators
248    // -----------------------------------------------------------------------
249    Wrapper4InputSource(const Wrapper4InputSource&);
250    Wrapper4InputSource& operator=(const Wrapper4InputSource&);
251
252    // -----------------------------------------------------------------------
253    //  Private data members
254    // -----------------------------------------------------------------------
255    bool         fAdoptInputSource;
256    InputSource* fInputSource;
257};
258
259
260// ---------------------------------------------------------------------------
261//  Wrapper4InputSource: Getter methods
262// ---------------------------------------------------------------------------
263inline const XMLCh* Wrapper4InputSource::getBaseURI() const
264{
265    return 0; // REVISIT - should we return an empty string?
266}
267
268inline const XMLCh* Wrapper4InputSource::getStringData() const
269{
270    return 0;
271}
272
273// ---------------------------------------------------------------------------
274//  Wrapper4InputSource: Setter methods
275// ---------------------------------------------------------------------------
276inline void Wrapper4InputSource::setBaseURI(const XMLCh* const)
277{
278}
279
280inline void Wrapper4InputSource::setStringData(const XMLCh*)
281{
282}
283
284inline void Wrapper4InputSource::setByteStream(InputSource*)
285{
286}
287
288XERCES_CPP_NAMESPACE_END
289
290#endif
Note: See TracBrowser for help on using the repository browser.