source: icXML/icXML-devel/src/xercesc/framework/URLInputSource.hpp @ 2732

Last change on this file since 2732 was 2722, checked in by cameron, 7 years ago

Original Xerces files with import mods for icxercesc

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