]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/uri.tex
fix LaTeX error (escape underscores); don't abuse bold face
[wxWidgets.git] / docs / latex / wx / uri.tex
CommitLineData
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
14wxURI is used to extract information from
15a URI (Uniform Resource Identifier).
16
17For information about URIs, see
4cc52142 18\urlref{RFC 3986}{http://www.ietf.org/rfc/rfc3986.txt}.
dd65d8c8
RN
19
20In short, a URL \em{is} a URI. In other
153fe6e7 21words, URL is a subset of a URI - all
dd65d8c8
RN
22acceptable URLs are also acceptable URIs.
23
ce321570
RN
24wxURI automatically escapes invalid characters in a string,
25so there is no chance of wxURI "failing" on construction/creation.
26
dd65d8c8
RN
27wxURI supports copy construction and standard assignment
28operators. wxURI can also be inherited from to provide
29furthur 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
51To obtain individual components you can use
ce321570 52one 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
62However, you should check HasXXX before
ce321570
RN
63calling a get method, which determines whether or not the component referred
64to by the method is defined according to RFC 2396.
65
ed6d7010 66Consider an undefined component equivalent to a
ce321570
RN
67NULL 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
77Example:
78\begin{verbatim}
79//protocol will hold the http protocol (i.e. "http")
80wxString protocol;
81wxURI myuri(wxT("http://mysite.com"));
82if(myuri.HasScheme())
83 protocol = myuri.GetScheme();
84\end{verbatim}
85
97ad053b
VZ
86\membersection{Deviations from the RFC}\label{deviationsfromrfc}
87
88Note that on URIs with a "file" scheme wxURI does not
89parse the userinfo, server, or port portion. This is to keep
90compatability 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 96Creates an empty URI.
dd65d8c8
RN
97
98\func{}{wxURI}{\param{const wxChar* }{uri}}
99
153fe6e7 100Constructor 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
106Copies 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 115Builds the URI from its individual components and adds proper separators.
86470d43
RN
116
117If the URI is not a reference or is not resolved,
118the URI that is returned from Get is the same one
119passed to Create.
120
121
122\membersection{wxURI::BuildUnescapedURI}\label{wxuribuildunescapeduri}
123
124\constfunc{wxString}{BuildUnescapedURI}{\void}
125
3103e8a9 126Builds the URI from its individual components, adds proper separators, and
86470d43
RN
127returns escape sequences to normal characters.
128
129Note 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 137Creates this URI from the string \arg{uri}.
dd65d8c8 138
ce321570
RN
139Returns the position at which parsing stopped (there
140is 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
149Obtains the fragment of this URI.
150
151The fragment of a URI is the last value of the URI,
152and is the value after a '#' character after the path
153of 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
161Obtains the host type of this URI, which is of type
162wxURI::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
177Returns the password part of the userinfo component of
178this URI. Note that this is explicitly depreciated by
179RFC 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
188Returns the (normalized) path of the URI.
189
190The path component of a URI comes
191directly after the scheme component
192if followed by zero or one slashes ('/'),
193or after the server/port component.
194
195Absolute paths include the leading '/'
196character.
197
198\tt{http://mysite.com<path>}
199
200\membersection{wxURI::GetPort}\label{wxurigetport}
201
202\constfunc{const wxString&}{GetPort}{\void}
203
204Returns a string representation of the URI's port.
205
206The Port of a URI is a value after the server, and
207must come after a colon (:).
208
209\tt{http://mysite.com:<port>}
210
211Note that you can easily get the numeric value of the port
212by using wxAtoi or wxString::Format.
213
214\membersection{wxURI::GetQuery}\label{wxurigetquery}
215
216\constfunc{const wxString&}{GetQuery}{\void}
217
218Returns the Query component of the URI.
219
220The query component is what is commonly passed to a
221cgi application, and must come after the path component,
222and 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
231Returns the Scheme component of the URI.
232
233The 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
242Returns the Server component of the URI.
243
244The server of the uri can be a server name or
245a type of ip address. See
246\helpref{GetHostType}{wxurigethosttype} for the
247possible values for the host type of the
248server 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
257Returns the username part of the userinfo component of
258this URI. Note that this is explicitly depreciated by
259RFC 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
268Returns the UserInfo component of the URI.
dd65d8c8
RN
269
270The component of a URI before the server component
271that 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 280Returns \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 287Returns \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 294Returns \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 301Returns \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 308Returns \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 315Returns \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 322Returns \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 329Returns \true if a valid [absolute] URI, otherwise this URI
dd65d8c8 330is a URI reference and not a full URI, and IsReference
e6a156f9 331returns \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
338Compares this URI to another URI, and returns \true if
339this 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
348Inherits this URI from a base URI - components that do not
349exist in this URI are copied from the base, and if this URI's
350path is not an absolute path (prefixed by a '/'), then this URI's
351path is merged with the base's path.
352
353For instance, resolving "../mydir" from "http://mysite.com/john/doe"
354results in the scheme (http) and server (mysite.com) being copied into
355this URI, since they do not exist. In addition, since the path
356of this URI is not absolute (does not begin with '/'), the path
357of 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 362mode some compatibility layers are enabled to allow loopholes from RFCs prior
8404931e 363to 2396}
dd65d8c8 364
86470d43
RN
365\membersection{wxURI::Unescape}\label{wxuriunescape}
366
367\func{wxString}{Unescape}{\param{const wxString\& }{uri}}
368
369Translates all escape sequences (% hex hex) of \arg{uri} into
370normal characters and returns the result.
371
47261ba0 372This is the preferred over deprecated wxURL::ConvertFromURI.
86470d43 373
47261ba0 374If you want to unescape an entire wxURI, use \helpref{BuildUnescapedURI}{wxuribuildunescapeduri} instead,
86470d43
RN
375as it performs some optimizations over this method.
376
377\docparam{uri}{string with escaped characters to convert}
378
379