wxWidgets: wxURI Class Reference

| Version: 3.0.5

Public Member Functions | Static Public Member Functions | List of all members
wxURI Class Reference
Class List by Category » Networking

`#include </home/Hamish/wxwidgets/wxWidgets3.0-3.0.5.1-1.src/wxWidgets3.0-3.0.5.1-1.i686/src/wxWidgets-3.0.5.1/interface/wx/uri.h>`

Inheritance diagram for wxURI:
[legend]

## Detailed Description

wxURI is used to extract information from a URI (Uniform Resource Identifier).

For information about URIs, see RFC 3986 (http://www.ietf.org/rfc/rfc3986.txt).

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 further functionality.

To obtain individual components you can use one of the GetXXX() methods. 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.

Example:

// protocol will hold the http protocol (i.e. "http")
wxString protocol;
wxURI myuri("http://mysite.com");
if( myuri.HasScheme() )
protocol = myuri.GetScheme();

Note
  On URIs with a "file" scheme wxURI does not parse the userinfo, server, or port portion. This is to keep compatibility with wxFileSystem, the old wxURL, and older url specifications.

##

Library: wxBase

<>< =''>:</>&;&;< =''>\ </></>

See also
  wxURL

## Public Member Functions
| wxURI ()
| Creates an empty URI. More...
| wxURI (const wxString &uri)
| Constructor for quick creation. More...
| wxURI (const wxURI &uri)
| Copies this URI from another URI. More...
wxString | BuildURI () const
| Builds the URI from its individual components and adds proper separators. More...
wxString | BuildUnescapedURI () const
| Builds the URI from its individual components, adds proper separators, and returns escape sequences to normal characters. More...
bool | Create (const wxString &uri)
| Creates this URI from the uri string. More...
const wxString & | GetFragment () const
| Obtains the fragment of this URI. More...
wxURIHostType | GetHostType () const
| Obtains the host type of this URI, which is one of wxURIHostType. More...
wxString | GetPassword () const
| Returns the password part of the userinfo component of this URI. More...
const wxString & | GetPath () const
| Returns the (normalized) path of the URI. More...
const wxString & | GetPort () const
| Returns a string representation of the URI's port. More...
const wxString & | GetQuery () const
| Returns the Query component of the URI. More...
const wxString & | GetScheme () const
| Returns the Scheme component of the URI. More...
const wxString & | GetServer () const
| Returns the Server component of the URI. More...
wxString | GetUser () const
| Returns the username part of the userinfo component of this URI. More...
const wxString & | GetUserInfo () const
| Returns the UserInfo component of the URI. More...
bool | HasFragment () const
| Returns true if the Fragment component of the URI exists. More...
bool | HasPath () const
| Returns true if the Path component of the URI exists. More...
bool | HasPort () const
| Returns true if the Port component of the URI exists. More...
bool | HasQuery () const
| Returns true if the Query component of the URI exists. More...
bool | HasScheme () const
| Returns true if the Scheme component of the URI exists. More...
bool | HasServer () const
| Returns true if the Server component of the URI exists. More...
bool | HasUserInfo () const
| Returns true if the User component of the URI exists. More...
bool | IsReference () const
| Returns true if a valid [absolute] URI, otherwise this URI is a URI reference and not a full URI, and this function returns false. More...
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. More...
bool | operator== (const wxURI &uricomp) const
| Compares this URI to another URI, and returns true if this URI equals uricomp, otherwise it returns false. More...
Public Member Functions inherited from wxObject
| wxObject ()
| Default ctor; initializes to NULL the internal reference data. More...
| wxObject (const wxObject &other)
| Copy ctor. More...
virtual | ~wxObject ()
| Destructor. More...
virtual wxClassInfo * | GetClassInfo () const
| This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar). More...
wxObjectRefData * | GetRefData () const
| Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. More...
bool | IsKindOf (const wxClassInfo *info) const
| Determines whether this class is a subclass of (or the same class as) the given class. More...
bool | IsSameAs (const wxObject &obj) const
| Returns true if this object has the same data pointer as obj. More...
void | Ref (const wxObject &clone)
| Makes this object refer to the data in clone. More...
void | SetRefData (wxObjectRefData *data)
| Sets the wxObject::m_refData pointer. More...
void | UnRef ()
| Decrements the reference count in the associated data, and if it is zero, deletes the data. More...
void | UnShare ()
| This is the same of AllocExclusive() but this method is public. More...
void | operator delete (void *buf)
| The delete operator is defined for debugging versions of the library only, when the identifier `WXDEBUG` is defined. More...
void * | operator new (size_t size, const wxString &filename=NULL, int lineNum=0)
| The new operator is defined for debugging versions of the library only, when the identifier `WXDEBUG` is defined. More...

