1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 2002 The Apache Software Foundation. All rights
|
---|
5 | * reserved.
|
---|
6 | *
|
---|
7 | * Redistribution and use in source and binary forms, with or without
|
---|
8 | * modification, are permitted provided that the following conditions
|
---|
9 | * are met:
|
---|
10 | *
|
---|
11 | * 1. Redistributions of source code must retain the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer.
|
---|
13 | *
|
---|
14 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
15 | * notice, this list of conditions and the following disclaimer in
|
---|
16 | * the documentation and/or other materials provided with the
|
---|
17 | * distribution.
|
---|
18 | *
|
---|
19 | * 3. The end-user documentation included with the redistribution,
|
---|
20 | * if any, must include the following acknowledgment:
|
---|
21 | * "This product includes software developed by the
|
---|
22 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
23 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
24 | * if and wherever such third-party acknowledgments normally appear.
|
---|
25 | *
|
---|
26 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
27 | * not be used to endorse or promote products derived from this
|
---|
28 | * software without prior written permission. For written
|
---|
29 | * permission, please contact apache\@apache.org.
|
---|
30 | *
|
---|
31 | * 5. Products derived from this software may not be called "Apache",
|
---|
32 | * nor may "Apache" appear in their name, without prior written
|
---|
33 | * permission of the Apache Software Foundation.
|
---|
34 | *
|
---|
35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
46 | * SUCH DAMAGE.
|
---|
47 | * ====================================================================
|
---|
48 | *
|
---|
49 | * This software consists of voluntary contributions made by many
|
---|
50 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
51 | * originally based on software copyright (c) 1999, International
|
---|
52 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
53 | * on the Apache Software Foundation, please see
|
---|
54 | * <http://www.apache.org/>.
|
---|
55 | */
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * $Id: Wrapper4DOMInputSource.hpp,v 1.7 2003/12/01 23:23:25 neilg Exp $
|
---|
59 | */
|
---|
60 |
|
---|
61 |
|
---|
62 | #ifndef WRAPPER4DOMINPUTSOURCE_HPP
|
---|
63 | #define WRAPPER4DOMINPUTSOURCE_HPP
|
---|
64 |
|
---|
65 | #include <xercesc/sax/InputSource.hpp>
|
---|
66 |
|
---|
67 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
68 |
|
---|
69 | class DOMInputSource;
|
---|
70 |
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * Wrap a DOMInputSource object to a SAX InputSource.
|
---|
74 | */
|
---|
75 | class XMLPARSER_EXPORT Wrapper4DOMInputSource: public InputSource
|
---|
76 | {
|
---|
77 | public:
|
---|
78 | /** @name Constructors and Destructor */
|
---|
79 | //@{
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * Constructor
|
---|
83 | *
|
---|
84 | * Wrap a DOMInputSource and pretend it to be a SAX InputSource.
|
---|
85 | * By default, the wrapper will adopt the DOMInputSource that is wrapped.
|
---|
86 | *
|
---|
87 | * @param inputSource The DOMInputSource to be wrapped
|
---|
88 | * @param adoptFlag Indicates if the wrapper should adopt the wrapped
|
---|
89 | * DOMInputSource. Default is true.
|
---|
90 | * @param manager Pointer to the memory manager to be used to
|
---|
91 | * allocate objects.
|
---|
92 | */
|
---|
93 | Wrapper4DOMInputSource
|
---|
94 | (
|
---|
95 | DOMInputSource* const inputSource
|
---|
96 | , const bool adoptFlag = true
|
---|
97 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
98 | );
|
---|
99 |
|
---|
100 | /**
|
---|
101 | * Destructor
|
---|
102 | *
|
---|
103 | */
|
---|
104 | virtual ~Wrapper4DOMInputSource();
|
---|
105 | //@}
|
---|
106 |
|
---|
107 |
|
---|
108 | // -----------------------------------------------------------------------
|
---|
109 | /** @name Virtual input source interface */
|
---|
110 | //@{
|
---|
111 | /**
|
---|
112 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
113 | *
|
---|
114 | * Makes the byte stream for this input source.
|
---|
115 | *
|
---|
116 | * <p>The function will call the makeStream of the wrapped input source.
|
---|
117 | * The returned stream becomes the parser's property.</p>
|
---|
118 | *
|
---|
119 | * @see BinInputStream
|
---|
120 | */
|
---|
121 | BinInputStream* makeStream() const;
|
---|
122 |
|
---|
123 | //@}
|
---|
124 |
|
---|
125 | // -----------------------------------------------------------------------
|
---|
126 | /** @name Getter methods */
|
---|
127 | //@{
|
---|
128 | /**
|
---|
129 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
130 | *
|
---|
131 | * An input source can be set to force the parser to assume a particular
|
---|
132 | * encoding for the data that input source reprsents, via the setEncoding()
|
---|
133 | * method. This method will delegate to the wrapped input source to return
|
---|
134 | * name of the encoding that is to be forced. If the encoding has never
|
---|
135 | * been forced, it returns a null pointer.
|
---|
136 | *
|
---|
137 | * @return The forced encoding, or null if none was supplied.
|
---|
138 | * @see #setEncoding
|
---|
139 | */
|
---|
140 | const XMLCh* getEncoding() const;
|
---|
141 |
|
---|
142 |
|
---|
143 | /**
|
---|
144 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
145 | *
|
---|
146 | * Get the public identifier for this input source. Delegated to the
|
---|
147 | * wrapped input source object.
|
---|
148 | *
|
---|
149 | * @return The public identifier, or null if none was supplied.
|
---|
150 | * @see #setPublicId
|
---|
151 | */
|
---|
152 | const XMLCh* getPublicId() const;
|
---|
153 |
|
---|
154 |
|
---|
155 | /**
|
---|
156 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
157 | *
|
---|
158 | * Get the system identifier for this input source. Delegated to the
|
---|
159 | * wrapped input source object.
|
---|
160 | *
|
---|
161 | * <p>If the system ID is a URL, it will be fully resolved.</p>
|
---|
162 | *
|
---|
163 | * @return The system identifier.
|
---|
164 | * @see #setSystemId
|
---|
165 | */
|
---|
166 | const XMLCh* getSystemId() const;
|
---|
167 |
|
---|
168 | /**
|
---|
169 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
170 | *
|
---|
171 | * Get the flag that indicates if the parser should issue fatal error if
|
---|
172 | * this input source is not found. Delegated to the wrapped input source
|
---|
173 | * object.
|
---|
174 | *
|
---|
175 | * @return True if the parser should issue fatal error if this input source
|
---|
176 | * is not found.
|
---|
177 | * False if the parser issue warning message instead.
|
---|
178 | * @see #setIssueFatalErrorIfNotFound
|
---|
179 | */
|
---|
180 | bool getIssueFatalErrorIfNotFound() const;
|
---|
181 |
|
---|
182 | //@}
|
---|
183 |
|
---|
184 |
|
---|
185 | // -----------------------------------------------------------------------
|
---|
186 | /** @name Setter methods */
|
---|
187 | //@{
|
---|
188 |
|
---|
189 | /**
|
---|
190 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
191 | *
|
---|
192 | * Set the encoding which will be required for use with the XML text read
|
---|
193 | * via a stream opened by this input source. This will update the wrapped
|
---|
194 | * input source object.
|
---|
195 | *
|
---|
196 | * <p>This is usually not set, allowing the encoding to be sensed in the
|
---|
197 | * usual XML way. However, in some cases, the encoding in the file is known
|
---|
198 | * to be incorrect because of intermediate transcoding, for instance
|
---|
199 | * encapsulation within a MIME document.
|
---|
200 | *
|
---|
201 | * @param encodingStr The name of the encoding to force.
|
---|
202 | */
|
---|
203 | void setEncoding(const XMLCh* const encodingStr);
|
---|
204 |
|
---|
205 |
|
---|
206 | /**
|
---|
207 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
208 | *
|
---|
209 | * Set the public identifier for this input source. This will update the
|
---|
210 | * wrapped input source object.
|
---|
211 | *
|
---|
212 | * <p>The public identifier is always optional: if the application writer
|
---|
213 | * includes one, it will be provided as part of the location information.</p>
|
---|
214 | *
|
---|
215 | * @param publicId The public identifier as a string.
|
---|
216 | * @see Locator#getPublicId
|
---|
217 | * @see SAXParseException#getPublicId
|
---|
218 | * @see #getPublicId
|
---|
219 | */
|
---|
220 | void setPublicId(const XMLCh* const publicId);
|
---|
221 |
|
---|
222 | /**
|
---|
223 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
224 | *
|
---|
225 | * Set the system identifier for this input source. This will update the
|
---|
226 | * wrapped input source object.
|
---|
227 | *
|
---|
228 | * <p>The system id is always required. The public id may be used to map
|
---|
229 | * to another system id, but the system id must always be present as a fall
|
---|
230 | * back.</p>
|
---|
231 | *
|
---|
232 | * <p>If the system ID is a URL, it must be fully resolved.</p>
|
---|
233 | *
|
---|
234 | * @param systemId The system identifier as a string.
|
---|
235 | * @see #getSystemId
|
---|
236 | * @see Locator#getSystemId
|
---|
237 | * @see SAXParseException#getSystemId
|
---|
238 | */
|
---|
239 | void setSystemId(const XMLCh* const systemId);
|
---|
240 |
|
---|
241 | /**
|
---|
242 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
243 | *
|
---|
244 | * Indicates if the parser should issue fatal error if this input source
|
---|
245 | * is not found. If set to false, the parser issue warning message instead.
|
---|
246 | * This will update the wrapped input source object.
|
---|
247 | *
|
---|
248 | * @param flag True if the parser should issue fatal error if this input source is not found.
|
---|
249 | * If set to false, the parser issue warning message instead. (Default: true)
|
---|
250 | *
|
---|
251 | * @see #getIssueFatalErrorIfNotFound
|
---|
252 | */
|
---|
253 | void setIssueFatalErrorIfNotFound(const bool flag);
|
---|
254 |
|
---|
255 | //@}
|
---|
256 |
|
---|
257 |
|
---|
258 | private:
|
---|
259 | // -----------------------------------------------------------------------
|
---|
260 | // Unimplemented constructors and operators
|
---|
261 | // -----------------------------------------------------------------------
|
---|
262 | Wrapper4DOMInputSource(const Wrapper4DOMInputSource&);
|
---|
263 | Wrapper4DOMInputSource& operator=(const Wrapper4DOMInputSource&);
|
---|
264 |
|
---|
265 | // -----------------------------------------------------------------------
|
---|
266 | // Private data members
|
---|
267 | // -----------------------------------------------------------------------
|
---|
268 | bool fAdoptInputSource;
|
---|
269 | DOMInputSource* fInputSource;
|
---|
270 | };
|
---|
271 |
|
---|
272 | XERCES_CPP_NAMESPACE_END
|
---|
273 |
|
---|
274 |
|
---|
275 | #endif
|
---|