hamcast  Version 0.7
Public Member Functions | List of all members
hamcast::uri Class Reference

#include <uri.hpp>

Inheritance diagram for hamcast::uri:
hamcast::util::comparable< uri, uri > hamcast::util::comparable< uri, const char * > hamcast::util::comparable< uri, std::string >

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 & user_information_and_host () 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)
 
urioperator= (const uri &other)
 

Detailed Description

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
\_/ \______________/\_________/ \_________/ \__/
| | | | |
| _____________________|__
/ \ / \
urn:example:animal:ferret:nose
Note
The documentation of the accessors are taken from RFC 3986.

Constructor & Destructor Documentation

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.

Parameters
uri_strAn URI encoded as a string.
Warning
Let 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.

Parameters
uri_c_strAn URI encoded as a C-string.
See Also
uri(const std::string&)
hamcast::uri::uri ( const uri other)

Create this object as a copy of other.

Parameters
otherThe original uri object.
Note
uri is implicit shared, thus copy operations are very fast and lightweight.

Member Function Documentation

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().

Returns
The authority component.
const char* hamcast::uri::c_str ( ) const

Get the string describing this uri as a C-string.

Returns
The full string representation of this URI as C-string.
Note
Equal to str().c_str().
bool hamcast::uri::empty ( ) const

Check if this URI is empty.

Returns
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.

Returns
The fragment component.
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.

Returns
The host subcomponent of authority().
bool hamcast::uri::host_is_ipv4addr ( ) const

Check if host() returns an IPv4 address.

Note
The testing is done in the constructor, so this member function only checks an internal flag (and has no other overhead!).
Returns
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.

Note
Returns true if host matches the regex [a-f0-9:] so host() might be an invalid ipv6 address.
The testing is done in the constructor, so this member function only checks an internal flag (and has no other overhead!).
Returns
true if the host subcomponent of authority() returns a string that describes an IPv6 address; otherwise false.
Warning
This member function does not guarantee, that host() returns a valid IPv6 address.
uri & hamcast::uri::operator= ( const uri other)

Equivalent to uri(other).swap(*this).

Parameters
otherOriginal uri object.
Returns
*this.
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).

Returns
The path component.
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).

Returns
A string representation of the port subcomponent of authority().
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.

Returns
An integer (16-bit, unsigned) representation of the port subcomponent of authority().
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).

Returns
The query component.
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.

Returns
The scheme component.
const std::string & hamcast::uri::str ( ) const

Get the string describing this URI.

Returns
The full string representation of this URI.
void hamcast::uri::swap ( uri other)

Exchanges the contents of this and other.

Parameters
otheruri 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.

Returns
The user information subcomponent of authority().
const std::string & hamcast::uri::user_information_and_host ( ) const

Get the user information plus host subcomponents of authority.


The documentation for this class was generated from the following files: