]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/uri.h
Fix typo in wxOwnerDrawnComboBox ctor documentation.
[wxWidgets.git] / interface / wx / uri.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: uri.h
e54c96f1 3// Purpose: interface of wxURI
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
fbec75d0
BP
9/**
10 Host type of URI returned from wxURI::GetHostType().
11*/
12enum wxURIHostType
13{
14 wxURI_REGNAME, ///< Host is a normal register name (@c "www.mysite.com").
15 wxURI_IPV4ADDRESS, ///< Host is a version 4 ip address (@c "192.168.1.100").
16 wxURI_IPV6ADDRESS, ///< Host is a version 6 ip address (@c "[aa:aa:aa:aa::aa:aa]:5050").
17 wxURI_IPVFUTURE ///< Host is a future ip address, wxURI is unsure what kind.
18};
19
23324ae1
FM
20/**
21 @class wxURI
7c913512 22
dc1b07fd 23 wxURI is used to extract information from a URI (Uniform Resource Identifier).
7c913512 24
dc1b07fd 25 For information about URIs, see RFC 3986 (http://www.ietf.org/rfc/rfc3986.txt).
7c913512 26
fbec75d0 27 In short, a URL is a URI. In other words, URL is a subset of a URI - all
23324ae1 28 acceptable URLs are also acceptable URIs.
7c913512 29
fbec75d0
BP
30 wxURI automatically escapes invalid characters in a string, so there is no
31 chance of wxURI "failing" on construction/creation.
32
33 wxURI supports copy construction and standard assignment operators. wxURI
fa68bafb 34 can also be inherited from to provide further functionality.
fbec75d0
BP
35
36 To obtain individual components you can use one of the GetXXX() methods.
37 However, you should check HasXXX() before calling a get method, which
38 determines whether or not the component referred to by the method is
39 defined according to RFC 2396. Consider an undefined component equivalent
40 to a @NULL C string.
41
42 Example:
fbec75d0 43 @code
dc1b07fd
FM
44 // protocol will hold the http protocol (i.e. "http")
45 wxString protocol;
46 wxURI myuri("http://mysite.com");
47 if( myuri.HasScheme() )
48 protocol = myuri.GetScheme();
fbec75d0 49 @endcode
7c913512 50
fbec75d0
BP
51 @note On URIs with a "file" scheme wxURI does not parse the userinfo,
52 server, or port portion. This is to keep compatability with
53 wxFileSystem, the old wxURL, and older url specifications.
7c913512 54
23324ae1 55 @library{wxbase}
ea2a647d 56 @category{net}
7c913512 57
e54c96f1 58 @see wxURL
23324ae1
FM
59*/
60class wxURI : public wxObject
61{
62public:
23324ae1 63 /**
fbec75d0
BP
64 Creates an empty URI.
65 */
66 wxURI();
cfbe5614 67
fbec75d0
BP
68 /**
69 Constructor for quick creation.
3c4f71cc 70
7c913512 71 @param uri
fbec75d0 72 URI (Uniform Resource Identifier) to initialize with.
23324ae1 73 */
cfbe5614
FM
74 wxURI(const wxString& uri);
75
fbec75d0
BP
76 /**
77 Copies this URI from another URI.
78
79 @param uri
80 URI (Uniform Resource Identifier) to initialize with.
81 */
7c913512 82 wxURI(const wxURI& uri);
23324ae1
FM
83
84 /**
fbec75d0
BP
85 Builds the URI from its individual components and adds proper
86 separators.
87
88 If the URI is not a reference or is not resolved, the URI that is
89 returned is the same one passed to the constructor or Create().
23324ae1 90 */
328f5751 91 wxString BuildURI() const;
23324ae1
FM
92
93 /**
fbec75d0
BP
94 Builds the URI from its individual components, adds proper separators,
95 and returns escape sequences to normal characters.
96
97 @note It is preferred to call this over Unescape(BuildURI()) since
98 BuildUnescapedURI() performs some optimizations over the plain
99 method.
23324ae1 100 */
328f5751 101 wxString BuildUnescapedURI() const;
23324ae1
FM
102
103 /**
fbec75d0 104 Creates this URI from the @a uri string.
3c4f71cc 105
cfbe5614 106 Returns @true if this instance was correctly initialized.
3c4f71cc 107
fbec75d0
BP
108 @param uri
109 String to initialize from.
23324ae1 110 */
cfbe5614 111 bool Create(const wxString& uri);
23324ae1
FM
112
113 /**
fbec75d0 114 Obtains the fragment of this URI.
23324ae1 115
fbec75d0
BP
116 The fragment of a URI is the last value of the URI, and is the value
117 after a "#" character after the path of the URI.
23324ae1 118
fbec75d0 119 @c "http://mysite.com/mypath#<fragment>"
23324ae1 120 */
fbec75d0 121 const wxString& GetFragment() const;
23324ae1
FM
122
123 /**
fbec75d0 124 Obtains the host type of this URI, which is one of wxURIHostType.
23324ae1 125 */
cfbe5614 126 wxURIHostType GetHostType() const;
23324ae1
FM
127
128 /**
fbec75d0
BP
129 Returns the password part of the userinfo component of this URI. Note
130 that this is explicitly depreciated by RFC 1396 and should generally be
131 avoided if possible.
132
133 @c "http://<user>:<password>@mysite.com/mypath"
23324ae1 134 */
cfbe5614 135 wxString GetPassword() const;
23324ae1
FM
136
137 /**
138 Returns the (normalized) path of the URI.
fbec75d0
BP
139
140 The path component of a URI comes directly after the scheme component
141 if followed by zero or one slashes ('/'), or after the server/port
142 component.
143
144 Absolute paths include the leading '/' character.
145
146 @c "http://mysite.com<path>"
23324ae1 147 */
fbec75d0 148 const wxString& GetPath() const;
23324ae1
FM
149
150 /**
151 Returns a string representation of the URI's port.
fbec75d0
BP
152
153 The Port of a URI is a value after the server, and must come after a
154 colon (:).
155
156 @c "http://mysite.com:<port>"
157
158 @note You can easily get the numeric value of the port by using
159 wxAtoi() or wxString::Format().
23324ae1 160 */
fbec75d0 161 const wxString& GetPort() const;
23324ae1
FM
162
163 /**
164 Returns the Query component of the URI.
fbec75d0
BP
165
166 The query component is what is commonly passed to a cgi application,
167 and must come after the path component, and after a '?' character.
168
169 @c "http://mysite.com/mypath?<query>"
23324ae1 170 */
fbec75d0 171 const wxString& GetQuery() const;
23324ae1
FM
172
173 /**
174 Returns the Scheme component of the URI.
fbec75d0
BP
175
176 The first part of the URI.
177
178 @c "<scheme>://mysite.com"
23324ae1 179 */
fbec75d0 180 const wxString& GetScheme() const;
23324ae1
FM
181
182 /**
183 Returns the Server component of the URI.
fbec75d0
BP
184
185 The server of the URI can be a server name or a type of IP address. See
186 GetHostType() for the possible values for the host type of the server
187 component.
188
189 @c "http://<server>/mypath"
23324ae1 190 */
fbec75d0 191 const wxString& GetServer() const;
23324ae1
FM
192
193 /**
fbec75d0
BP
194 Returns the username part of the userinfo component of this URI. Note
195 that this is explicitly depreciated by RFC 1396 and should generally be
196 avoided if possible.
197
198 @c "http://<user>:<password>@mysite.com/mypath"
23324ae1 199 */
cfbe5614 200 wxString GetUser() const;
23324ae1
FM
201
202 /**
203 Returns the UserInfo component of the URI.
fbec75d0
BP
204
205 The component of a URI before the server component that is postfixed by
206 a '@' character.
207
208 @c "http://<userinfo>@mysite.com/mypath"
23324ae1 209 */
fbec75d0 210 const wxString& GetUserInfo() const;
23324ae1
FM
211
212 /**
213 Returns @true if the Fragment component of the URI exists.
214 */
328f5751 215 bool HasFragment() const;
23324ae1
FM
216
217 /**
218 Returns @true if the Path component of the URI exists.
219 */
328f5751 220 bool HasPath() const;
23324ae1
FM
221
222 /**
223 Returns @true if the Port component of the URI exists.
224 */
328f5751 225 bool HasPort() const;
23324ae1
FM
226
227 /**
228 Returns @true if the Query component of the URI exists.
229 */
328f5751 230 bool HasQuery() const;
23324ae1
FM
231
232 /**
233 Returns @true if the Scheme component of the URI exists.
234 */
328f5751 235 bool HasScheme() const;
23324ae1
FM
236
237 /**
238 Returns @true if the Server component of the URI exists.
239 */
328f5751 240 bool HasServer() const;
23324ae1
FM
241
242 /**
243 Returns @true if the User component of the URI exists.
244 */
328f5751 245 bool HasUser() const;
23324ae1
FM
246
247 /**
fbec75d0
BP
248 Returns @true if a valid [absolute] URI, otherwise this URI is a URI
249 reference and not a full URI, and this function returns @false.
23324ae1 250 */
328f5751 251 bool IsReference() const;
23324ae1
FM
252
253 /**
fbec75d0
BP
254 Inherits this URI from a base URI - components that do not exist in
255 this URI are copied from the base, and if this URI's path is not an
256 absolute path (prefixed by a '/'), then this URI's path is merged with
257 the base's path.
3c4f71cc 258
7c913512 259 For instance, resolving "../mydir" from "http://mysite.com/john/doe"
fbec75d0
BP
260 results in the scheme (http) and server ("mysite.com") being copied
261 into this URI, since they do not exist. In addition, since the path of
262 this URI is not absolute (does not begin with '/'), the path of the
263 base's is merged with this URI's path, resulting in the URI
23324ae1 264 "http://mysite.com/john/mydir".
3c4f71cc 265
7c913512 266 @param base
fbec75d0 267 Base URI to inherit from. Must be a full URI and not a reference.
7c913512 268 @param flags
fbec75d0
BP
269 Currently either wxURI_STRICT or 0, in non-strict mode some
270 compatibility layers are enabled to allow loopholes from RFCs prior
271 to 2396.
23324ae1
FM
272 */
273 void Resolve(const wxURI& base, int flags = wxURI_STRICT);
274
275 /**
dc1b07fd 276 Translates all escape sequences (normal characters and returns the result.
fbec75d0
BP
277
278 If you want to unescape an entire wxURI, use BuildUnescapedURI()
279 instead, as it performs some optimizations over this method.
3c4f71cc 280
7c913512 281 @param uri
fbec75d0 282 String with escaped characters to convert.
23324ae1 283 */
adaaa686 284 static wxString Unescape(const wxString& uri);
23324ae1
FM
285
286 /**
fbec75d0
BP
287 Compares this URI to another URI, and returns @true if this URI equals
288 @a uricomp, otherwise it returns @false.
3c4f71cc 289
fbec75d0
BP
290 @param uricomp
291 URI to compare to.
23324ae1 292 */
cfbe5614 293 bool operator==(const wxURI& uricomp) const;
23324ae1 294};
e54c96f1 295