activemq-cpp-3.9.5
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>
27 #include <string>
28 
29 namespace decaf {
30 namespace net {
31 
32  class URL;
33 
37  class DECAF_API URI: public lang::Comparable<URI> {
38  private:
39 
40  // The structure that holds the parsed URI data.
42 
43  // The original string entered from URI( string ), empty if not set.
44  mutable std::string uriString;
45 
46  static const std::string unreserved;
47  static const std::string punct;
48  static const std::string reserved;
49  static const std::string someLegal;
50  static const std::string allLegal;
51 
52  public:
53 
57  URI();
58 
66  URI(const URI& uri);
67 
75  URI(const std::string& uri);
76 
86  URI(const std::string& scheme, const std::string& ssp, const std::string& fragment);
87 
101  URI(const std::string& scheme, const std::string& userInfo, const std::string& host, int port,
102  const std::string& path, const std::string& query, const std::string& fragment);
103 
113  URI(const std::string& scheme, const std::string& host,
114  const std::string& path, const std::string& fragment);
115 
126  URI(const std::string& scheme, const std::string& authority,
127  const std::string& path, const std::string& query,
128  const std::string& fragment);
129 
130  virtual ~URI() {}
131 
139  virtual int compareTo(const URI& value) const;
140 
144  virtual bool equals(const URI& value) const;
145 
151  virtual bool operator==(const URI& value) const;
152 
159  virtual bool operator<(const URI& value) const;
160 
164  std::string getAuthority() const;
165 
169  std::string getFragment() const;
170 
174  std::string getHost() const;
175 
179  std::string getPath() const;
180 
184  int getPort() const;
185 
189  std::string getQuery() const;
190 
194  std::string getScheme() const;
195 
199  std::string getUserInfo() const;
200 
212  std::string getRawAuthority() const;
213 
222  std::string getRawFragment() const;
223 
233  std::string getRawPath() const;
234 
242  std::string getRawQuery() const;
243 
252  std::string getRawSchemeSpecificPart() const;
253 
262  std::string getSchemeSpecificPart() const;
263 
271  std::string getRawUserInfo() const;
272 
279  bool isAbsolute() const;
280 
289  bool isOpaque() const;
290 
316  URI normalize() const;
317 
337  URI parseServerAuthority() const;
338 
357  URI relativize(const URI& uri) const;
358 
373  URI resolve(const std::string& str) const;
374 
414  URI resolve(const URI& uri) const;
415 
428  std::string toString() const;
429 
443  URL toURL() const;
444 
445  public: // Static Methods
446 
457  static URI create(const std::string uri);
458 
459  private:
460 
469  void parseURI(const std::string& uri, bool forceServer);
470 
471  /*
472  * Quote illegal chars for each component, but not the others
473  *
474  * @param component the component to be converted
475  * @param legalset the legal character set allowed in the component strng
476  * @return the converted string
477  */
478  std::string quoteComponent(const std::string& component, const std::string& legalset);
479 
480  /*
481  * Encode Unicode chars that are not part of US-ASCII char set into the
482  * escaped form
483  *
484  * i.e. The Euro currency symbol is encoded as "%E2%82%AC".
485  *
486  * @param src the string to be encoded
487  * @return the converted string
488  */
489  std::string encodeOthers(const std::string& src) const;
490 
497  std::string decode(const std::string& src) const;
498 
505  bool equalsHexCaseInsensitive(const std::string& first, const std::string& second) const;
506 
507  /*
508  * Takes a string that may contain hex sequences like %F1 or %2b and
509  * converts the hex values following the '%' to lowercase.
510  *
511  * @param s - String to convert the hex in.
512  */
513  std::string convertHexToLowerCase(const std::string& s) const;
514 
515  /*
516  * Normalize path, and return the resulting string.
517  *
518  * @param path - the path value to normalize.
519  */
520  std::string normalize(const std::string& path) const;
521 
526  void setSchemeSpecificPart();
527 
528  };
529 
530 }}
531 
532 #endif /*_DECAF_NET_URI_H_*/
virtual ~URI()
Definition: URI.h:130
This class represents an instance of a URI as defined by RFC 2396.
Definition: URI.h:37
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:118
This interface imposes a total ordering on the objects of each class that implements it...
Definition: Comparable.h:33
bool operator<(const std::string &left, const String &right)