Uniform Resource Identifier (as defined in RFC 3986). More...
#include <uri.hpp>
Public Member Functions | |
uri () | |
uri (const std::string &uri_str) | |
uri (const char *uri_c_str) | |
uri (const uri &other) | |
const std::string & | str () const |
const char * | c_str () const |
bool | empty () const |
const std::string & | host () const |
bool | host_is_ipv4addr () const |
bool | host_is_ipv6addr () const |
const std::string & | port () const |
boost::uint16_t | port_as_int () const |
const std::string & | user_information () const |
const std::string & | path () const |
const std::string & | query () const |
const std::string & | scheme () const |
const std::string & | fragment () const |
const std::string & | authority () const |
void | swap (uri &other) |
uri & | operator= (const uri &other) |
Uniform Resource Identifier (as defined in RFC 3986).
The following are two example URIs and their component parts: foo://example.com:8042/over/there?name=ferret#nose \_/ \______________/\_________/ \_________/ \__/ | | | | | scheme authority path query fragment | _____________________|__ / \ / \ urn:example:animal:ferret:nose
hamcast::uri::uri | ( | ) |
Create an empty URI.
hamcast::uri::uri | ( | const std::string & | uri_str | ) |
Create an URI from uri_str
.
If uri_str
could not be parsed to a valid URI, then this URI object will be empty.
uri_str | An URI encoded as a string. |
a
be a string then the assertion a.empty() == uri(a).empty()
fails, if a
is not empty, but does not describe a valid URI (e.g. "Hello World" is a string, but is an invalid URI). hamcast::uri::uri | ( | const char * | uri_c_str | ) |
Create an URI from uri_str_c_str
.
uri_c_str | An URI encoded as a C-string. |
hamcast::uri::uri | ( | const uri & | other | ) |
const std::string & hamcast::uri::authority | ( | ) | const |
Get the authority component of this URI object.
The subcomponents of authority could be queried with user_information(), host() and port().
const char* hamcast::uri::c_str | ( | ) | const |
bool hamcast::uri::empty | ( | ) | const |
Check if this URI is empty.
true
if this URI is empty; otherwise false
. const std::string & hamcast::uri::fragment | ( | ) | const |
Get the fragment component of this URI object.
The fragment identifier component of a URI allows indirect identification of a secondary resource by reference to a primary resource and additional identifying information.
const std::string & hamcast::uri::host | ( | ) | const |
Get the host subcomponent of authority.
The host subcomponent of authority is identified by an IP literal encapsulated within square brackets, an IPv4 address in dotted- decimal form, or a registered name.
bool hamcast::uri::host_is_ipv4addr | ( | ) | const |
Check if host() returns an IPv4 address.
true
if the host subcomponent of authority() returns a string that describes a valid IPv4 address; otherwise false
. bool hamcast::uri::host_is_ipv6addr | ( | ) | const |
Check if host() returns an IPv6 address.
[a-f0-9:\.]
so host() might be an invalid ipv6 address. true
if the host subcomponent of authority() returns a string that describes an IPv6 address; otherwise false
. const std::string & hamcast::uri::path | ( | ) | const |
Get the path component of this URI object.
The path component contains data that serves to identifiy a resource within the scope of the URI's scheme and naming authority (if any).
const std::string & hamcast::uri::port | ( | ) | const |
Get the port subcomponent of authority.
Port is either empty or a decimal number (between 0 and 65536).
boost::uint16_t hamcast::uri::port_as_int | ( | ) | const |
Get the port subcomponent as integer value.
This value is always 0 if port().empty() == true
.
const std::string & hamcast::uri::query | ( | ) | const |
Get the query component of this URI object.
The query component contains non-hierarchical data that, along with data in the path component (Section 3.3), serves to identify a resource within the scope of the URI's scheme and naming authority (if any).
const std::string & hamcast::uri::scheme | ( | ) | const |
Get the scheme component of this URI object.
Each URI begins with a scheme name that refers to a specification for assigning identifiers within that scheme.
const std::string & hamcast::uri::str | ( | ) | const |
Get the string describing this URI.
void hamcast::uri::swap | ( | uri & | other | ) |
Exchanges the contents of this
and other
.
other | uri object that should exchange its content with the content of this . |
const std::string & hamcast::uri::user_information | ( | ) | const |
Get the user information subcomponent of authority.
The userinfo subcomponent may consist of a user name and, optionally, scheme-specific information about how to gain authorization to access the resource.