# wxURL Class Reference
[Networking]

`#include </home/work/projects/wx/2.9/wx/interface/wx/url.h>`

Inheritance diagram for wxURL:
[legend]

## 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.
virtual | ~wxURL ()
| Destroys the URL object.
wxURLError | GetError () const
| Returns the last error.
wxInputStream * | GetInputStream ()
| Creates a new input stream on the specified URL.
wxProtocol & | GetProtocol ()
| Returns a reference to the protocol which will be used to get the URL.
bool | IsOk () const
| Returns true if this object is correctly initialized, i.e.
void | SetProxy (const wxString &url_proxy)
| Sets the proxy to use for this URL.
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).

## Static Public Member Functions

static void | SetDefaultProxy (const wxString &url_proxy)
| Sets the default proxy server to use to get the URL.

List of all members.

## Constructor & Destructor Documentation

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:

  | url | Url string to parse.

virtual wxURL::~wxURL | ( |  | ) | `[virtual]`

Destroys the URL object.

## Member Function Documentation

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.

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

Returns:
  Returns the initialized stream. You will have to delete it yourself.

See also:
  wxInputStream

wxProtocol& wxURL::GetProtocol | ( |  | ) |

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

bool wxURL::IsOk | ( |  | ) | const

Returns true if this object is correctly initialized, i.e.

if GetError() returns wxURL_NOERR.

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_proxy | Specifies the proxy to use.

See also:
  SetProxy()

void wxURL::SetProxy | ( | const wxString & | url_proxy | ) |

Sets the proxy to use for this URL.

See also:
  SetDefaultProxy()

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

|  | [ top ]