activemq-cpp-3.8.2
URI.h
Go to the documentation of this file.
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 #ifndef _DECAF_NET_URI_H_
19 #define _DECAF_NET_URI_H_
20 
21 #include <decaf/util/Config.h>
22 #include <decaf/lang/Comparable.h>
26 #include <decaf/net/URL.h>
28 #include <string>
29 
30 namespace decaf{
31 namespace net{
32 
36  class DECAF_API URI : public lang::Comparable<URI> {
37  private:
38 
39  // The structure that holds the parsed URI data.
41 
42  // The original string entered from URI( string ), empty if not set.
43  mutable std::string uriString;
44 
45  static const std::string unreserved;
46  static const std::string punct;
47  static const std::string reserved;
48  static const std::string someLegal;
49  static const std::string allLegal;
50 
51  public:
52 
56  URI();
57 
65  URI( const URI& uri );
66 
74  URI( const std::string& uri );
75 
85  URI( const std::string& scheme, const std::string& ssp, const std::string& fragment );
86 
100  URI( const std::string& scheme, const std::string& userInfo,
101  const std::string& host, int port,
102  const std::string& path, const std::string& query,
103  const std::string& fragment );
104 
114  URI( const std::string& scheme, const std::string& host,
115  const std::string& path, const std::string& fragment );
116 
127  URI( const std::string& scheme, const std::string& authority,
128  const std::string& path, const std::string& query,
129  const std::string& fragment );
130 
131  virtual ~URI() {}
132 
140  virtual int compareTo( const URI& value ) const;
141 
145  virtual bool equals( const URI& value ) const;
146 
152  virtual bool operator==( const URI& value ) const;
153 
160  virtual bool operator<( const URI& value ) const;
161 
165  std::string getAuthority() const;
166 
170  std::string getFragment() const;
171 
175  std::string getHost() const;
176 
180  std::string getPath() const;
181 
185  int getPort() const;
186 
190  std::string getQuery() const;
191 
195  std::string getScheme() const;
196 
200  std::string getUserInfo() const;
201 
212  std::string getRawAuthority() const;
213 
221  std::string getRawFragment() const;
222 
231  std::string getRawPath() const;
232 
238  std::string getRawQuery() const;
239 
246  std::string getRawSchemeSpecificPart() const;
247 
255  std::string getSchemeSpecificPart() const;
256 
263  std::string getRawUserInfo() const;
264 
270  bool isAbsolute() const;
271 
279  bool isOpaque() const;
280 
305  URI normalize() const;
306 
324  URI parseServerAuthority() const;
325 
342  URI relativize( const URI& uri ) const;
343 
354  URI resolve( const std::string& str ) const;
355 
392  URI resolve( const URI& uri ) const;
393 
405  std::string toString() const;
406 
418  URL toURL() const;
419 
420  public: // Static Methods
421 
432  static URI create( const std::string uri );
433 
434  private:
435 
444  void parseURI( const std::string& uri, bool forceServer );
445 
446  /*
447  * Quote illegal chars for each component, but not the others
448  *
449  * @param component the component to be converted
450  * @param legalset the legal character set allowed in the component strng
451  * @return the converted string
452  */
453  std::string quoteComponent( const std::string& component,
454  const std::string& legalset );
455 
456  /*
457  * Encode Unicode chars that are not part of US-ASCII char set into the
458  * escaped form
459  *
460  * i.e. The Euro currency symbol is encoded as "%E2%82%AC".
461  *
462  * @param src the string to be encoded
463  * @return the converted string
464  */
465  std::string encodeOthers( const std::string& src ) const;
466 
473  std::string decode( const std::string& src ) const;
474 
481  bool equalsHexCaseInsensitive( const std::string& first,
482  const std::string& second ) const;
483 
484  /*
485  * Takes a string that may contain hex sequences like %F1 or %2b and
486  * converts the hex values following the '%' to lowercase.
487  *
488  * @param s - String to convert the hex in.
489  */
490  std::string convertHexToLowerCase( const std::string& s ) const;
491 
492  /*
493  * Normalize path, and return the resulting string.
494  *
495  * @param path - the path value to normalize.
496  */
497  std::string normalize( const std::string& path ) const;
498 
503  void setSchemeSpecificPart();
504 
505  };
506 
507 }}
508 
509 #endif /*_DECAF_NET_URI_H_*/
virtual ~URI()
Definition: URI.h:131
This class represents an instance of a URI as defined by RFC 2396.
Definition: URI.h:36
Basic type object that holds data that composes a given URI.
Definition: URIType.h:31
#define DECAF_API
Definition: Config.h:29
bool operator==(const ArrayPointer< T > &left, const U *right)
Definition: ArrayPointer.h:379
Class URL represents a Uniform Resource Locator, a pointer to a "resource" on the World Wide Web...
Definition: URL.h:106
This interface imposes a total ordering on the objects of each class that implements it...
Definition: Comparable.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25