]> git.saurik.com Git - wxWidgets.git/blame - interface/url.h
Replaced @returns with @return for more standard command use and compatibility.
[wxWidgets.git] / interface / url.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: url.h
e54c96f1 3// Purpose: interface of wxURL
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
fbec75d0
BP
9/**
10 Error types returned from wxURL::GetError().
11*/
12typedef enum {
13 wxURL_NOERR = 0, ///< No error.
14 wxURL_SNTXERR, ///< Syntax error in the URL string.
15 wxURL_NOPROTO, ///< Found no protocol which can get this URL.
16 wxURL_NOHOST, ///< A host name is required for this protocol.
17 wxURL_NOPATH, ///< A path is required for this protocol.
18 wxURL_CONNERR, ///< Connection error.
19 wxURL_PROTOERR ///< An error occurred during negotiation.
20} wxURLError;
21
23324ae1
FM
22/**
23 @class wxURL
24 @wxheader{url.h}
7c913512 25
fbec75d0
BP
26 wxURL is a specialization of wxURI for parsing URLs. Please look at wxURI
27 documentation for more info about the functions you can use to retrieve the
28 various parts of the URL (scheme, server, port, etc).
7c913512 29
fbec75d0
BP
30 Supports standard assignment operators, copy constructors, and comparison
31 operators.
7c913512 32
23324ae1
FM
33 @library{wxnet}
34 @category{net}
7c913512 35
e54c96f1 36 @see wxSocketBase, wxProtocol
23324ae1
FM
37*/
38class wxURL : public wxURI
39{
40public:
41 /**
fbec75d0
BP
42 Constructs a URL object from the string. The URL must be valid
43 according to RFC 1738. In particular, file URLs must be of the format
44 @c "file://hostname/path/to/file", otherwise GetError() will return a
45 value different from ::wxURL_NOERR.
46
47 It is valid to leave out the hostname but slashes must remain in place,
48 in other words, a file URL without a hostname must contain three
49 consecutive slashes (e.g. @c "file:///somepath/myfile").
3c4f71cc 50
7c913512 51 @param url
4cc4bfaf 52 Url string to parse.
23324ae1 53 */
4cc4bfaf 54 wxURL(const wxString& url = wxEmptyString);
23324ae1
FM
55
56 /**
57 Destroys the URL object.
58 */
4cc4bfaf 59 ~wxURL();
23324ae1
FM
60
61 /**
fbec75d0
BP
62 Returns the last error. This error refers to the URL parsing or to the
63 protocol. It can be one of ::wxURLError.
23324ae1 64 */
328f5751 65 wxURLError GetError() const;
23324ae1
FM
66
67 /**
fbec75d0
BP
68 Creates a new input stream on the specified URL. You can use all but
69 seek functionality of wxStream. Seek isn't available on all streams.
70 For example, HTTP or FTP streams don't deal with it.
71
72 Note that this method is somewhat deprecated, all future wxWidgets
73 applications should use wxFileSystem instead.
74
23324ae1 75 Example:
3c4f71cc 76
fbec75d0
BP
77 @code
78 wxURL url("http://a.host/a.dir/a.file");
79 if (url.GetError() == wxURL_NOERR)
80 {
81 wxInputStream *in_stream;
82
83 in_stream = url.GetInputStream();
84 // Then, you can use all IO calls of in_stream (See wxStream)
85 }
86 @endcode
87
d29a9a8a 88 @return Returns the initialized stream. You will have to delete it
4cc4bfaf 89 yourself.
3c4f71cc 90
4cc4bfaf 91 @see wxInputStream
23324ae1 92 */
4cc4bfaf 93 wxInputStream* GetInputStream();
23324ae1
FM
94
95 /**
96 Returns a reference to the protocol which will be used to get the URL.
97 */
98 wxProtocol GetProtocol();
99
100 /**
7c913512 101 Returns @true if this object is correctly initialized, i.e. if
fbec75d0 102 GetError() returns ::wxURL_NOERR.
23324ae1 103 */
328f5751 104 bool IsOk() const;
23324ae1
FM
105
106 /**
fbec75d0
BP
107 Sets the default proxy server to use to get the URL. The string
108 specifies the proxy like this: @c "<hostname>:<port number>".
3c4f71cc 109
7c913512 110 @param url_proxy
fbec75d0 111 Specifies the proxy to use.
3c4f71cc 112
4cc4bfaf 113 @see SetProxy()
23324ae1
FM
114 */
115 static void SetDefaultProxy(const wxString& url_proxy);
116
117 /**
118 Sets the proxy to use for this URL.
3c4f71cc 119
4cc4bfaf 120 @see SetDefaultProxy()
23324ae1
FM
121 */
122 void SetProxy(const wxString& url_proxy);
123
124 /**
fbec75d0
BP
125 Initializes this object with the given URL and returns ::wxURL_NOERR if
126 it's valid (see GetError() for more info).
23324ae1 127 */
4cc4bfaf 128 wxURLError SetURL(const wxString& url);
23324ae1 129};
e54c96f1 130