source: NonGTP/Xerces/xerces/include/xercesc/framework/URLInputSource.hpp @ 358

Revision 358, 10.1 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 1999-2000,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 * $Log: URLInputSource.hpp,v $
19 * Revision 1.6  2004/09/08 13:55:58  peiyongz
20 * Apache License Version 2.0
21 *
22 * Revision 1.5  2004/01/29 11:46:29  cargilld
23 * Code cleanup changes to get rid of various compiler diagnostic messages.
24 *
25 * Revision 1.4  2003/12/01 23:23:25  neilg
26 * fix for bug 25118; thanks to Jeroen Witmond
27 *
28 * Revision 1.3  2003/05/16 21:36:55  knoaman
29 * Memory manager implementation: Modify constructors to pass in the memory manager.
30 *
31 * Revision 1.2  2002/11/04 15:00:21  tng
32 * C++ Namespace Support.
33 *
34 * Revision 1.1.1.1  2002/02/01 22:21:50  peiyongz
35 * sane_include
36 *
37 * Revision 1.8  2000/12/14 18:49:56  tng
38 * Fix API document generation warning: "Warning: end of member group without matching begin"
39 *
40 * Revision 1.7  2000/02/24 20:00:22  abagchi
41 * Swat for removing Log from API docs
42 *
43 * Revision 1.6  2000/02/15 23:59:07  roddey
44 * More updated documentation of Framework classes.
45 *
46 * Revision 1.5  2000/02/15 01:21:30  roddey
47 * Some initial documentation improvements. More to come...
48 *
49 * Revision 1.4  2000/02/06 07:47:46  rahulj
50 * Year 2K copyright swat.
51 *
52 * Revision 1.3  2000/01/26 18:56:02  roddey
53 * Needed to include XMLURL.hpp so that it compiles standalone.
54 *
55 * Revision 1.2  2000/01/15 01:26:16  rahulj
56 * Added support for HTTP to the parser using libWWW 5.2.8.
57 * Renamed URL.[ch]pp to XMLURL.[ch]pp and like wise for the class name.
58 * Only tested under NT 4.0 SP 5.
59 * Removed URL.hpp from files where it was not used.
60 *
61 * Revision 1.1  2000/01/12 00:13:26  roddey
62 * These were moved from internal/ to framework/, which was something that should have
63 * happened long ago. They are really framework type of classes.
64 *
65 * Revision 1.1.1.1  1999/11/09 01:08:18  twl
66 * Initial checkin
67 *
68 * Revision 1.2  1999/11/08 20:44:44  rahul
69 * Swat for adding in Product name and CVS comment log variable.
70 *
71 */
72
73
74
75#if !defined(URLINPUTSOURCE_HPP)
76#define URLINPUTSOURCE_HPP
77
78#include <xercesc/util/XMLURL.hpp>
79#include <xercesc/sax/InputSource.hpp>
80
81XERCES_CPP_NAMESPACE_BEGIN
82
83class BinInputStream;
84
85/**
86 *  This class is a derivative of the standard InputSource class. It provides
87 *  for the parser access to data which is referenced via a URL, as apposed to
88 *  a local file name. The URL can be provided via an XMLURL class, as a fully
89 *  qualified system id, or a base system id and a system id which may be
90 *  fully qualified or may be relative to the base.
91 *
92 *  As with all InputSource derivatives. The primary objective of an input
93 *  source is to create an input stream via which the parser can spool in
94 *  data from the referenced source.
95 *
96 *  Note that the parse system does not necessarily support URL based XML
97 *  entities out of the box. Support for socket based access is optional and
98 *  controlled by the per-platform support.
99 */
100class XMLPARSER_EXPORT URLInputSource : public InputSource
101{
102public :
103    // -----------------------------------------------------------------------
104    //  Constructors and Destructor
105    // -----------------------------------------------------------------------
106
107    /** @name Constructors */
108    //@{
109
110    /**
111      * This constructor accepts an already built URL. It is assumed that
112      * it is correct and it will be used as is. In this case, no public id
113      * accepted, but it can still be set via the parent class' setPublicId()
114      * method.
115      *
116      * @param  urlId   The URL which holds the system id of the entity
117      *                 to parse.
118      * @param  manager Pointer to the memory manager to be used to
119      *                 allocate objects.
120      */
121    URLInputSource
122    (
123        const XMLURL& urlId
124        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
125    );
126
127
128    /**
129     *  This constructor takes a base system id URL and a possibly relative
130     *  system id. The relative part is parsed and, if it is indeed relative,
131     *  it will be made relative to the passed base id. Otherwise, it will be
132     *  taken as is.
133     *
134     *  @param  baseId      The base system id URL which provides the base
135     *                      for any relative id part.
136     *
137     *  @param  systemId    The possibly relative system id URL. If its relative
138     *                      its based on baseId, else its taken as is.
139     *  @param  manager     Pointer to the memory manager to be used to
140     *                      allocate objects.
141     */
142    URLInputSource
143    (
144        const   XMLCh* const    baseId
145        , const XMLCh* const    systemId
146        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
147    );
148
149    /**
150     *  This constructor is indentical to the previous one, except that it also
151     *  allows you to set a public id if you want to.
152     *
153     *  @param  baseId      The base system id URL which provides the base
154     *                      for any relative id part.
155     *
156     *  @param  systemId    The possibly relative system id URL. If its relative
157     *                      its based on baseId, else its taken as is.
158     *
159     *  @param  publicId    The optional public id to set. This is just passed
160     *                      on to the parent class for storage.
161     *
162     * @param  manager      Pointer to the memory manager to be used to
163     *                      allocate objects.
164     */
165    URLInputSource
166    (
167        const   XMLCh* const    baseId
168        , const XMLCh* const    systemId
169        , const XMLCh* const    publicId
170        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
171    );
172
173
174    /**
175     *  This constructor is identical to the second constructor above, except that
176     *  it accepts the relative system id part as a local code page string and
177     *  just transcodes it internally, as a convenience.
178     *
179     *  @param  baseId      The base system id URL which provides the base
180     *                      for any relative id part.
181     *
182     *  @param  systemId    The possibly relative system id URL. If its relative
183     *                      its based on baseId, else its taken as is.
184     *
185     *  @param  manager     Pointer to the memory manager to be used to
186     *                      allocate objects.
187     */
188    URLInputSource
189    (
190        const   XMLCh* const    baseId
191        , const char* const     systemId
192        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
193    );
194
195    /**
196     *  This constructor is identical to the third constructor above, except that
197     *  it accepts the relative and public ids as local code page strings and just
198     *  transcodes them internally, as a convenience.
199     *
200     *  @param  baseId      The base system id URL which provides the base
201     *                      for any relative id part.
202     *
203     *  @param  systemId    The possibly relative system id URL. If its relative
204     *                      its based on baseId, else its taken as is.
205     *
206     *  @param  publicId    The optional public id to set. This is just passed
207     *                      on to the parent class for storage.
208     *                      on to the parent class for storage.
209     *
210     *  @param  manager     Pointer to the memory manager to be used to
211     *                      allocate objects.
212     */
213    URLInputSource
214    (
215        const   XMLCh* const    baseId
216        , const char* const     systemId
217        , const char* const     publicId
218        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
219    );
220
221    //@}
222
223    /** @name Destructor */
224    //@{
225    ~URLInputSource();
226    //@}
227
228
229    // -----------------------------------------------------------------------
230    //  Virtual input source interface
231    // -----------------------------------------------------------------------
232
233    /** @name Virtual methods */
234    //@{
235
236    /**
237     * This method will return a binary input stream derivative that will
238     * parse from the source refered to by the URL system id.
239     */
240    BinInputStream* makeStream() const;
241
242    //@}
243
244
245    // -----------------------------------------------------------------------
246    //  Getter methods
247    // -----------------------------------------------------------------------
248
249    /** @name Getter methods */
250    //@{
251
252    /**
253      * This method will return a const reference to the URL member which
254      * contains the system id in pre-parsed URL form. If you just want the
255      * string format, call getSystemId() on the parent class.
256      *
257      * @return A const reference to a URL object that contains the current
258      *         system id set for this input source.
259      */
260    const XMLURL& urlSrc() const;
261
262    //@}
263
264
265private :
266    // -----------------------------------------------------------------------
267    //  Unimplemented constructors and operators
268    // -----------------------------------------------------------------------   
269    URLInputSource(const URLInputSource&);
270    URLInputSource& operator=(const URLInputSource&);
271
272    // -----------------------------------------------------------------------
273    //  Private data members
274    //
275    //  fURL
276    //      This is the URL created from the passed ids.
277    // -----------------------------------------------------------------------
278    XMLURL fURL;
279};
280
281
282inline const XMLURL& URLInputSource::urlSrc() const
283{
284    return fURL;
285}
286
287XERCES_CPP_NAMESPACE_END
288
289#endif
Note: See TracBrowser for help on using the repository browser.