]> git.saurik.com Git - wxWidgets.git/blob - interface/url.h
Compilation fixes for mingw-w64.
[wxWidgets.git] / interface / url.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: url.h
3 // Purpose: interface of wxURL
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
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
22 /**
23 @class wxURL
24 @wxheader{url.h}
25
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).
29
30 Supports standard assignment operators, copy constructors, and comparison
31 operators.
32
33 @library{wxnet}
34 @category{net}
35
36 @see wxSocketBase, wxProtocol
37 */
38 class wxURL : public wxURI
39 {
40 public:
41 /**
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").
50
51 @param url
52 Url string to parse.
53 */
54 wxURL(const wxString& url = wxEmptyString);
55
56 /**
57 Destroys the URL object.
58 */
59 ~wxURL();
60
61 /**
62 Returns the last error. This error refers to the URL parsing or to the
63 protocol. It can be one of ::wxURLError.
64 */
65 wxURLError GetError() const;
66
67 /**
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
75 Example:
76
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
88 @return Returns the initialized stream. You will have to delete it
89 yourself.
90
91 @see wxInputStream
92 */
93 wxInputStream* GetInputStream();
94
95 /**
96 Returns a reference to the protocol which will be used to get the URL.
97 */
98 wxProtocol GetProtocol();
99
100 /**
101 Returns @true if this object is correctly initialized, i.e. if
102 GetError() returns ::wxURL_NOERR.
103 */
104 bool IsOk() const;
105
106 /**
107 Sets the default proxy server to use to get the URL. The string
108 specifies the proxy like this: @c "<hostname>:<port number>".
109
110 @param url_proxy
111 Specifies the proxy to use.
112
113 @see SetProxy()
114 */
115 static void SetDefaultProxy(const wxString& url_proxy);
116
117 /**
118 Sets the proxy to use for this URL.
119
120 @see SetDefaultProxy()
121 */
122 void SetProxy(const wxString& url_proxy);
123
124 /**
125 Initializes this object with the given URL and returns ::wxURL_NOERR if
126 it's valid (see GetError() for more info).
127 */
128 wxURLError SetURL(const wxString& url);
129 };
130