Servus
1.0.0
A small set of network oriented utilities in C++ including a zeroconf implementation.
|
The URI class parses the given uri using the generic syntax from RFC3986. More...
#include <uri.h>
Public Types | |
typedef std::map< std::string, std::string > | KVMap |
typedef KVMap::const_iterator | ConstKVIter |
Public Member Functions | |
SERVUS_API | URI () |
Construct an empty URI. More... | |
SERVUS_API | URI (const std::string &uri) |
SERVUS_API | URI (const char *uri) |
SERVUS_API | URI (const URI &from) |
Copy-construct an URI. More... | |
SERVUS_API URI & | operator= (const URI &rhs) |
Assign the data from another URI. More... | |
SERVUS_API bool | operator== (const URI &rhs) const |
Equals operator. | |
SERVUS_API bool | operator!= (const URI &rhs) const |
Not equals operator. | |
Getters for uri data | |
SERVUS_API const std::string & | getScheme () const |
SERVUS_API const std::string & | getUserinfo () const |
SERVUS_API uint16_t | getPort () const |
SERVUS_API const std::string & | getHost () const |
SERVUS_API const std::string & | getPath () const |
SERVUS_API const std::string & | getQuery () const |
SERVUS_API const std::string & | getFragment () const |
Setters for uri data. | |
SERVUS_API void | setScheme (const std::string &scheme) |
SERVUS_API void | setHost (const std::string &host) |
SERVUS_API void | setPort (uint16_t port) |
Access to key-value data in query. | |
SERVUS_API ConstKVIter | queryBegin () const |
SERVUS_API ConstKVIter | queryEnd () const |
SERVUS_API ConstKVIter | findQuery (const std::string &key) const |
SERVUS_API 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 using the generic syntax from 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:
SERVUS_API servus::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.
SERVUS_API void servus::URI::addQuery | ( | const std::string & | key, |
const std::string & | value | ||
) |
Add a key-value pair to the query.
SERVUS_API ConstKVIter servus::URI::findQuery | ( | const std::string & | key | ) | const |
SERVUS_API ConstKVIter servus::URI::queryBegin | ( | ) | const |
SERVUS_API ConstKVIter servus::URI::queryEnd | ( | ) | const |