contents up previous next

wxurl

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.

derived from

wxuri
wxobject

include files

<wx/url.h>

see also

wxsocketbase, wxprotocol

members

wxurl::wxurl
wxurl::~wxurl
wxurl::getprotocol
wxurl::geterror
wxurl::getinputstream
wxurl::isok
wxurl::setdefaultproxy
wxurl::setproxy
wxurl::seturl


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 - i.e. a file url without a hostname must contain three consecutive slashes (e.g. file:///somepath/myfile).

parameters

url


wxurl::~wxurl

~wxurl()

destroys the url object.


wxurl::getprotocol

wxprotocol& getprotocol()

returns a reference to the protocol which will be used to get the url.


wxurl::geterror

wxurlerror geterror() const

returns the last error. this error refers to the url parsing or to the protocol. it can be one of these errors:

wxurl_noerr no error.
wxurl_sntxerr syntax error in the url string.
wxurl_noproto found no protocol which can get this url.
wxurl_nohost an host name is required for this protocol.
wxurl_nopath a path is required for this protocol.
wxurl_connerr connection error.
wxurl_protoerr an error occurred during negotiation.


wxurl::getinputstream

wxinputstream * 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 really 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)
  }
return value

returns the initialized stream. you will have to delete it yourself.

see also

wxinputstream


wxurl::isok

bool isok() const

returns true if this object is correctly initialized, i.e. if geterror returns wxurl_noerr.


wxurl::setdefaultproxy

static void setdefaultproxy(const wxstring& url_proxy)

sets the default proxy server to use to get the url. the string specifies the proxy like this: <hostname>:<port number>.

parameters

url_proxy

see also

wxurl::setproxy


wxurl::setproxy

void setproxy(const wxstring& url_proxy)

sets the proxy to use for this url.

see also

wxurl::setdefaultproxy


wxurl::seturl

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).