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