## Static Public Member Functions
static wxString | Unescape (const wxString &uri)
| Translates all escape sequences (normal characters and returns the result. More...

## Additional Inherited Members
Protected Member Functions inherited from wxObject
void | AllocExclusive ()
| Ensure that this object's data is not shared with any other object. More...
virtual wxObjectRefData * | CreateRefData () const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. More...
virtual wxObjectRefData * | CloneRefData (const wxObjectRefData *data) const
| Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data. More...
Protected Attributes inherited from wxObject
wxObjectRefData * | m_refData
| Pointer to an object which is the object's reference-counted data. More...

## Constructor & Destructor Documentation

## ◆ wxURI() [1/3]

wxURI::wxURI | ( |  | ) |

Creates an empty URI.

## ◆ wxURI() [2/3]

wxURI::wxURI | ( | const wxString & | uri | ) |

Constructor for quick creation.

Parameters

  uri | URI (Uniform Resource Identifier) to initialize with.

## ◆ wxURI() [3/3]

wxURI::wxURI | ( | const wxURI & | uri | ) |

Copies this URI from another URI.

Parameters

  uri | URI (Uniform Resource Identifier) to initialize with.

## Member Function Documentation

## ◆ BuildUnescapedURI()

wxString wxURI::BuildUnescapedURI | ( |  | ) | const

Builds the URI from its individual components, adds proper separators, and returns escape sequences to normal characters.

Note
  It is preferred to call this over Unescape(BuildURI()) since BuildUnescapedURI() performs some optimizations over the plain method.

## ◆ BuildURI()

wxString wxURI::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 is the same one passed to the constructor or Create().

## ◆ Create()

bool wxURI::Create | ( | const wxString & | uri | ) |

Creates this URI from the uri string.

Returns true if this instance was correctly initialized.

Parameters

  uri | String to initialize from.

## ◆ GetFragment()

const wxString& wxURI::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>"`

## ◆ GetHostType()

wxURIHostType wxURI::GetHostType | ( |  | ) | const

Obtains the host type of this URI, which is one of wxURIHostType.

## ◆ GetPassword()

wxString wxURI::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"`

## ◆ GetPath()

const wxString& wxURI::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>"`

## ◆ GetPort()

const wxString& wxURI::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
  You can easily get the numeric value of the port by using wxAtoi() or wxString::Format().

## ◆ GetQuery()

const wxString& wxURI::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>"`

## ◆ GetScheme()

const wxString& wxURI::GetScheme | ( |  | ) | const

Returns the Scheme component of the URI.

The first part of the URI.

`"<scheme>://mysite.com"`

## ◆ GetServer()

const wxString& wxURI::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"`

## ◆ GetUser()

wxString wxURI::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"`

## ◆ GetUserInfo()

const wxString& wxURI::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"`

## ◆ HasFragment()

bool wxURI::HasFragment | ( |  | ) | const

Returns true if the Fragment component of the URI exists.

## ◆ HasPath()

bool wxURI::HasPath | ( |  | ) | const

Returns true if the Path component of the URI exists.

## ◆ HasPort()

bool wxURI::HasPort | ( |  | ) | const

Returns true if the Port component of the URI exists.

## ◆ HasQuery()

bool wxURI::HasQuery | ( |  | ) | const

Returns true if the Query component of the URI exists.

## ◆ HasScheme()

bool wxURI::HasScheme | ( |  | ) | const

Returns true if the Scheme component of the URI exists.

## ◆ HasServer()

bool wxURI::HasServer | ( |  | ) | const

Returns true if the Server component of the URI exists.

## ◆ HasUserInfo()

bool wxURI::HasUserInfo | ( |  | ) | const

Returns true if the User component of the URI exists.

## ◆ IsReference()

bool wxURI::IsReference | ( |  | ) | const

Returns true if a valid [absolute] URI, otherwise this URI is a URI reference and not a full URI, and this function returns false.

## ◆ operator==()

bool wxURI::operator== | ( | const wxURI & | uricomp | ) | const

Compares this URI to another URI, and returns true if this URI equals uricomp, otherwise it returns false.

Parameters

  uricomp | URI to compare to.

## ◆ Resolve()

void wxURI::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".

Parameters

  base | Base URI to inherit from. Must be a full URI and not a reference.
  flags | Currently either wxURI_STRICT or 0, in non-strict mode some compatibility layers are enabled to allow loopholes from RFCs prior to 2396.

## ◆ Unescape()

static wxString wxURI::Unescape | ( | const wxString & | uri | ) |
| static

Translates all escape sequences (normal characters and returns the result.

If you want to unescape an entire wxURI, use BuildUnescapedURI() instead, as it performs some optimizations over this method.

Parameters

  uri | String with escaped characters to convert.

wxString
String class for passing textual data to or receiving it from wxWidgets.
Definition: string.h:314
wxURI
wxURI is used to extract information from a URI (Uniform Resource Identifier).
Definition: uri.h:60