A simple parser for URLs.
More...
#include <gurl.h>
|
typedef std::multimap
< std::string, std::string > | Map |
|
|
| Url () |
| Default constructor for a url with a path of "/".
|
|
| Url (const std::string &) |
| Constructor.
|
|
std::string | protocol () const |
| Returns the protocol part eg. "http".
|
|
std::string | address () const |
| Returns the address part, which might include the port, and which might use ipv6 square brackets. More...
|
|
std::string | address (const std::string &default_port) const |
| Returns the transport address formed from host() and port(default_port). More...
|
|
std::string | host () const |
| Returns the hostname or network address part. More...
|
|
std::string | port (const std::string &default_=std::string()) const |
| Returns the port or service-name, or the specified default if none. More...
|
|
std::string | path () const |
| Returns the path part, including the leading slash.
|
|
std::string | request () const |
| Returns the path and parameters, suitable for a GET request.
|
|
std::string | parameters () const |
| Returns the parameters string.
|
|
Map | pmap () const |
| Returns the decode()d parameters as a multimap.
|
|
bool | has (const std::string &key) const |
| Returns true if the named parameter is present.
|
|
std::string | parameter (std::string key, std::string default_=std::string()) const |
| Returns the decode()d value of the named parameter, or a default value. More...
|
|
std::string | authorisation () const |
| Returns the "user:pwd" part.
|
|
std::string | anchor () const |
| Returns the "#anchor" part.
|
|
std::string | str () const |
| Returns the string representation. Returns "/" if default constructed.
|
|
std::string | summary () const |
| Returns a summary of the url for logging purposes, specifically excluding username/password but also excluding url parameters in case they also contains authentication secrets or tokens. More...
|
|
|
static std::string | decode (const std::string &) |
| Does url-decoding (rfc3986 2.1).
|
|
static std::string | encode (const std::string &, bool plus_for_space=true) |
| Does url-encoding.
|
|
static std::string | join (const std::string &protocol, const std::string &authorisation, const std::string &address, const std::string &path, const std::string ¶ms, const std::string &anchor=std::string()) |
| Returns a concatenation of the given url parts, with the correct separators inserted. More...
|
|
A simple parser for URLs.
Eg:
"protocol://user:pwd@host:port/path1/path2.ext?key1=/value%31&key2#anchor"
- See Also
- rfc3986
Definition at line 42 of file gurl.h.
std::string G::Url::address |
( |
| ) |
const |
Returns the address part, which might include the port, and which might use ipv6 square brackets.
Definition at line 196 of file gurl.cpp.
std::string G::Url::address |
( |
const std::string & |
default_port | ) |
const |
Returns the transport address formed from host() and port(default_port).
This never has ipv6 square brackets. Precondition: !default_port.empty()
Definition at line 201 of file gurl.cpp.
std::string G::Url::host |
( |
| ) |
const |
Returns the hostname or network address part.
Any square brackets used to delimit an ipv6 network address are not returned.
Definition at line 186 of file gurl.cpp.
std::string G::Url::join |
( |
const std::string & |
protocol, |
|
|
const std::string & |
authorisation, |
|
|
const std::string & |
address, |
|
|
const std::string & |
path, |
|
|
const std::string & |
params, |
|
|
const std::string & |
anchor = std::string() |
|
) |
| |
|
static |
Returns a concatenation of the given url parts, with the correct separators inserted.
Definition at line 43 of file gurl.cpp.
std::string G::Url::parameter |
( |
std::string |
key, |
|
|
std::string |
default_ = std::string() |
|
) |
| const |
Returns the decode()d value of the named parameter, or a default value.
Definition at line 213 of file gurl.cpp.
std::string G::Url::port |
( |
const std::string & |
default_ = std::string() | ) |
const |
Returns the port or service-name, or the specified default if none.
It is often appropriate to pass protocol() as the default.
Definition at line 191 of file gurl.cpp.
std::string G::Url::summary |
( |
| ) |
const |
Returns a summary of the url for logging purposes, specifically excluding username/password but also excluding url parameters in case they also contains authentication secrets or tokens.
Definition at line 73 of file gurl.cpp.
The documentation for this class was generated from the following files:
- /home/graeme/videotools/src/glib/gurl.h
- /home/graeme/videotools/src/glib/gurl.cpp