uripp::uri Class Reference

List of all members.

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>


 uripp::uri u("http://mydomain.com/a/b/c?id=12345&s=x%20y");
 assert(u.scheme().string() == "http");
 assert(u.authority().host() == "mydomain.com");
 uripp::path::const_iterator it = u.path().begin();
 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:

Public Types

typedef uripp::scheme scheme_type
 scheme type
typedef uripp::authority authority_type
 authority type
typedef uripp::path path_type
 path type
typedef uripp::query query_type
 query type
typedef uripp::fragment fragment_type
 fragment type

Public Member Functions

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


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

Constructor & Destructor Documentation

uripp::uri::uri (  ) 


uripp::uri::uri ( const std::string &  v  ) 

Construct from encoded string.

std::invalid_argument if invalid encoding

Friends And Related Function Documentation

bool URIPP_API 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.

Generated on Wed May 13 09:06:22 2009 for uripp by  doxygen 1.4.7