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