$szTitle = "wxuri"; include "./_header.inc"; ?>
wxuri is used to extract information from a uri (uniform resource identifier).
for information about uris, see rfc 3986.
in short, a url is a uri. in other words, url is a subset of a uri - all acceptable urls are also acceptable uris.
wxuri automatically escapes invalid characters in a string, so there is no chance of wxuri "failing" on construction/creation.
wxuri supports copy construction and standard assignment operators. wxuri can also be inherited from to provide furthur functionality.
derived from
include files
<wx/uri.h>
see also
members
obtaining individual components
deviations from the rfc
wxuri::wxuri
wxuri::builduri
wxuri::buildunescapeduri
wxuri::create
wxuri::getfragment
wxuri::gethosttype
wxuri::getpassword
wxuri::getpath
wxuri::getport
wxuri::getquery
wxuri::getscheme
wxuri::getserver
wxuri::getuser
wxuri::getuserinfo
wxuri::hasfragment
wxuri::haspath
wxuri::hasport
wxuri::hasquery
wxuri::hasscheme
wxuri::hasserver
wxuri::hasuser
wxuri::isreference
wxuri::operator ==
wxuri::resolve
wxuri::unescape
to obtain individual components you can use one of the following methods
getscheme
getuserinfo
getserver
getport
getpath
getquery
getfragment
however, you should check hasxxx before calling a get method, which determines whether or not the component referred to by the method is defined according to rfc 2396.
consider an undefined component equivalent to a
null c string.
hasscheme
hasuserinfo
hasserver
hasport
haspath
hasquery
hasfragment
example:
//protocol will hold the http protocol (i.e. "http") wxstring protocol; wxuri myuri(wxt("http://mysite.com")); if(myuri.hasscheme()) protocol = myuri.getscheme();
note that on uris with a "file" scheme wxuri does not parse the userinfo, server, or port portion. this is to keep compatability with wxfilesystem, the old wxurl, and older url specifications.
wxuri()
creates an empty uri.
wxuri(const wxchar* uri)
constructor for quick creation.
uri
wxuri(const wxuri& uri)
copies this uri from another uri.
uri
wxstring builduri() const
builds the uri from its individual components and adds proper separators.
if the uri is not a reference or is not resolved, the uri that is returned from get is the same one passed to create.
wxstring buildunescapeduri() const
builds the uri from its individual components, adds proper separators, and returns escape sequences to normal characters.
note that it is preferred to call this over unescape(builduri()) since buildunescapeduri performs some optimizations over the plain method.
const wxchar* create(const wxstringuri)
creates this uri from the string uri.
returns the position at which parsing stopped (there is no such thing as an "invalid" wxuri).
uri
const wxstring getfragment() const
obtains the fragment of this uri.
the fragment of a uri is the last value of the uri, and is the value after a '' character after the path of the uri.
http://mysite.com/mypath#<fragment>
const hosttype& gethosttype() const
obtains the host type of this uri, which is of type wxuri::hosttype:
wxuri_regname | server is a host name, or the server component itself is undefined. |
wxuri_ipv4address | server is a ip version 4 address (xxx.xxx.xxx.xxx) |
wxuri_ipv6address | server is a ip version 6 address ((xxx:)xxx::(xxx)xxx:xxx |
wxuri_ipvfuture | server is an ip address, but not versions 4 or 6 |
const wxstring getpassword() const
returns the password part of the userinfo component of this uri. note that this is explicitly depreciated by rfc 1396 and should generally be avoided if possible.
http://<user>:<password>@mysite.com/mypath
const wxstring getpath() const
returns the (normalized) path of the uri.
the path component of a uri comes directly after the scheme component if followed by zero or one slashes ('/'), or after the server/port component.
absolute paths include the leading '/' character.
http://mysite.com<path>
const wxstring getport() const
returns a string representation of the uri's port.
the port of a uri is a value after the server, and must come after a colon (:).
http://mysite.com:<port>
note that you can easily get the numeric value of the port by using wxatoi or wxstring::format.
const wxstring getquery() const
returns the query component of the uri.
the query component is what is commonly passed to a cgi application, and must come after the path component, and after a '?' character.
http://mysite.com/mypath?<query>
const wxstring getscheme() const
returns the scheme component of the uri.
the first part of the uri.
<scheme>://mysite.com
const wxstring getserver() const
returns the server component of the uri.
the server of the uri can be a server name or a type of ip address. see gethosttype for the possible values for the host type of the server component.
http://<server>/mypath
const wxstring getuser() const
returns the username part of the userinfo component of this uri. note that this is explicitly depreciated by rfc 1396 and should generally be avoided if possible.
http://<user>:<password>@mysite.com/mypath
const wxstring getuserinfo() const
returns the userinfo component of the uri.
the component of a uri before the server component that is postfixed by a '@' character.
http://<userinfo>@mysite.com/mypath
bool hasfragment() const
returns true if the fragment component of the uri exists.
bool haspath() const
returns true if the path component of the uri exists.
bool hasport() const
returns true if the port component of the uri exists.
bool hasquery() const
returns true if the query component of the uri exists.
bool hasscheme() const
returns true if the scheme component of the uri exists.
bool hasserver() const
returns true if the server component of the uri exists.
bool hasuser() const
returns true if the user component of the uri exists.
bool isreference() const
returns true if a valid [absolute] uri, otherwise this uri is a uri reference and not a full uri, and isreference returns false.
void operator ==(const wxuri& uricomp)
compares this uri to another uri, and returns true if this uri equals uricomp, otherwise it returns false.
uricomp
void resolve(const wxuri& base, int flags = wxuri_strict)
inherits this uri from a base uri - components that do not exist in this uri are copied from the base, and if this uri's path is not an absolute path (prefixed by a '/'), then this uri's path is merged with the base's path.
for instance, resolving "../mydir" from "http://mysite.com/john/doe" results in the scheme (http) and server (mysite.com) being copied into this uri, since they do not exist. in addition, since the path of this uri is not absolute (does not begin with '/'), the path of the base's is merged with this uri's path, resulting in the uri "http://mysite.com/john/mydir".
base
wxstring unescape(const wxstring& uri)
translates all escape sequences (normal characters and returns the result.
this is the preferred over deprecated wxurl::convertfromuri.
if you want to unescape an entire wxuri, use buildunescapeduri instead, as it performs some optimizations over this method.
uri
include "./_footer.inc"; ?>