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