45 typedef std::multimap<std::string,std::string> Map ;
50 explicit Url(
const std::string & ) ;
60 std::string
address(
const std::string & default_port )
const ;
65 std::string
host()
const ;
70 std::string
port(
const std::string & default_ = std::string() )
const ;
75 std::string
path()
const ;
87 bool has(
const std::string & key )
const ;
90 std::string
parameter( std::string key , std::string default_ = std::string() )
const ;
97 std::string
anchor()
const ;
100 std::string
str()
const ;
108 static std::string
decode(
const std::string & ) ;
111 static std::string
encode(
const std::string & ,
bool plus_for_space =
true ) ;
114 static std::string
join(
const std::string & protocol ,
const std::string & authorisation ,
115 const std::string & address ,
const std::string & path ,
const std::string & params ,
116 const std::string & anchor = std::string() ) ;
121 void init( std::string ) ;
122 static size_t colonpos(
const std::string & ) ;
123 static bool ipv6(
const std::string & ) ;
126 std::string m_protocol ;
127 std::string m_authorisation ;
128 std::string m_address ;
132 std::string m_params ;
133 std::string m_anchor ;
std::string port(const std::string &default_=std::string()) const
Returns the port or service-name, or the specified default if none.
std::string host() const
Returns the hostname or network address part.
static std::string decode(const std::string &)
Does url-decoding (rfc3986 2.1).
A simple parser for URLs.
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.
std::string request() const
Returns the path and parameters, suitable for a GET request.
std::string path() const
Returns the path part, including the leading slash.
bool has(const std::string &key) const
Returns true if the named parameter is present.
std::string parameters() const
Returns the parameters string.
std::string str() const
Returns the string representation. Returns "/" if default constructed.
Url()
Default constructor for a url with a path of "/".
Map pmap() const
Returns the decode()d parameters as a multimap.
std::string protocol() const
Returns the protocol part eg. "http".
std::string authorisation() const
Returns the "user:pwd" part.
static std::string encode(const std::string &, bool plus_for_space=true)
Does url-encoding.
std::string summary() const
Returns a summary of the url for logging purposes, specifically excluding username/password but also ...
std::string anchor() const
Returns the "#anchor" part.
std::string address() const
Returns the address part, which might include the port, and which might use ipv6 square brackets...
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.