Lunchbox  1.13.0
Multi-threaded C++ toolbox library for all application developers creating high-performance multi-threaded programs.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
lunchbox::URI Class Reference

The URI class parses the given uri string according to the regex given in RFC3986. More...

#include <uri.h>

+ Collaboration diagram for lunchbox::URI:

Public Types

typedef boost::unordered_map
< std::string, std::string > 
KVMap
 
typedef KVMap::const_iterator ConstKVIter
 

Public Member Functions

 URI ()
 Construct an empty URI. More...
 
 URI (const std::string &uri)
 
 URI (const char *uri)
 
 URI (const URI &from)
 Copy-construct an URI. More...
 
URIoperator= (const URI &rhs)
 Assign the data from another URI. More...
 
Getters for the uri data @version 1.9.2
const std::string & getScheme () const
 
const std::string & getUserinfo () const
 
uint16_t getPort () const
 
const std::string & getHost () const
 
const std::string & getPath () const
 
const std::string & getQuery () const
 
const std::string & getFragment () const
 
Access to key-value data in query @version 1.9.2
ConstKVIter queryBegin () const
 
ConstKVIter queryEnd () const
 
ConstKVIter findQuery (const std::string &key) const
 
void addQuery (const std::string &key, const std::string &value)
 Add a key-value pair to the query. More...
 

Detailed Description

The URI class parses the given uri string according to the regex given in RFC3986.

* http://bob@www.example.com:8080/path/?key=value,foo=bar#fragment
* ^   ^  ^  ^               ^    ^     ^                 ^
* a   b  c  d               e    f     g                 h
*
* URI part  Range   String
* scheme    [a, b)  "http"
* userinfo [c, d) bob
* host  [d, e)  "www.example.com"
* port (e, f) 8080
* path  [f, g)  "/path/"
* query (g, h)  "key=value"
* fragment  (h,-) "fragment"
* 

Queries are parsed into key-value pairs and can be accessed using findQuery(), queryBegin() and queryEnd().

Example:

Definition at line 55 of file uri.h.

Constructor & Destructor Documentation

lunchbox::URI::URI ( )

Construct an empty URI.

Version
1.9.2
lunchbox::URI::URI ( const std::string &  uri)
explicit
Parameters
uriURI string to parse.
Exceptions
std::exceptionfor incomplete URIs, and boost::bad_lexical_cast if the port is not a number.
Version
1.9.2
lunchbox::URI::URI ( const char *  uri)
explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

lunchbox::URI::URI ( const URI from)

Copy-construct an URI.

Version
1.9.2

Member Function Documentation

void lunchbox::URI::addQuery ( const std::string &  key,
const std::string &  value 
)

Add a key-value pair to the query.

Version
1.9.2
ConstKVIter lunchbox::URI::findQuery ( const std::string &  key) const
Returns
a const iterator to the given key, or queryEnd().
Version
1.9.2
URI& lunchbox::URI::operator= ( const URI rhs)

Assign the data from another URI.

Version
1.9.2
ConstKVIter lunchbox::URI::queryBegin ( ) const
Returns
a const iterator to the beginning of the query map.
Version
1.9.2
ConstKVIter lunchbox::URI::queryEnd ( ) const
Returns
a const iterator to end beginning of the query map.
Version
1.9.2

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