1 | #ifndef DOMInputSource_HEADER_GUARD_ |
---|
2 | #define DOMInputSource_HEADER_GUARD_ |
---|
3 | |
---|
4 | /* |
---|
5 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
6 | * contributor license agreements. See the NOTICE file distributed with |
---|
7 | * this work for additional information regarding copyright ownership. |
---|
8 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
9 | * (the "License"); you may not use this file except in compliance with |
---|
10 | * the License. You may obtain a copy of the License at |
---|
11 | * |
---|
12 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
13 | * |
---|
14 | * Unless required by applicable law or agreed to in writing, software |
---|
15 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
17 | * See the License for the specific language governing permissions and |
---|
18 | * limitations under the License. |
---|
19 | */ |
---|
20 | |
---|
21 | /* |
---|
22 | * $Id: DOMInputSource.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
23 | */ |
---|
24 | |
---|
25 | |
---|
26 | #include <xercesc/util/XercesDefs.hpp> |
---|
27 | |
---|
28 | XERCES_CPP_NAMESPACE_BEGIN |
---|
29 | |
---|
30 | |
---|
31 | class BinInputStream; |
---|
32 | |
---|
33 | |
---|
34 | /** |
---|
35 | * This interface represents a single input source for an XML entity. |
---|
36 | * |
---|
37 | * <p>This interface allows an application to encapsulate information about |
---|
38 | * an input source in a single object, which may include a public identifier, |
---|
39 | * a system identifier, a byte stream (possibly with a specified encoding), |
---|
40 | * and/or a character stream.</p> |
---|
41 | * |
---|
42 | * <p>There are two places that the application will deliver this input source |
---|
43 | * to the parser: as the argument to the parse method, or as the return value |
---|
44 | * of the DOMEntityResolver.resolveEntity method.</p> |
---|
45 | * |
---|
46 | * <p>The DOMBuilder will use the DOMInputSource object to determine how to |
---|
47 | * read XML input. If there is a character stream available, the parser will |
---|
48 | * read that stream directly; if not, the parser will use a byte stream, if |
---|
49 | * available; if neither a character stream nor a byte stream is available, |
---|
50 | * the parser will attempt to open a URI connection to the resource identified |
---|
51 | * by the system identifier.</p> |
---|
52 | * |
---|
53 | * <p>A DOMInputSource object belongs to the application: the parser shall |
---|
54 | * never modify it in any way (it may modify a copy if necessary).</p> |
---|
55 | * |
---|
56 | * @see DOMBuilder#parse |
---|
57 | * @see DOMEntityResolver#resolveEntity |
---|
58 | * @since DOM Level 3 |
---|
59 | */ |
---|
60 | class CDOM_EXPORT DOMInputSource |
---|
61 | { |
---|
62 | protected: |
---|
63 | // ----------------------------------------------------------------------- |
---|
64 | // Hidden constructors |
---|
65 | // ----------------------------------------------------------------------- |
---|
66 | /** @name Hidden constructors */ |
---|
67 | //@{ |
---|
68 | DOMInputSource() {}; |
---|
69 | //@} |
---|
70 | |
---|
71 | private: |
---|
72 | // ----------------------------------------------------------------------- |
---|
73 | // Unimplemented constructors and operators |
---|
74 | // ----------------------------------------------------------------------- |
---|
75 | /** @name Unimplemented constructors and operators */ |
---|
76 | //@{ |
---|
77 | DOMInputSource(const DOMInputSource &); |
---|
78 | DOMInputSource & operator = (const DOMInputSource &); |
---|
79 | //@} |
---|
80 | |
---|
81 | public: |
---|
82 | // ----------------------------------------------------------------------- |
---|
83 | // All constructors are hidden, just the destructor is available |
---|
84 | // ----------------------------------------------------------------------- |
---|
85 | /** @name Destructor */ |
---|
86 | //@{ |
---|
87 | /** |
---|
88 | * Destructor |
---|
89 | * |
---|
90 | */ |
---|
91 | virtual ~DOMInputSource() {}; |
---|
92 | //@} |
---|
93 | |
---|
94 | // ----------------------------------------------------------------------- |
---|
95 | // Virtual DOMInputSource interface |
---|
96 | // ----------------------------------------------------------------------- |
---|
97 | /** @name Functions introduced in DOM Level 3 */ |
---|
98 | //@{ |
---|
99 | // ----------------------------------------------------------------------- |
---|
100 | // Getter methods |
---|
101 | // ----------------------------------------------------------------------- |
---|
102 | /** |
---|
103 | * An input source can be set to force the parser to assume a particular |
---|
104 | * encoding for the data that input source reprsents, via the setEncoding() |
---|
105 | * method. This method returns name of the encoding that is to be forced. |
---|
106 | * If the encoding has never been forced, it returns a null pointer. |
---|
107 | * |
---|
108 | * <p><b>"Experimental - subject to change"</b></p> |
---|
109 | * |
---|
110 | * @return The forced encoding, or null if none was supplied. |
---|
111 | * @see #setEncoding |
---|
112 | * @since DOM Level 3 |
---|
113 | */ |
---|
114 | virtual const XMLCh* getEncoding() const = 0; |
---|
115 | |
---|
116 | |
---|
117 | /** |
---|
118 | * Get the public identifier for this input source. |
---|
119 | * |
---|
120 | * <p><b>"Experimental - subject to change"</b></p> |
---|
121 | * |
---|
122 | * @return The public identifier, or null if none was supplied. |
---|
123 | * @see #setPublicId |
---|
124 | * @since DOM Level 3 |
---|
125 | */ |
---|
126 | virtual const XMLCh* getPublicId() const = 0; |
---|
127 | |
---|
128 | |
---|
129 | /** |
---|
130 | * Get the system identifier for this input source. |
---|
131 | * |
---|
132 | * <p><b>"Experimental - subject to change"</b></p> |
---|
133 | * |
---|
134 | * <p>If the system ID is a URL, it will be fully resolved.</p> |
---|
135 | * |
---|
136 | * @return The system identifier. |
---|
137 | * @see #setSystemId |
---|
138 | * @since DOM Level 3 |
---|
139 | */ |
---|
140 | virtual const XMLCh* getSystemId() const = 0; |
---|
141 | |
---|
142 | |
---|
143 | /** |
---|
144 | * Get the base URI to be used for resolving relative URIs to absolute |
---|
145 | * URIs. If the baseURI is itself a relative URI, the behavior is |
---|
146 | * implementation dependent. |
---|
147 | * |
---|
148 | * <p><b>"Experimental - subject to change"</b></p> |
---|
149 | * |
---|
150 | * @return The base URI. |
---|
151 | * @see #setBaseURI |
---|
152 | * @since DOM Level 3 |
---|
153 | */ |
---|
154 | virtual const XMLCh* getBaseURI() const = 0; |
---|
155 | |
---|
156 | // ----------------------------------------------------------------------- |
---|
157 | // Setter methods |
---|
158 | // ----------------------------------------------------------------------- |
---|
159 | /** |
---|
160 | * Set the encoding which will be required for use with the XML text read |
---|
161 | * via a stream opened by this input source. |
---|
162 | * |
---|
163 | * <p>This is usually not set, allowing the encoding to be sensed in the |
---|
164 | * usual XML way. However, in some cases, the encoding in the file is known |
---|
165 | * to be incorrect because of intermediate transcoding, for instance |
---|
166 | * encapsulation within a MIME document. |
---|
167 | * |
---|
168 | * <p><b>"Experimental - subject to change"</b></p> |
---|
169 | * |
---|
170 | * @param encodingStr The name of the encoding to force. |
---|
171 | * @since DOM Level 3 |
---|
172 | */ |
---|
173 | virtual void setEncoding(const XMLCh* const encodingStr) = 0; |
---|
174 | |
---|
175 | |
---|
176 | /** |
---|
177 | * Set the public identifier for this input source. |
---|
178 | * |
---|
179 | * <p>The public identifier is always optional: if the application writer |
---|
180 | * includes one, it will be provided as part of the location information.</p> |
---|
181 | * |
---|
182 | * <p><b>"Experimental - subject to change"</b></p> |
---|
183 | * |
---|
184 | * @param publicId The public identifier as a string. |
---|
185 | * @see #getPublicId |
---|
186 | * @since DOM Level 3 |
---|
187 | */ |
---|
188 | virtual void setPublicId(const XMLCh* const publicId) = 0; |
---|
189 | |
---|
190 | /** |
---|
191 | * Set the system identifier for this input source. |
---|
192 | * |
---|
193 | * <p>The system id is always required. The public id may be used to map |
---|
194 | * to another system id, but the system id must always be present as a fall |
---|
195 | * back.</p> |
---|
196 | * |
---|
197 | * <p>If the system ID is a URL, it must be fully resolved.</p> |
---|
198 | * |
---|
199 | * <p><b>"Experimental - subject to change"</b></p> |
---|
200 | * |
---|
201 | * @param systemId The system identifier as a string. |
---|
202 | * @see #getSystemId |
---|
203 | * @since DOM Level 3 |
---|
204 | */ |
---|
205 | virtual void setSystemId(const XMLCh* const systemId) = 0; |
---|
206 | |
---|
207 | /** |
---|
208 | * Set the base URI to be used for resolving relative URIs to absolute |
---|
209 | * URIs. If the baseURI is itself a relative URI, the behavior is |
---|
210 | * implementation dependent. |
---|
211 | * |
---|
212 | * <p><b>"Experimental - subject to change"</b></p> |
---|
213 | * |
---|
214 | * @param baseURI The base URI. |
---|
215 | * @see #getBaseURI |
---|
216 | * @since DOM Level 3 |
---|
217 | */ |
---|
218 | virtual void setBaseURI(const XMLCh* const baseURI) = 0; |
---|
219 | //@} |
---|
220 | |
---|
221 | // ----------------------------------------------------------------------- |
---|
222 | // Non-standard Extension |
---|
223 | // ----------------------------------------------------------------------- |
---|
224 | /** @name Non-standard Extension */ |
---|
225 | //@{ |
---|
226 | |
---|
227 | /** |
---|
228 | * Makes the byte stream for this input source. |
---|
229 | * |
---|
230 | * <p>The derived class must create and return a binary input stream of an |
---|
231 | * appropriate type for its kind of data source. The returned stream must |
---|
232 | * be dynamically allocated and becomes the parser's property. |
---|
233 | * </p> |
---|
234 | * |
---|
235 | * <p><b>"Experimental - subject to change"</b></p> |
---|
236 | * |
---|
237 | * @see BinInputStream |
---|
238 | */ |
---|
239 | virtual BinInputStream* makeStream() const = 0; |
---|
240 | |
---|
241 | /** |
---|
242 | * Indicates if the parser should issue fatal error if this input source |
---|
243 | * is not found. If set to false, the parser issue warning message instead. |
---|
244 | * |
---|
245 | * <p><b>"Experimental - subject to change"</b></p> |
---|
246 | * |
---|
247 | * @param flag True if the parser should issue fatal error if this input source is not found. |
---|
248 | * If set to false, the parser issue warning message instead. (Default: true) |
---|
249 | * |
---|
250 | * @see #getIssueFatalErrorIfNotFound |
---|
251 | */ |
---|
252 | virtual void setIssueFatalErrorIfNotFound(const bool flag) = 0; |
---|
253 | |
---|
254 | |
---|
255 | /** |
---|
256 | * Get the flag that indicates if the parser should issue fatal error if this input source |
---|
257 | * is not found. |
---|
258 | * |
---|
259 | * <p><b>"Experimental - subject to change"</b></p> |
---|
260 | * |
---|
261 | * @return True if the parser should issue fatal error if this input source is not found. |
---|
262 | * False if the parser issue warning message instead. |
---|
263 | * @see #setIssueFatalErrorIfNotFound |
---|
264 | */ |
---|
265 | virtual bool getIssueFatalErrorIfNotFound() const = 0; |
---|
266 | |
---|
267 | /** |
---|
268 | * Called to indicate that this DOMInputSource is no longer in use |
---|
269 | * and that the implementation may relinquish any resources associated with it. |
---|
270 | * |
---|
271 | * Access to a released object will lead to unexpected result. |
---|
272 | */ |
---|
273 | virtual void release() = 0; |
---|
274 | //@} |
---|
275 | }; |
---|
276 | |
---|
277 | |
---|
278 | XERCES_CPP_NAMESPACE_END |
---|
279 | |
---|
280 | #endif |
---|