te::common::uri::uri Class Reference

Uniform Resource Identifier (URI) reference. More...

#include <uri.h>

Public Types

typedef te::common::uri::authority authority_type
 authority type More...
 
typedef te::common::uri::fragment fragment_type
 fragment type More...
 
typedef te::common::uri::path path_type
 path type More...
 
typedef te::common::uri::query query_type
 query type More...
 
typedef te::common::uri::scheme scheme_type
 scheme type More...
 

Public Member Functions

const authority_typeauthority () const
 Get authority. More...
 
authority_typeauthority ()
 Get authority. More...
 
bool empty () const
 Test if null/empty. More...
 
std::string encoding () const
 Calculate encoded string. More...
 
const fragment_typefragment () const
 Get fragment. More...
 
fragment_typefragment ()
 Get fragment. More...
 
bool is_null () const
 Test if null/empty. More...
 
std::ostream & operator<< (std::ostream &os) const
 Stream out encoding. More...
 
const path_typepath () const
 Get path. More...
 
path_typepath ()
 Get path. More...
 
const query_typequery () const
 Get query. More...
 
query_typequery ()
 Get query. More...
 
bool relative () const
 Test if relative (null scheme). More...
 
const scheme_typescheme () const
 Get scheme (null if relative). More...
 
scheme_typescheme ()
 Get scheme (null if relative). More...
 
 uri ()
 Construct. More...
 
 uri (const std::string &v)
 Construct from encoded string. More...
 

Static Private Member Functions

static bool parse_literal (std::string::const_iterator &first, std::string::const_iterator last, const char *v)
 

Private Attributes

authority_type authority_
 
fragment_type fragment_
 
path_type path_
 
query_type query_
 
scheme_type scheme_
 

Friends

bool TECOMMONEXPORT parse (std::string::const_iterator &first, std::string::const_iterator last, uri &v, std::string *errs)
 Parse URI, returning whether found or not and advancing first and setting URI if found. More...
 

Detailed Description

Uniform Resource Identifier (URI) reference.

A "URI-reference" is either a URI or a relative reference.

Syntax: Note that it is up to the application to correctly compose a URI reference with a missing scheme or authority, i.e. to make sure the initial path chars (if any) do not look like a scheme or authority (it helps with this library that the path class cannot have empty segments so it cannot have a URI authority-like prefix).

URI           = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
relative-ref  = relative-part [ "?" query ] [ "#" fragment ]
relative-part = "//" authority path-abempty
              | path-absolute
              | path-noscheme
              | path-empty
hier-part     = "//" authority path-abempty
              | path-absolute
              | path-rootless
              | path-empty
path-abempty  = *( "/" segment )
path-absolute = "/" [ segment-nz *( "/" segment ) ]
path-noscheme = segment-nz-nc *( "/" segment )
path-rootless = segment-nz *( "/" segment )
path-empty    = 0<pchar>

Example:

te::common::uri::uri u("http://mydomain.com/a/b/c?id=12345&s=x%20y");
assert(u.scheme().string() == "http");
assert(u.authority().host() == "mydomain.com");
assert(u.path().absolute());
assert(*it == "a" && *++it == "b" && *++it == "c" && ++it == u.path().end());
int id;
std::string s;
bool is_null;
assert(u.query().find("id", id, is_null) && id == 12345 && !is_null);
assert(u.query().find("s", s, is_null) && s == "x y" && !is_null);
assert(!u.query().find("foo", s, is_null));
See also
http://tools.ietf.org/html/rfc3986

Definition at line 110 of file uri.h.

Member Typedef Documentation

authority type

Definition at line 113 of file uri.h.

fragment type

Definition at line 116 of file uri.h.

path type

Definition at line 114 of file uri.h.

query type

Definition at line 115 of file uri.h.

scheme type

Definition at line 112 of file uri.h.

Constructor & Destructor Documentation

te::common::uri::uri::uri ( )

Construct.

te::common::uri::uri::uri ( const std::string &  v)

Construct from encoded string.

Exceptions
std::invalid_argumentif invalid encoding

Member Function Documentation

const authority_type& te::common::uri::uri::authority ( ) const
inline

Get authority.

Definition at line 126 of file uri.h.

authority_type& te::common::uri::uri::authority ( )
inline

Get authority.

Definition at line 127 of file uri.h.

bool te::common::uri::uri::empty ( ) const
inline

Test if null/empty.

Definition at line 121 of file uri.h.

std::string te::common::uri::uri::encoding ( ) const

Calculate encoded string.

const fragment_type& te::common::uri::uri::fragment ( ) const
inline

Get fragment.

Definition at line 132 of file uri.h.

fragment_type& te::common::uri::uri::fragment ( )
inline

Get fragment.

Definition at line 133 of file uri.h.

bool te::common::uri::uri::is_null ( ) const

Test if null/empty.

std::ostream& te::common::uri::uri::operator<< ( std::ostream &  os) const

Stream out encoding.

static bool te::common::uri::uri::parse_literal ( std::string::const_iterator &  first,
std::string::const_iterator  last,
const char *  v 
)
staticprivate
const path_type& te::common::uri::uri::path ( ) const
inline

Get path.

Definition at line 128 of file uri.h.

path_type& te::common::uri::uri::path ( )
inline

Get path.

Definition at line 129 of file uri.h.

const query_type& te::common::uri::uri::query ( ) const
inline

Get query.

Definition at line 130 of file uri.h.

query_type& te::common::uri::uri::query ( )
inline

Get query.

Definition at line 131 of file uri.h.

bool te::common::uri::uri::relative ( ) const
inline

Test if relative (null scheme).

Definition at line 123 of file uri.h.

const scheme_type& te::common::uri::uri::scheme ( ) const
inline

Get scheme (null if relative).

Definition at line 124 of file uri.h.

scheme_type& te::common::uri::uri::scheme ( )
inline

Get scheme (null if relative).

Definition at line 125 of file uri.h.

Friends And Related Function Documentation

bool TECOMMONEXPORT parse ( std::string::const_iterator &  first,
std::string::const_iterator  last,
uri v,
std::string *  errs 
)
friend

Parse URI, returning whether found or not and advancing first and setting URI if found.

Does not skip leading space.

If errs is specified parsing is more lax allowing decoding and other errors and setting errs with the error messages. See the individual component parse functions for details.

Member Data Documentation

authority_type te::common::uri::uri::authority_
private

Definition at line 140 of file uri.h.

fragment_type te::common::uri::uri::fragment_
private

Definition at line 143 of file uri.h.

path_type te::common::uri::uri::path_
private

Definition at line 141 of file uri.h.

query_type te::common::uri::uri::query_
private

Definition at line 142 of file uri.h.

scheme_type te::common::uri::uri::scheme_
private

Definition at line 139 of file uri.h.


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