]>
Commit | Line | Data |
---|---|---|
dd65d8c8 RN |
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2 | %% Name: uri.tex | |
3 | %% Purpose: wxURI docs | |
4 | %% Author: Ryan Norton <wxprojects@comcast.net> | |
5 | %% Modified by: | |
6 | %% Created: 7/7/2004 | |
7 | %% RCS-ID: $Id$ | |
8 | %% Copyright: (c) Ryan Norton | |
9 | %% License: wxWindows license | |
10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
11 | ||
12 | \section{\class{wxURI}}\label{wxuri} | |
13 | ||
14 | wxURI is used to extract information from | |
15 | a URI (Uniform Resource Identifier). | |
16 | ||
17 | For information about URIs, see | |
4cc52142 | 18 | \urlref{RFC 3986}{http://www.ietf.org/rfc/rfc3986.txt}. |
dd65d8c8 RN |
19 | |
20 | In short, a URL \em{is} a URI. In other | |
153fe6e7 | 21 | words, URL is a subset of a URI - all |
dd65d8c8 RN |
22 | acceptable URLs are also acceptable URIs. |
23 | ||
ce321570 RN |
24 | wxURI automatically escapes invalid characters in a string, |
25 | so there is no chance of wxURI "failing" on construction/creation. | |
26 | ||
dd65d8c8 RN |
27 | wxURI supports copy construction and standard assignment |
28 | operators. wxURI can also be inherited from to provide | |
29 | furthur functionality. | |
30 | ||
31 | \wxheading{Derived from} | |
32 | ||
b60b2ec8 | 33 | \helpref{wxObject}{wxobject} |
dd65d8c8 RN |
34 | |
35 | \wxheading{Include files} | |
36 | ||
9689f522 | 37 | <wx/uri.h> |
dd65d8c8 | 38 | |
a7af285d VZ |
39 | \wxheading{Library} |
40 | ||
41 | \helpref{wxBase}{librarieslist} | |
42 | ||
7d90da2b RR |
43 | \wxheading{See also} |
44 | ||
45 | \helpref{wxURL}{wxurl} | |
46 | ||
dd65d8c8 RN |
47 | \latexignore{\rtfignore{\wxheading{Members}}} |
48 | ||
aed31418 | 49 | \membersection{Obtaining individual components}\label{obtainingwxuricomponents} |
dd65d8c8 RN |
50 | |
51 | To obtain individual components you can use | |
ce321570 | 52 | one of the following methods |
dd65d8c8 RN |
53 | |
54 | \helpref{GetScheme}{wxurigetscheme}\\ | |
4860d40d | 55 | \helpref{GetUserInfo}{wxurigetuserinfo}\\ |
dd65d8c8 | 56 | \helpref{GetServer}{wxurigetserver}\\ |
7d90da2b | 57 | \helpref{GetPort}{wxurigetport}\\ |
dd65d8c8 RN |
58 | \helpref{GetPath}{wxurigetpath}\\ |
59 | \helpref{GetQuery}{wxurigetquery}\\ | |
60 | \helpref{GetFragment}{wxurigetfragment} | |
61 | ||
62 | However, you should check HasXXX before | |
ce321570 RN |
63 | calling a get method, which determines whether or not the component referred |
64 | to by the method is defined according to RFC 2396. | |
65 | ||
ed6d7010 | 66 | Consider an undefined component equivalent to a |
ce321570 RN |
67 | NULL C string.\\ |
68 | \\ | |
dd65d8c8 | 69 | \helpref{HasScheme}{wxurihasscheme}\\ |
4860d40d | 70 | \helpref{HasUserInfo}{wxurihasuserinfo}\\ |
dd65d8c8 RN |
71 | \helpref{HasServer}{wxurihasserver}\\ |
72 | \helpref{HasPort}{wxurihasserver}\\ | |
73 | \helpref{HasPath}{wxurihaspath}\\ | |
74 | \helpref{HasQuery}{wxurihasquery}\\ | |
75 | \helpref{HasFragment}{wxurihasfragment} | |
76 | ||
77 | Example: | |
78 | \begin{verbatim} | |
79 | //protocol will hold the http protocol (i.e. "http") | |
80 | wxString protocol; | |
81 | wxURI myuri(wxT("http://mysite.com")); | |
82 | if(myuri.HasScheme()) | |
83 | protocol = myuri.GetScheme(); | |
84 | \end{verbatim} | |
85 | ||
97ad053b VZ |
86 | \membersection{Deviations from the RFC}\label{deviationsfromrfc} |
87 | ||
88 | Note that on URIs with a "file" scheme wxURI does not | |
89 | parse the userinfo, server, or port portion. This is to keep | |
90 | compatability with wxFileSystem, the old wxURL, and older url specifications. | |
91 | ||
dd65d8c8 RN |
92 | \membersection{wxURI::wxURI}\label{wxuriwxuri} |
93 | ||
94 | \func{}{wxURI}{\void} | |
95 | ||
153fe6e7 | 96 | Creates an empty URI. |
dd65d8c8 RN |
97 | |
98 | \func{}{wxURI}{\param{const wxChar* }{uri}} | |
99 | ||
153fe6e7 | 100 | Constructor for quick creation. |
dd65d8c8 RN |
101 | |
102 | \docparam{uri}{string to initialize with} | |
103 | ||
153fe6e7 | 104 | \func{}{wxURI}{\param{const wxURI\& }{uri}} |
dd65d8c8 RN |
105 | |
106 | Copies this URI from another URI. | |
107 | ||
108 | \docparam{uri}{URI (Uniform Resource Identifier) to initialize with} | |
109 | ||
110 | ||
86470d43 RN |
111 | \membersection{wxURI::BuildURI}\label{wxuribuilduri} |
112 | ||
113 | \constfunc{wxString}{BuildURI}{\void} | |
114 | ||
3103e8a9 | 115 | Builds the URI from its individual components and adds proper separators. |
86470d43 RN |
116 | |
117 | If the URI is not a reference or is not resolved, | |
118 | the URI that is returned from Get is the same one | |
119 | passed to Create. | |
120 | ||
121 | ||
122 | \membersection{wxURI::BuildUnescapedURI}\label{wxuribuildunescapeduri} | |
123 | ||
124 | \constfunc{wxString}{BuildUnescapedURI}{\void} | |
125 | ||
3103e8a9 | 126 | Builds the URI from its individual components, adds proper separators, and |
86470d43 RN |
127 | returns escape sequences to normal characters. |
128 | ||
129 | Note that it is preferred to call this over Unescape(BuildURI()) since | |
47261ba0 | 130 | \helpref{BuildUnescapedURI}{wxuribuildunescapeduri} performs some optimizations over the plain method. |
86470d43 RN |
131 | |
132 | ||
dd65d8c8 RN |
133 | \membersection{wxURI::Create}\label{wxuricreate} |
134 | ||
ed6d7010 | 135 | \func{const wxChar*}{Create}{\param{const wxString&}{uri}} |
dd65d8c8 | 136 | |
e6a156f9 | 137 | Creates this URI from the string \arg{uri}. |
dd65d8c8 | 138 | |
ce321570 RN |
139 | Returns the position at which parsing stopped (there |
140 | is no such thing as an "invalid" wxURI). | |
141 | ||
dd65d8c8 RN |
142 | \docparam{uri}{string to initialize from} |
143 | ||
dd65d8c8 RN |
144 | |
145 | \membersection{wxURI::GetFragment}\label{wxurigetfragment} | |
146 | ||
147 | \constfunc{const wxString&}{GetFragment}{\void} | |
148 | ||
149 | Obtains the fragment of this URI. | |
150 | ||
151 | The fragment of a URI is the last value of the URI, | |
152 | and is the value after a '#' character after the path | |
153 | of the URI. | |
154 | ||
155 | \tt{http://mysite.com/mypath\#<fragment>} | |
156 | ||
157 | \membersection{wxURI::GetHostType}\label{wxurigethosttype} | |
158 | ||
159 | \constfunc{const HostType\&}{GetHostType}{\void} | |
160 | ||
161 | Obtains the host type of this URI, which is of type | |
162 | wxURI::HostType: | |
163 | ||
164 | \twocolwidtha{7cm} | |
165 | \begin{twocollist}\itemsep=0pt | |
166 | \twocolitem{{\bf wxURI\_REGNAME}}{Server is a host name, or the Server component itself is undefined.} | |
167 | \twocolitem{{\bf wxURI\_IPV4ADDRESS}}{Server is a IP version 4 address (XXX.XXX.XXX.XXX)} | |
168 | \twocolitem{{\bf wxURI\_IPV6ADDRESS}}{Server is a IP version 6 address ((XXX:)XXX::(XXX)XXX:XXX} | |
169 | \twocolitem{{\bf wxURI\_IPVFUTURE}}{Server is an IP address, but not versions 4 or 6} | |
170 | \end{twocollist} | |
171 | ||
4860d40d RN |
172 | |
173 | \membersection{wxURI::GetPassword}\label{wxurigetpassword} | |
174 | ||
175 | \constfunc{const wxString&}{GetPassword}{\void} | |
176 | ||
177 | Returns the password part of the userinfo component of | |
178 | this URI. Note that this is explicitly depreciated by | |
179 | RFC 1396 and should generally be avoided if possible. | |
180 | ||
181 | \tt{http://<user>:<password>@mysite.com/mypath} | |
182 | ||
183 | ||
dd65d8c8 RN |
184 | \membersection{wxURI::GetPath}\label{wxurigetpath} |
185 | ||
186 | \constfunc{const wxString&}{GetPath}{\void} | |
187 | ||
188 | Returns the (normalized) path of the URI. | |
189 | ||
190 | The path component of a URI comes | |
191 | directly after the scheme component | |
192 | if followed by zero or one slashes ('/'), | |
193 | or after the server/port component. | |
194 | ||
195 | Absolute paths include the leading '/' | |
196 | character. | |
197 | ||
198 | \tt{http://mysite.com<path>} | |
199 | ||
200 | \membersection{wxURI::GetPort}\label{wxurigetport} | |
201 | ||
202 | \constfunc{const wxString&}{GetPort}{\void} | |
203 | ||
204 | Returns a string representation of the URI's port. | |
205 | ||
206 | The Port of a URI is a value after the server, and | |
207 | must come after a colon (:). | |
208 | ||
209 | \tt{http://mysite.com:<port>} | |
210 | ||
211 | Note that you can easily get the numeric value of the port | |
212 | by using wxAtoi or wxString::Format. | |
213 | ||
214 | \membersection{wxURI::GetQuery}\label{wxurigetquery} | |
215 | ||
216 | \constfunc{const wxString&}{GetQuery}{\void} | |
217 | ||
218 | Returns the Query component of the URI. | |
219 | ||
220 | The query component is what is commonly passed to a | |
221 | cgi application, and must come after the path component, | |
222 | and after a '?' character. | |
223 | ||
224 | \tt{http://mysite.com/mypath?<query>} | |
225 | ||
226 | ||
227 | \membersection{wxURI::GetScheme}\label{wxurigetscheme} | |
228 | ||
229 | \constfunc{const wxString&}{GetScheme}{\void} | |
230 | ||
231 | Returns the Scheme component of the URI. | |
232 | ||
233 | The first part of the uri. | |
234 | ||
235 | \tt{<scheme>://mysite.com} | |
236 | ||
237 | ||
238 | \membersection{wxURI::GetServer}\label{wxurigetserver} | |
239 | ||
240 | \constfunc{const wxString&}{GetServer}{\void} | |
241 | ||
242 | Returns the Server component of the URI. | |
243 | ||
244 | The server of the uri can be a server name or | |
245 | a type of ip address. See | |
246 | \helpref{GetHostType}{wxurigethosttype} for the | |
247 | possible values for the host type of the | |
248 | server component. | |
249 | ||
250 | \tt{http://<server>/mypath} | |
251 | ||
252 | ||
253 | \membersection{wxURI::GetUser}\label{wxurigetuser} | |
254 | ||
255 | \constfunc{const wxString&}{GetUser}{\void} | |
256 | ||
4860d40d RN |
257 | Returns the username part of the userinfo component of |
258 | this URI. Note that this is explicitly depreciated by | |
259 | RFC 1396 and should generally be avoided if possible. | |
260 | ||
261 | \tt{http://<user>:<password>@mysite.com/mypath} | |
262 | ||
263 | ||
264 | \membersection{wxURI::GetUserInfo}\label{wxurigetuserinfo} | |
265 | ||
266 | \constfunc{const wxString&}{GetUserInfo}{\void} | |
267 | ||
268 | Returns the UserInfo component of the URI. | |
dd65d8c8 RN |
269 | |
270 | The component of a URI before the server component | |
271 | that is postfixed by a '@' character. | |
272 | ||
4860d40d RN |
273 | \tt{http://<userinfo>@mysite.com/mypath} |
274 | ||
dd65d8c8 RN |
275 | |
276 | \membersection{wxURI::HasFragment}\label{wxurihasfragment} | |
277 | ||
278 | \constfunc{bool}{HasFragment}{\void} | |
279 | ||
e6a156f9 | 280 | Returns \true if the Fragment component of the URI exists. |
dd65d8c8 | 281 | |
4860d40d | 282 | |
dd65d8c8 RN |
283 | \membersection{wxURI::HasPath}\label{wxurihaspath} |
284 | ||
285 | \constfunc{bool}{HasPath}{\void} | |
286 | ||
e6a156f9 | 287 | Returns \true if the Path component of the URI exists. |
dd65d8c8 | 288 | |
4860d40d | 289 | |
dd65d8c8 RN |
290 | \membersection{wxURI::HasPort}\label{wxurihasport} |
291 | ||
292 | \constfunc{bool}{HasPort}{\void} | |
293 | ||
e6a156f9 | 294 | Returns \true if the Port component of the URI exists. |
dd65d8c8 RN |
295 | |
296 | ||
297 | \membersection{wxURI::HasQuery}\label{wxurihasquery} | |
298 | ||
299 | \constfunc{bool}{HasQuery}{\void} | |
300 | ||
e6a156f9 | 301 | Returns \true if the Query component of the URI exists. |
dd65d8c8 RN |
302 | |
303 | ||
304 | \membersection{wxURI::HasScheme}\label{wxurihasscheme} | |
305 | ||
306 | \constfunc{bool}{HasScheme}{\void} | |
307 | ||
e6a156f9 | 308 | Returns \true if the Scheme component of the URI exists. |
dd65d8c8 RN |
309 | |
310 | ||
311 | \membersection{wxURI::HasServer}\label{wxurihasserver} | |
312 | ||
313 | \constfunc{bool}{HasServer}{\void} | |
314 | ||
e6a156f9 | 315 | Returns \true if the Server component of the URI exists. |
dd65d8c8 RN |
316 | |
317 | ||
2f43eb98 | 318 | \membersection{wxURI::HasUser}\label{wxurihasuserinfo} |
dd65d8c8 RN |
319 | |
320 | \constfunc{bool}{HasUser}{\void} | |
321 | ||
e6a156f9 | 322 | Returns \true if the User component of the URI exists. |
dd65d8c8 RN |
323 | |
324 | ||
dd65d8c8 RN |
325 | \membersection{wxURI::IsReference}\label{wxuriisreference} |
326 | ||
327 | \constfunc{bool}{IsReference}{\void} | |
328 | ||
e6a156f9 | 329 | Returns \true if a valid [absolute] URI, otherwise this URI |
dd65d8c8 | 330 | is a URI reference and not a full URI, and IsReference |
e6a156f9 | 331 | returns \false. |
dd65d8c8 RN |
332 | |
333 | ||
334 | \membersection{wxURI::operator ==}\label{wxurioperatorcompare} | |
335 | ||
153fe6e7 | 336 | \func{void}{operator ==}{\param{const wxURI\& }{uricomp}} |
dd65d8c8 | 337 | |
e6a156f9 VZ |
338 | Compares this URI to another URI, and returns \true if |
339 | this URI equals \arg{uricomp}, otherwise it returns \false. | |
dd65d8c8 RN |
340 | |
341 | \docparam{uricomp}{URI to compare to} | |
342 | ||
343 | ||
dd65d8c8 RN |
344 | \membersection{wxURI::Resolve}\label{wxuriresolve} |
345 | ||
8404931e | 346 | \func{void}{Resolve}{\param{const wxURI\& }{base}, \param{int }{flags = \texttt{wxURI\_STRICT}}} |
dd65d8c8 RN |
347 | |
348 | Inherits this URI from a base URI - components that do not | |
349 | exist in this URI are copied from the base, and if this URI's | |
350 | path is not an absolute path (prefixed by a '/'), then this URI's | |
351 | path is merged with the base's path. | |
352 | ||
353 | For instance, resolving "../mydir" from "http://mysite.com/john/doe" | |
354 | results in the scheme (http) and server (mysite.com) being copied into | |
355 | this URI, since they do not exist. In addition, since the path | |
356 | of this URI is not absolute (does not begin with '/'), the path | |
357 | of the base's is merged with this URI's path, resulting in the URI | |
358 | "http://mysite.com/john/mydir". | |
359 | ||
360 | \docparam{base}{Base URI to inherit from. Must be a full URI and not a reference} | |
154b6b0f | 361 | \docparam{flags}{Currently either \texttt{wxURI\_STRICT} or $0$, in non-strict |
00a1d2e0 | 362 | mode some compatibility layers are enabled to allow loopholes from RFCs prior |
8404931e | 363 | to 2396} |
dd65d8c8 | 364 | |
86470d43 RN |
365 | \membersection{wxURI::Unescape}\label{wxuriunescape} |
366 | ||
367 | \func{wxString}{Unescape}{\param{const wxString\& }{uri}} | |
368 | ||
369 | Translates all escape sequences (% hex hex) of \arg{uri} into | |
370 | normal characters and returns the result. | |
371 | ||
47261ba0 | 372 | This is the preferred over deprecated wxURL::ConvertFromURI. |
86470d43 | 373 | |
47261ba0 | 374 | If you want to unescape an entire wxURI, use \helpref{BuildUnescapedURI}{wxuribuildunescapeduri} instead, |
86470d43 RN |
375 | as it performs some optimizations over this method. |
376 | ||
377 | \docparam{uri}{string with escaped characters to convert} | |
378 | ||
379 |