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 attic/src/common/URI/uri.h.

Member Typedef Documentation

Constructor & Destructor Documentation

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

Construct.

Definition at line 34 of file uri.cpp.

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

Construct from encoded string.

Exceptions
std::invalid_argumentif invalid encoding

Definition at line 35 of file uri.cpp.

References parse.

Member Function Documentation

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

Get authority.

Definition at line 127 of file attic/src/common/URI/uri.h.

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

Test if null/empty.

Definition at line 121 of file attic/src/common/URI/uri.h.

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

Calculate encoded string.

Definition at line 43 of file uri.cpp.

References operator<<().

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

Get fragment.

Definition at line 133 of file attic/src/common/URI/uri.h.

References te::common::uri::operator<<(), te::common::uri::parse(), and TECOMMONEXPORT.

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

Definition at line 60 of file uri.cpp.

Referenced by te::common::uri::parse().

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

Get path.

Definition at line 129 of file attic/src/common/URI/uri.h.

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

Get query.

Definition at line 131 of file attic/src/common/URI/uri.h.

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

Test if relative (null scheme).

Definition at line 123 of file attic/src/common/URI/uri.h.

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

Get scheme (null if relative).

Definition at line 124 of file attic/src/common/URI/uri.h.

Referenced by te::common::URL::getProtocol(), te::common::uri::parse(), and te::common::URL::setProtocol().

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

Get scheme (null if relative).

Definition at line 125 of file attic/src/common/URI/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.

Definition at line 73 of file uri.cpp.

Referenced by te::common::uri::parse(), and uri().

Member Data Documentation

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

Definition at line 140 of file attic/src/common/URI/uri.h.

Referenced by is_null(), and operator<<().

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

Definition at line 143 of file attic/src/common/URI/uri.h.

Referenced by is_null(), and operator<<().

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

Definition at line 141 of file attic/src/common/URI/uri.h.

Referenced by is_null(), and operator<<().

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

Definition at line 142 of file attic/src/common/URI/uri.h.

Referenced by is_null(), and operator<<().

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

Definition at line 139 of file attic/src/common/URI/uri.h.

Referenced by is_null(), and operator<<().


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