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 
34 namespace XALAN_CPP_NAMESPACE {
35 
36 
37 
38 /**
39  * URI handling (hopefully) according to RFC2396.
40  */
42 {
43 public:
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  */
75  const XalanDOMChar* uriString,
76  XalanDOMString::size_type uriStringLen,
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  */
94  const XalanDOMString &uriString,
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,
120  XalanDOMString::size_type uriStringLen);
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(
129  const XalanDOMString &uriString)
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  */
139  XalanDOMString& make(XalanDOMString& theResult) const;
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  */
154  void resolve(
155  const XalanDOMChar *base,
156  const XalanDOMString::size_type baseLen)
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  */
168  void resolve(
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  */
183  static XalanDOMString& resolve(
184  const XalanDOMChar *relative,
185  XalanDOMString::size_type relativeLen,
186  const XalanDOMChar *base,
188  XalanDOMString& theResult
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  */
200  const XalanDOMString &relative,
201  const XalanDOMString &base,
202  XalanDOMString& theResult
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  */
227  void setScheme(const XalanDOMChar *scheme)
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  */
236  void setScheme(const XalanDOMString &scheme)
237  {
238  m_scheme = scheme;
239  m_defined |= d_scheme;
240  }
241 
242  /**
243  * Get the authority component
244  */
245  const XalanDOMString& getAuthority() const
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  */
261  void setAuthority(const XalanDOMChar *authority)
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  */
270  void setAuthority(const XalanDOMString &authority)
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  */
287  void setPath(const XalanDOMChar *path)
288  {
289  m_path = path;
290  }
291 
292  /**
293  * Set the path component.
294  */
295  void setPath(const XalanDOMString &path)
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  */
319  void setQuery(const XalanDOMChar *query)
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  */
328  void setQuery(const XalanDOMString &query)
329  {
330  m_query = query;
331  m_defined |= d_query;
332  }
333 
334  /**
335  * Get the fragment component
336  */
337  const XalanDOMString& getFragment() const
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  */
353  void setFragment(const XalanDOMChar *fragment)
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  */
362  void setFragment(const XalanDOMString &fragment)
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 
384 private:
385  // not implemented
386  XalanParsedURI();
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
xalanc::XalanParsedURI::resolve
void resolve(const XalanDOMChar *base, const XalanDOMString::size_type baseLen)
Resolve this URI relative to another.
Definition: XalanParsedURI.hpp:154
xalanc::XalanParsedURI::getFragment
const XalanDOMString & getFragment() const
Get the fragment component.
Definition: XalanParsedURI.hpp:337
xalanc::XalanParsedURI::getAuthority
const XalanDOMString & getAuthority() const
Get the authority component.
Definition: XalanParsedURI.hpp:245
xalanc::XalanParsedURI::resolve
void resolve(const XalanDOMString &base)
Resolve this URI relative to another.
Definition: XalanParsedURI.hpp:168
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::XalanParsedURI::getDefined
unsigned int getDefined() const
Get the defined components mask.
Definition: XalanParsedURI.hpp:371
xalanc::XalanParsedURI::getPath
const XalanDOMString & getPath() const
Get the path component.
Definition: XalanParsedURI.hpp:279
xalanc::XalanParsedURI::eComponent
eComponent
Definition: XalanParsedURI.hpp:47
xalanc::XalanParsedURI::parse
void parse(const XalanDOMString &uriString)
Parse the passed in uri.
Definition: XalanParsedURI.hpp:128
xalanc::XalanParsedURI::setDefined
void setDefined(unsigned int defined)
Set the defined components mask.
Definition: XalanParsedURI.hpp:379
XalanDOMString.hpp
xalanc::XalanParsedURI::setQuery
void setQuery(const XalanDOMChar *query)
Set the query component.
Definition: XalanParsedURI.hpp:319
xalanc::XalanParsedURI::getScheme
const XalanDOMString & getScheme() const
Get the scheme component.
Definition: XalanParsedURI.hpp:211
xalanc::XalanParsedURI::setPath
void setPath(const XalanDOMChar *path)
Set the path component.
Definition: XalanParsedURI.hpp:287
xalanc::XalanParsedURI::setFragment
void setFragment(const XalanDOMChar *fragment)
Set the fragment component.
Definition: XalanParsedURI.hpp:353
xalanc::XalanParsedURI::XalanParsedURI
XalanParsedURI(MemoryManager &theManager)
Default constructor.
Definition: XalanParsedURI.hpp:58
xalanc::XalanParsedURI::XalanParsedURI
XalanParsedURI(const XalanDOMChar *uriString, XalanDOMString::size_type uriStringLen, MemoryManager &theManager)
Constructor which parses the passed in uri.
Definition: XalanParsedURI.hpp:74
xalanc::XalanParsedURI::setQuery
void setQuery(const XalanDOMString &query)
Set the query component.
Definition: XalanParsedURI.hpp:328
xalanc::XalanParsedURI::getMemoryManager
MemoryManager & getMemoryManager()
Definition: XalanParsedURI.hpp:107
XALAN_PLATFORMSUPPORT_EXPORT
#define XALAN_PLATFORMSUPPORT_EXPORT
Definition: PlatformSupportDefinitions.hpp:35
PlatformSupportDefinitions.hpp
xalanc::XalanParsedURI::setAuthority
void setAuthority(const XalanDOMString &authority)
Set the authority component.
Definition: XalanParsedURI.hpp:270
xalanc::XalanParsedURI::setPath
void setPath(const XalanDOMString &path)
Set the path component.
Definition: XalanParsedURI.hpp:295
xalanc::XalanParsedURI::setScheme
void setScheme(const XalanDOMChar *scheme)
Set the scheme component.
Definition: XalanParsedURI.hpp:227
xalanc::XalanDOMString::length
size_type length() const
Definition: XalanDOMString.hpp:209
xalanc::XalanParsedURI::setScheme
void setScheme(const XalanDOMString &scheme)
Set the scheme component.
Definition: XalanParsedURI.hpp:236
xalanc::XalanParsedURI::getQuery
const XalanDOMString & getQuery() const
Get function to get the query component.
Definition: XalanParsedURI.hpp:303
xalanc::XalanParsedURI::isQueryDefined
bool isQueryDefined() const
See if the query component is defined.
Definition: XalanParsedURI.hpp:311
xalanc::XalanParsedURI::resolve
static XalanDOMString & resolve(const XalanDOMString &relative, const XalanDOMString &base, XalanDOMString &theResult)
Resolve the one URI relative to another.
Definition: XalanParsedURI.hpp:199
xalanc::XalanParsedURI::isSchemeDefined
bool isSchemeDefined() const
See if the scheme component is defined.
Definition: XalanParsedURI.hpp:219
xalanc::XalanDOMString::c_str
const XalanDOMChar * c_str() const
Definition: XalanDOMString.hpp:344
xalanc::XalanParsedURI::XalanParsedURI
XalanParsedURI(const XalanDOMString &uriString, MemoryManager &theManager)
Constructor which parses the passed in uri.
Definition: XalanParsedURI.hpp:93
xalanc::XalanDOMString::size_type
XalanSize_t size_type
Definition: XalanDOMString.hpp:57
xalanc::XalanParsedURI::setFragment
void setFragment(const XalanDOMString &fragment)
Set the fragment component.
Definition: XalanParsedURI.hpp:362
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
xalanc::XalanParsedURI::isFragmentDefined
bool isFragmentDefined() const
See if the fragment component is defined.
Definition: XalanParsedURI.hpp:345
xalanc::XalanParsedURI::setAuthority
void setAuthority(const XalanDOMChar *authority)
Set the authority component.
Definition: XalanParsedURI.hpp:261
xalanc::XalanParsedURI
URI handling (hopefully) according to RFC2396.
Definition: XalanParsedURI.hpp:41
xalanc::XalanParsedURI::isAuthorityDefined
bool isAuthorityDefined() const
See if the authority component is defined.
Definition: XalanParsedURI.hpp:253