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>
27#include <string>
28
29namespace decaf {
30namespace 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
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_*/
URI()
Default Constructor, same as calling a Constructor with all fields empty.
Basic type object that holds data that composes a given URI.
Definition URIType.h:31
virtual bool equals(const URI &value) const
std::string getScheme() const
URI(const std::string &uri)
Constructs a URI from the given string.
std::string getSchemeSpecificPart() const
Returns the decoded scheme-specific part of this URI.
virtual bool operator<(const URI &value) const
Compares this object to another and returns true if this object is considered to be less than the one...
URI(const URI &uri)
Constructs a URI as a copy of another URI.
std::string getRawQuery() const
Returns the raw query component of this URI.
std::string getRawFragment() const
Returns the raw fragment component of this URI.
virtual ~URI()
Definition URI.h:130
std::string getRawAuthority() const
Returns the raw authority component of this URI.
URI resolve(const URI &uri) const
Resolves the given URI against this URI.
std::string getRawPath() const
Returns the raw path component of this URI.
URL toURL() const
Constructs a URL from this URI.
URI(const std::string &scheme, const std::string &authority, const std::string &path, const std::string &query, const std::string &fragment)
Constructs a URI from the given components.
URI parseServerAuthority() const
Attempts to parse this URI's authority component, if defined, into user-information,...
std::string getRawUserInfo() const
Returns the raw user-information component of this URI.
std::string getHost() const
std::string getPath() const
std::string getUserInfo() const
URI resolve(const std::string &str) const
Constructs a new URI by parsing the given string and then resolving it against this URI.
bool isOpaque() const
Tells whether or not this URI is opaque.
URI()
Default Constructor, same as calling a Constructor with all fields empty.
URI normalize() const
Normalizes this URI's path.
URI(const std::string &scheme, const std::string &ssp, const std::string &fragment)
Constructs a URI from the given components.
std::string getFragment() const
URI relativize(const URI &uri) const
Relativizes the given URI against this URI.
bool isAbsolute() const
Tells whether or not this URI is absolute.
URI(const std::string &scheme, const std::string &host, const std::string &path, const std::string &fragment)
Constructs a URI from the given components.
static URI create(const std::string uri)
Creates a URI by parsing the given string.
int getPort() const
std::string getRawSchemeSpecificPart() const
Returns the raw scheme-specific part of this URI.
virtual int compareTo(const URI &value) const
Compares this object with the specified object for order.
std::string toString() const
Returns the content of this URI as a string.
virtual bool operator==(const URI &value) const
Compares equality between this object and the one passed.
URI(const std::string &scheme, const std::string &userInfo, const std::string &host, int port, const std::string &path, const std::string &query, const std::string &fragment)
Constructs a URI from the given components.
std::string getAuthority() const
std::string getQuery() const
Class URL represents a Uniform Resource Locator, a pointer to a "resource" on the World Wide Web.
Definition URL.h:118
#define DECAF_API
Definition Config.h:29
Definition URLStreamHandlerManager.h:26
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25