Lunchbox
1.13.0
Multi-threaded C++ toolbox library for all application developers creating high-performance multi-threaded programs.
|
The URI class parses the given uri string according to the regex given in RFC3986. More...
#include <uri.h>
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... | |
URI & | operator= (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... | |
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:
lunchbox::URI::URI | ( | ) |
Construct an empty URI.
|
explicit |
uri | URI string to parse. |
std::exception | for incomplete URIs, and boost::bad_lexical_cast if the port is not a number. |
|
explicit |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void lunchbox::URI::addQuery | ( | const std::string & | key, |
const std::string & | value | ||
) |
Add a key-value pair to the query.
ConstKVIter lunchbox::URI::findQuery | ( | const std::string & | key | ) | const |
ConstKVIter lunchbox::URI::queryBegin | ( | ) | const |
ConstKVIter lunchbox::URI::queryEnd | ( | ) | const |