Xalan-C++ API Reference 1.12.0
XalanParsedURI.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#if !defined(XALANPARSEDURI_HEADER_GUARD_1357924680)
20#define XALANPARSEDURI_HEADER_GUARD_1357924680
21
22
23
24// Base include file. Must be first.
26
27
28
30
31
32
33
34namespace XALAN_CPP_NAMESPACE {
35
36
37
38/**
39 * URI handling (hopefully) according to RFC2396.
40 */
42{
43public:
44
45 // Flags to say if a component is defined. Note that each component may
46 // be defined but empty, except for the path.
48 {
49 d_scheme = 1,
50 d_authority = 2,
51 d_query = 4,
52 d_fragment = 8
53 };
54
55 /**
56 * Default constructor
57 */
58 XalanParsedURI(MemoryManager& theManager) :
59 m_scheme(theManager),
60 m_authority(theManager),
61 m_path(theManager),
62 m_query(theManager),
63 m_fragment(theManager),
64 m_defined(0)
65 {
66 }
67
68 /**
69 * Constructor which parses the passed in uri
70 *
71 * @param uriString URI to parse
72 * @param uriStringLen Length of the URI string
73 */
77 MemoryManager& theManager) :
78 m_scheme(theManager),
79 m_authority(theManager),
80 m_path(theManager),
81 m_query(theManager),
82 m_fragment(theManager),
83 m_defined(0)
84 {
85 parse(uriString, uriStringLen);
86 }
87
88 /**
89 * Constructor which parses the passed in uri
90 *
91 * @param uriString URI to parse
92 */
95 MemoryManager& theManager) :
96 m_scheme(theManager),
97 m_authority(theManager),
98 m_path(theManager),
99 m_query(theManager),
100 m_fragment(theManager),
101 m_defined(0)
102 {
103 parse(uriString.c_str(), uriString.length());
104 }
105
106 MemoryManager&
108 {
109 return m_scheme.getMemoryManager();
110 }
111
112 /**
113 * Parse the passed in uri
114 *
115 * @param uriString URI to parse
116 * @param uriStringLen Length of the URI string
117 */
118 void parse(
119 const XalanDOMChar* uriString,
121
122 /**
123 * Parse the passed in uri
124 *
125 * @param uriString URI to parse
126 * @param uriStringLen Length of the URI string
127 */
128 void parse(
130 {
131 parse(uriString.c_str(), uriString.length());
132 }
133
134 /**
135 * Reassemble the uri components to make a complete URI
136 *
137 * @return The reassembled URI
138 */
140
141 /**
142 * Resolve this URI relative to another, according to RFC2396.
143 *
144 * @param base The base URI to use during resolution.
145 */
146 void resolve(const XalanParsedURI &base);
147
148 /**
149 * Resolve this URI relative to another.
150 *
151 * @param base The base URI string
152 * @param baseLen The length of the base URI
153 */
155 const XalanDOMChar *base,
157 {
158 XalanParsedURI baseURI(base, baseLen,getMemoryManager());
159
160 resolve(baseURI);
161 }
162
163 /**
164 * Resolve this URI relative to another.
165 *
166 * @param base The base URI string
167 */
169 const XalanDOMString &base)
170 {
171 resolve(base.c_str(), base.length());
172 }
173
174 /**
175 * Resolve the one URI relative to another.
176 *
177 * @relative The URI string to resolve
178 * @relativeLen The lengh of the relative URI string
179 * @base The base URI string
180 * @baseLen The length of the base URI string
181 *
182 */
184 const XalanDOMChar *relative,
186 const XalanDOMChar *base,
189 );
190
191
192 /**
193 * Resolve the one URI relative to another.
194 *
195 * @relative The URI string to resolve
196 * @base The base URI string
197 *
198 */
201 const XalanDOMString &base,
203 )
204 {
205 return resolve(relative.c_str(), relative.length(), base.c_str(), base.length(), theResult);
206 }
207
208 /**
209 * Get the scheme component
210 */
211 const XalanDOMString& getScheme() const
212 {
213 return m_scheme;
214 }
215
216 /**
217 * See if the scheme component is defined.
218 */
219 bool isSchemeDefined() const
220 {
221 return m_defined & d_scheme;
222 }
223
224 /**
225 * Set the scheme component. Also sets the scheme defined flag.
226 */
228 {
229 m_scheme = scheme;
230 m_defined |= d_scheme;
231 }
232
233 /**
234 * Set the scheme component. Also sets the scheme defined flag.
235 */
237 {
238 m_scheme = scheme;
239 m_defined |= d_scheme;
240 }
241
242 /**
243 * Get the authority component
244 */
246 {
247 return m_authority;
248 }
249
250 /**
251 * See if the authority component is defined.
252 */
253 bool isAuthorityDefined() const
254 {
255 return m_defined & d_authority ? true : false;
256 }
257
258 /**
259 * Set the authority component. Also sets the authority defined flag.
260 */
262 {
263 m_authority = authority;
264 m_defined |= d_authority;
265 }
266
267 /**
268 * Set the authority component. Also sets the authority defined flag.
269 */
271 {
272 m_authority = authority;
273 m_defined |= d_authority;
274 }
275
276 /**
277 * Get the path component
278 */
279 const XalanDOMString& getPath() const
280 {
281 return m_path;
282 }
283
284 /**
285 * Set the path component.
286 */
288 {
289 m_path = path;
290 }
291
292 /**
293 * Set the path component.
294 */
296 {
297 m_path = path;
298 }
299
300 /**
301 * Get function to get the query component
302 */
303 const XalanDOMString& getQuery() const
304 {
305 return m_query;
306 }
307
308 /**
309 * See if the query component is defined.
310 */
311 bool isQueryDefined() const
312 {
313 return m_defined & d_query ? true : false;
314 }
315
316 /**
317 * Set the query component. Also sets the query defined flag.
318 */
320 {
321 m_query = query;
322 m_defined |= d_query;
323 }
324
325 /**
326 * Set the query component. Also sets the query defined flag.
327 */
329 {
330 m_query = query;
331 m_defined |= d_query;
332 }
333
334 /**
335 * Get the fragment component
336 */
338 {
339 return m_fragment;
340 }
341
342 /**
343 * See if the fragment component is defined.
344 */
345 bool isFragmentDefined() const
346 {
347 return m_defined & d_fragment ? true : false;
348 }
349
350 /**
351 * Set the fragment component. Also sets the fragment defined flag.
352 */
354 {
355 m_fragment = fragment;
356 m_defined |= d_fragment;
357 }
358
359 /**
360 * Set the fragment component. Also sets the fragment defined flag.
361 */
363 {
364 m_fragment = fragment;
365 m_defined |= d_fragment;
366 }
367
368 /**
369 * Get the defined components mask.
370 */
371 unsigned int getDefined() const
372 {
373 return m_defined;
374 }
375
376 /**
377 * Set the defined components mask.
378 */
379 void setDefined(unsigned int defined)
380 {
381 m_defined = defined;
382 }
383
384private:
385 // not implemented
388
389 XalanDOMString m_scheme;
390 XalanDOMString m_authority;
391 XalanDOMString m_path;
392 XalanDOMString m_query;
393 XalanDOMString m_fragment;
394
395 unsigned int m_defined;
396};
397
398}
399
400#endif // XALANPARSEDURI_HEADER_GUARD_1357924680
#define XALAN_PLATFORMSUPPORT_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
const XalanDOMChar * c_str() const
size_type length() const
URI handling (hopefully) according to RFC2396.
void parse(const XalanDOMString &uriString)
Parse the passed in uri.
void parse(const XalanDOMChar *uriString, XalanDOMString::size_type uriStringLen)
Parse the passed in uri.
void setFragment(const XalanDOMChar *fragment)
Set the fragment component.
void setScheme(const XalanDOMChar *scheme)
Set the scheme component.
void setQuery(const XalanDOMString &query)
Set the query component.
const XalanDOMString & getFragment() const
Get the fragment component.
void resolve(const XalanDOMChar *base, const XalanDOMString::size_type baseLen)
Resolve this URI relative to another.
const XalanDOMString & getPath() const
Get the path component.
void setPath(const XalanDOMChar *path)
Set the path component.
MemoryManager & getMemoryManager()
void setAuthority(const XalanDOMString &authority)
Set the authority component.
bool isFragmentDefined() const
See if the fragment component is defined.
void setFragment(const XalanDOMString &fragment)
Set the fragment component.
XalanParsedURI(MemoryManager &theManager)
Default constructor.
void setQuery(const XalanDOMChar *query)
Set the query component.
static XalanDOMString & resolve(const XalanDOMChar *relative, XalanDOMString::size_type relativeLen, const XalanDOMChar *base, XalanDOMString::size_type baseLen, XalanDOMString &theResult)
Resolve the one URI relative to another.
static XalanDOMString & resolve(const XalanDOMString &relative, const XalanDOMString &base, XalanDOMString &theResult)
Resolve the one URI relative to another.
void setAuthority(const XalanDOMChar *authority)
Set the authority component.
XalanDOMString & make(XalanDOMString &theResult) const
Reassemble the uri components to make a complete URI.
void setPath(const XalanDOMString &path)
Set the path component.
XalanParsedURI(const XalanDOMString &uriString, MemoryManager &theManager)
Constructor which parses the passed in uri.
bool isQueryDefined() const
See if the query component is defined.
void setDefined(unsigned int defined)
Set the defined components mask.
bool isAuthorityDefined() const
See if the authority component is defined.
bool isSchemeDefined() const
See if the scheme component is defined.
const XalanDOMString & getAuthority() const
Get the authority component.
void setScheme(const XalanDOMString &scheme)
Set the scheme component.
void resolve(const XalanDOMString &base)
Resolve this URI relative to another.
void resolve(const XalanParsedURI &base)
Resolve this URI relative to another, according to RFC2396.
const XalanDOMString & getScheme() const
Get the scheme component.
XalanParsedURI(const XalanDOMChar *uriString, XalanDOMString::size_type uriStringLen, MemoryManager &theManager)
Constructor which parses the passed in uri.
unsigned int getDefined() const
Get the defined components mask.
const XalanDOMString & getQuery() const
Get function to get the query component.