Version: 3.2.5
wxURL Class Reference

#include <wx/url.h>

+ Inheritance diagram for wxURL:

Detailed Description

wxURL is a specialization of wxURI for parsing URLs.

Please look at wxURI documentation for more info about the functions you can use to retrieve the various parts of the URL (scheme, server, port, etc).

Supports standard assignment operators, copy constructors, and comparison operators.

Library:  wxNet
Category:  Networking
See also
wxSocketBase, wxProtocol

Public Member Functions

 wxURL (const wxString &url=wxEmptyString)
 Constructs a URL object from the string. More...
 
virtual ~wxURL ()
 Destroys the URL object. More...
 
wxURLError GetError () const
 Returns the last error. More...
 
wxInputStreamGetInputStream ()
 Creates a new input stream on the specified URL. More...
 
wxProtocolGetProtocol ()
 Returns a reference to the protocol which will be used to get the URL. More...
 
bool IsOk () const
 Returns true if this object is correctly initialized, i.e. if GetError() returns wxURL_NOERR. More...
 
void SetProxy (const wxString &url_proxy)
 Sets the proxy to use for this URL. More...
 
wxURLError SetURL (const wxString &url)
 Initializes this object with the given URL and returns wxURL_NOERR if it's valid (see GetError() for more info). More...
 
- Public Member Functions inherited from wxURI
 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 wxStringGetFragment () 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 wxStringGetPath () const
 Returns the (normalized) path of the URI. More...
 
const wxStringGetPort () const
 Returns a string representation of the URI's port. More...
 
const wxStringGetQuery () const
 Returns the Query component of the URI. More...
 
const wxStringGetScheme () const
 Returns the Scheme component of the URI. More...
 
const wxStringGetServer () 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 wxStringGetUserInfo () 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 wxClassInfoGetClassInfo () const
 This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar). More...
 
wxObjectRefDataGetRefData () 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 void SetDefaultProxy (const wxString &url_proxy)
 Sets the default proxy server to use to get the URL. More...
 
- Static Public Member Functions inherited from wxURI
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 wxObjectRefDataCreateRefData () const
 Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. More...
 
virtual wxObjectRefDataCloneRefData (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
wxObjectRefDatam_refData
 Pointer to an object which is the object's reference-counted data. More...
 

Constructor & Destructor Documentation

◆ wxURL()

wxURL::wxURL ( const wxString url = wxEmptyString)

Constructs a URL object from the string.

The URL must be valid according to RFC 1738. In particular, file URLs must be of the format "file://hostname/path/to/file", otherwise GetError() will return a value different from wxURL_NOERR.

It is valid to leave out the hostname but slashes must remain in place, in other words, a file URL without a hostname must contain three consecutive slashes (e.g. "file:///somepath/myfile").

Parameters
urlUrl string to parse.

◆ ~wxURL()

virtual wxURL::~wxURL ( )
virtual

Destroys the URL object.

Member Function Documentation

◆ GetError()

wxURLError wxURL::GetError ( ) const

Returns the last error.

This error refers to the URL parsing or to the protocol. It can be one of wxURLError.

◆ GetInputStream()

wxInputStream* wxURL::GetInputStream ( )

Creates a new input stream on the specified URL.

You can use all but seek functionality of wxStream. Seek isn't available on all streams. For example, HTTP or FTP streams don't deal with it.

Note that this method is somewhat deprecated, all future wxWidgets applications should use wxFileSystem instead.

Example:

wxURL url("http://a.host/a.dir/a.file");
if (url.GetError() == wxURL_NOERR)
{
wxInputStream *in_stream;
in_stream = url.GetInputStream();
// Then, you can use all IO calls of in_stream (See wxStream)
}
wxInputStream is an abstract base class which may not be used directly.
Definition: stream.h:580
wxURL is a specialization of wxURI for parsing URLs.
Definition: url.h:37
@ wxURL_NOERR
No error.
Definition: url.h:12
Returns
Returns the initialized stream. You will have to delete it yourself.
See also
wxInputStream

◆ GetProtocol()

wxProtocol& wxURL::GetProtocol ( )

Returns a reference to the protocol which will be used to get the URL.

◆ IsOk()

bool wxURL::IsOk ( ) const

Returns true if this object is correctly initialized, i.e. if GetError() returns wxURL_NOERR.

◆ SetDefaultProxy()

static void wxURL::SetDefaultProxy ( const wxString url_proxy)
static

Sets the default proxy server to use to get the URL.

The string specifies the proxy like this: "<hostname>:<port number>".

Parameters
url_proxySpecifies the proxy to use.
See also
SetProxy()

◆ SetProxy()

void wxURL::SetProxy ( const wxString url_proxy)

Sets the proxy to use for this URL.

See also
SetDefaultProxy()

◆ SetURL()

wxURLError wxURL::SetURL ( const wxString url)

Initializes this object with the given URL and returns wxURL_NOERR if it's valid (see GetError() for more info).