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: URLInputSource.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | |
---|
23 | |
---|
24 | #if !defined(URLINPUTSOURCE_HPP) |
---|
25 | #define URLINPUTSOURCE_HPP |
---|
26 | |
---|
27 | #include <xercesc/util/XMLURL.hpp> |
---|
28 | #include <xercesc/sax/InputSource.hpp> |
---|
29 | |
---|
30 | XERCES_CPP_NAMESPACE_BEGIN |
---|
31 | |
---|
32 | class BinInputStream; |
---|
33 | |
---|
34 | /** |
---|
35 | * This class is a derivative of the standard InputSource class. It provides |
---|
36 | * for the parser access to data which is referenced via a URL, as apposed to |
---|
37 | * a local file name. The URL can be provided via an XMLURL class, as a fully |
---|
38 | * qualified system id, or a base system id and a system id which may be |
---|
39 | * fully qualified or may be relative to the base. |
---|
40 | * |
---|
41 | * As with all InputSource derivatives. The primary objective of an input |
---|
42 | * source is to create an input stream via which the parser can spool in |
---|
43 | * data from the referenced source. |
---|
44 | * |
---|
45 | * Note that the parse system does not necessarily support URL based XML |
---|
46 | * entities out of the box. Support for socket based access is optional and |
---|
47 | * controlled by the per-platform support. |
---|
48 | */ |
---|
49 | class XMLPARSER_EXPORT URLInputSource : public InputSource |
---|
50 | { |
---|
51 | public : |
---|
52 | // ----------------------------------------------------------------------- |
---|
53 | // Constructors and Destructor |
---|
54 | // ----------------------------------------------------------------------- |
---|
55 | |
---|
56 | /** @name Constructors */ |
---|
57 | //@{ |
---|
58 | |
---|
59 | /** |
---|
60 | * This constructor accepts an already built URL. It is assumed that |
---|
61 | * it is correct and it will be used as is. In this case, no public id |
---|
62 | * accepted, but it can still be set via the parent class' setPublicId() |
---|
63 | * method. |
---|
64 | * |
---|
65 | * @param urlId The URL which holds the system id of the entity |
---|
66 | * to parse. |
---|
67 | * @param manager Pointer to the memory manager to be used to |
---|
68 | * allocate objects. |
---|
69 | */ |
---|
70 | URLInputSource |
---|
71 | ( |
---|
72 | const XMLURL& urlId |
---|
73 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
74 | ); |
---|
75 | |
---|
76 | |
---|
77 | /** |
---|
78 | * This constructor takes a base system id URL and a possibly relative |
---|
79 | * system id. The relative part is parsed and, if it is indeed relative, |
---|
80 | * it will be made relative to the passed base id. Otherwise, it will be |
---|
81 | * taken as is. |
---|
82 | * |
---|
83 | * @param baseId The base system id URL which provides the base |
---|
84 | * for any relative id part. |
---|
85 | * |
---|
86 | * @param systemId The possibly relative system id URL. If its relative |
---|
87 | * its based on baseId, else its taken as is. |
---|
88 | * @param manager Pointer to the memory manager to be used to |
---|
89 | * allocate objects. |
---|
90 | */ |
---|
91 | URLInputSource |
---|
92 | ( |
---|
93 | const XMLCh* const baseId |
---|
94 | , const XMLCh* const systemId |
---|
95 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
96 | ); |
---|
97 | |
---|
98 | /** |
---|
99 | * This constructor is indentical to the previous one, except that it also |
---|
100 | * allows you to set a public id if you want to. |
---|
101 | * |
---|
102 | * @param baseId The base system id URL which provides the base |
---|
103 | * for any relative id part. |
---|
104 | * |
---|
105 | * @param systemId The possibly relative system id URL. If its relative |
---|
106 | * its based on baseId, else its taken as is. |
---|
107 | * |
---|
108 | * @param publicId The optional public id to set. This is just passed |
---|
109 | * on to the parent class for storage. |
---|
110 | * |
---|
111 | * @param manager Pointer to the memory manager to be used to |
---|
112 | * allocate objects. |
---|
113 | */ |
---|
114 | URLInputSource |
---|
115 | ( |
---|
116 | const XMLCh* const baseId |
---|
117 | , const XMLCh* const systemId |
---|
118 | , const XMLCh* const publicId |
---|
119 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
120 | ); |
---|
121 | |
---|
122 | |
---|
123 | /** |
---|
124 | * This constructor is identical to the second constructor above, except that |
---|
125 | * it accepts the relative system id part as a local code page string and |
---|
126 | * just transcodes it internally, as a convenience. |
---|
127 | * |
---|
128 | * @param baseId The base system id URL which provides the base |
---|
129 | * for any relative id part. |
---|
130 | * |
---|
131 | * @param systemId The possibly relative system id URL. If its relative |
---|
132 | * its based on baseId, else its taken as is. |
---|
133 | * |
---|
134 | * @param manager Pointer to the memory manager to be used to |
---|
135 | * allocate objects. |
---|
136 | */ |
---|
137 | URLInputSource |
---|
138 | ( |
---|
139 | const XMLCh* const baseId |
---|
140 | , const char* const systemId |
---|
141 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
142 | ); |
---|
143 | |
---|
144 | /** |
---|
145 | * This constructor is identical to the third constructor above, except that |
---|
146 | * it accepts the relative and public ids as local code page strings and just |
---|
147 | * transcodes them internally, as a convenience. |
---|
148 | * |
---|
149 | * @param baseId The base system id URL which provides the base |
---|
150 | * for any relative id part. |
---|
151 | * |
---|
152 | * @param systemId The possibly relative system id URL. If its relative |
---|
153 | * its based on baseId, else its taken as is. |
---|
154 | * |
---|
155 | * @param publicId The optional public id to set. This is just passed |
---|
156 | * on to the parent class for storage. |
---|
157 | * on to the parent class for storage. |
---|
158 | * |
---|
159 | * @param manager Pointer to the memory manager to be used to |
---|
160 | * allocate objects. |
---|
161 | */ |
---|
162 | URLInputSource |
---|
163 | ( |
---|
164 | const XMLCh* const baseId |
---|
165 | , const char* const systemId |
---|
166 | , const char* const publicId |
---|
167 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
168 | ); |
---|
169 | |
---|
170 | //@} |
---|
171 | |
---|
172 | /** @name Destructor */ |
---|
173 | //@{ |
---|
174 | ~URLInputSource(); |
---|
175 | //@} |
---|
176 | |
---|
177 | |
---|
178 | // ----------------------------------------------------------------------- |
---|
179 | // Virtual input source interface |
---|
180 | // ----------------------------------------------------------------------- |
---|
181 | |
---|
182 | /** @name Virtual methods */ |
---|
183 | //@{ |
---|
184 | |
---|
185 | /** |
---|
186 | * This method will return a binary input stream derivative that will |
---|
187 | * parse from the source refered to by the URL system id. |
---|
188 | */ |
---|
189 | BinInputStream* makeStream() const; |
---|
190 | |
---|
191 | //@} |
---|
192 | |
---|
193 | |
---|
194 | // ----------------------------------------------------------------------- |
---|
195 | // Getter methods |
---|
196 | // ----------------------------------------------------------------------- |
---|
197 | |
---|
198 | /** @name Getter methods */ |
---|
199 | //@{ |
---|
200 | |
---|
201 | /** |
---|
202 | * This method will return a const reference to the URL member which |
---|
203 | * contains the system id in pre-parsed URL form. If you just want the |
---|
204 | * string format, call getSystemId() on the parent class. |
---|
205 | * |
---|
206 | * @return A const reference to a URL object that contains the current |
---|
207 | * system id set for this input source. |
---|
208 | */ |
---|
209 | const XMLURL& urlSrc() const; |
---|
210 | |
---|
211 | //@} |
---|
212 | |
---|
213 | |
---|
214 | private : |
---|
215 | // ----------------------------------------------------------------------- |
---|
216 | // Unimplemented constructors and operators |
---|
217 | // ----------------------------------------------------------------------- |
---|
218 | URLInputSource(const URLInputSource&); |
---|
219 | URLInputSource& operator=(const URLInputSource&); |
---|
220 | |
---|
221 | // ----------------------------------------------------------------------- |
---|
222 | // Private data members |
---|
223 | // |
---|
224 | // fURL |
---|
225 | // This is the URL created from the passed ids. |
---|
226 | // ----------------------------------------------------------------------- |
---|
227 | XMLURL fURL; |
---|
228 | }; |
---|
229 | |
---|
230 | |
---|
231 | inline const XMLURL& URLInputSource::urlSrc() const |
---|
232 | { |
---|
233 | return fURL; |
---|
234 | } |
---|
235 | |
---|
236 | XERCES_CPP_NAMESPACE_END |
---|
237 | |
---|
238 | #endif |
---|