1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 %% Author: Ryan Norton <wxprojects@comcast.net>
8 %% Copyright: (c) Ryan Norton
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxURI
}}\label{wxuri
}
14 wxURI is used to extract information from
15 a URI (Uniform Resource Identifier).
17 For information about URIs, see
18 \urlref{RFC
3986}{http://www.ietf.org/rfc/rfc3986.txt
}.
20 In short, a URL
\em{is
} a URI. In other
21 words, URL is a subset of a URI - all
22 acceptable URLs are also acceptable URIs.
24 wxURI automatically escapes invalid characters in a string,
25 so there is no chance of wxURI "failing" on construction/creation.
27 wxURI supports copy construction and standard assignment
28 operators. wxURI can also be inherited from to provide
29 furthur functionality.
31 \wxheading{Derived from
}
33 \helpref{wxObject
}{wxobject
}
35 \wxheading{Include files
}
41 \helpref{wxBase
}{librarieslist
}
45 \helpref{wxURL
}{wxurl
}
47 \latexignore{\rtfignore{\wxheading{Members
}}}
49 \membersection{Obtaining individual components
}\label{obtainingwxuricomponents
}
51 To obtain individual components you can use
52 one of the following methods
54 \helpref{GetScheme
}{wxurigetscheme
}\\
55 \helpref{GetUserInfo
}{wxurigetuserinfo
}\\
56 \helpref{GetServer
}{wxurigetserver
}\\
57 \helpref{GetPort
}{wxurigetport
}\\
58 \helpref{GetPath
}{wxurigetpath
}\\
59 \helpref{GetQuery
}{wxurigetquery
}\\
60 \helpref{GetFragment
}{wxurigetfragment
}
62 However, you should check HasXXX before
63 calling a get method, which determines whether or not the component referred
64 to by the method is defined according to RFC
2396.
66 Consider an undefined component equivalent to a
69 \helpref{HasScheme
}{wxurihasscheme
}\\
70 \helpref{HasUserInfo
}{wxurihasuserinfo
}\\
71 \helpref{HasServer
}{wxurihasserver
}\\
72 \helpref{HasPort
}{wxurihasserver
}\\
73 \helpref{HasPath
}{wxurihaspath
}\\
74 \helpref{HasQuery
}{wxurihasquery
}\\
75 \helpref{HasFragment
}{wxurihasfragment
}
79 //protocol will hold the http protocol (i.e. "http")
81 wxURI myuri(wxT("http://mysite.com"));
83 protocol = myuri.GetScheme();
86 \membersection{Deviations from the RFC
}\label{deviationsfromrfc
}
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.
92 \membersection{wxURI::wxURI
}\label{wxuriwxuri
}
98 \func{}{wxURI
}{\param{const wxChar*
}{uri
}}
100 Constructor for quick creation.
102 \docparam{uri
}{string to initialize with
}
104 \func{}{wxURI
}{\param{const wxURI\&
}{uri
}}
106 Copies this URI from another URI.
108 \docparam{uri
}{URI (Uniform Resource Identifier) to initialize with
}
111 \membersection{wxURI::BuildURI
}\label{wxuribuilduri
}
113 \constfunc{wxString
}{BuildURI
}{\void}
115 Builds the URI from its individual components and adds proper separators.
117 If the URI is not a reference or is not resolved,
118 the URI that is returned from Get is the same one
122 \membersection{wxURI::BuildUnescapedURI
}\label{wxuribuildunescapeduri
}
124 \constfunc{wxString
}{BuildUnescapedURI
}{\void}
126 Builds the URI from its individual components, adds proper separators, and
127 returns escape sequences to normal characters.
129 Note that it is preferred to call this over Unescape(BuildURI()) since
130 \helpref{BuildUnescapedURI
}{wxuribuildunescapeduri
} performs some optimizations over the plain method.
133 \membersection{wxURI::Create
}\label{wxuricreate
}
135 \func{const wxChar*
}{Create
}{\param{const wxString&
}{uri
}}
137 Creates this URI from the string
\arg{uri
}.
139 Returns the position at which parsing stopped (there
140 is no such thing as an "invalid" wxURI).
142 \docparam{uri
}{string to initialize from
}
145 \membersection{wxURI::GetFragment
}\label{wxurigetfragment
}
147 \constfunc{const wxString&
}{GetFragment
}{\void}
149 Obtains the fragment of this URI.
151 The fragment of a URI is the last value of the URI,
152 and is the value after a '#' character after the path
155 \tt{http://mysite.com/mypath\#<fragment>
}
157 \membersection{wxURI::GetHostType
}\label{wxurigethosttype
}
159 \constfunc{const HostType\&
}{GetHostType
}{\void}
161 Obtains the host type of this URI, which is of type
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}
173 \membersection{wxURI::GetPassword
}\label{wxurigetpassword
}
175 \constfunc{const wxString&
}{GetPassword
}{\void}
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.
181 \tt{http://<user>:<password>@mysite.com/mypath
}
184 \membersection{wxURI::GetPath
}\label{wxurigetpath
}
186 \constfunc{const wxString&
}{GetPath
}{\void}
188 Returns the (normalized) path of the URI.
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.
195 Absolute paths include the leading '/'
198 \tt{http://mysite.com<path>
}
200 \membersection{wxURI::GetPort
}\label{wxurigetport
}
202 \constfunc{const wxString&
}{GetPort
}{\void}
204 Returns a string representation of the URI's port.
206 The Port of a URI is a value after the server, and
207 must come after a colon (:).
209 \tt{http://mysite.com:<port>
}
211 Note that you can easily get the numeric value of the port
212 by using wxAtoi or wxString::Format.
214 \membersection{wxURI::GetQuery
}\label{wxurigetquery
}
216 \constfunc{const wxString&
}{GetQuery
}{\void}
218 Returns the Query component of the URI.
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.
224 \tt{http://mysite.com/mypath?<query>
}
227 \membersection{wxURI::GetScheme
}\label{wxurigetscheme
}
229 \constfunc{const wxString&
}{GetScheme
}{\void}
231 Returns the Scheme component of the URI.
233 The first part of the uri.
235 \tt{<scheme>://mysite.com
}
238 \membersection{wxURI::GetServer
}\label{wxurigetserver
}
240 \constfunc{const wxString&
}{GetServer
}{\void}
242 Returns the Server component of the URI.
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
250 \tt{http://<server>/mypath
}
253 \membersection{wxURI::GetUser
}\label{wxurigetuser
}
255 \constfunc{const wxString&
}{GetUser
}{\void}
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.
261 \tt{http://<user>:<password>@mysite.com/mypath
}
264 \membersection{wxURI::GetUserInfo
}\label{wxurigetuserinfo
}
266 \constfunc{const wxString&
}{GetUserInfo
}{\void}
268 Returns the UserInfo component of the URI.
270 The component of a URI before the server component
271 that is postfixed by a '@' character.
273 \tt{http://<userinfo>@mysite.com/mypath
}
276 \membersection{wxURI::HasFragment
}\label{wxurihasfragment
}
278 \constfunc{bool
}{HasFragment
}{\void}
280 Returns
\true if the Fragment component of the URI exists.
283 \membersection{wxURI::HasPath
}\label{wxurihaspath
}
285 \constfunc{bool
}{HasPath
}{\void}
287 Returns
\true if the Path component of the URI exists.
290 \membersection{wxURI::HasPort
}\label{wxurihasport
}
292 \constfunc{bool
}{HasPort
}{\void}
294 Returns
\true if the Port component of the URI exists.
297 \membersection{wxURI::HasQuery
}\label{wxurihasquery
}
299 \constfunc{bool
}{HasQuery
}{\void}
301 Returns
\true if the Query component of the URI exists.
304 \membersection{wxURI::HasScheme
}\label{wxurihasscheme
}
306 \constfunc{bool
}{HasScheme
}{\void}
308 Returns
\true if the Scheme component of the URI exists.
311 \membersection{wxURI::HasServer
}\label{wxurihasserver
}
313 \constfunc{bool
}{HasServer
}{\void}
315 Returns
\true if the Server component of the URI exists.
318 \membersection{wxURI::HasUser
}\label{wxurihasuserinfo
}
320 \constfunc{bool
}{HasUser
}{\void}
322 Returns
\true if the User component of the URI exists.
325 \membersection{wxURI::IsReference
}\label{wxuriisreference
}
327 \constfunc{bool
}{IsReference
}{\void}
329 Returns
\true if a valid
[absolute
] URI, otherwise this URI
330 is a URI reference and not a full URI, and IsReference
334 \membersection{wxURI::operator ==
}\label{wxurioperatorcompare
}
336 \func{void
}{operator ==
}{\param{const wxURI\&
}{uricomp
}}
338 Compares this URI to another URI, and returns
\true if
339 this URI equals
\arg{uricomp
}, otherwise it returns
\false.
341 \docparam{uricomp
}{URI to compare to
}
344 \membersection{wxURI::Resolve
}\label{wxuriresolve
}
346 \func{void
}{Resolve
}{\param{const wxURI\&
}{base
},
\param{int
}{flags =
\texttt{wxURI
\_STRICT}}}
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.
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".
360 \docparam{base
}{Base URI to inherit from. Must be a full URI and not a reference
}
361 \docparam{flags
}{Currently either
\texttt{wxURI
\_STRICT} or $
0$, in non-strict
362 mode some compatibility layers are enabled to allow loopholes from RFCs prior
365 \membersection{wxURI::Unescape
}\label{wxuriunescape
}
367 \func{wxString
}{Unescape
}{\param{const wxString\&
}{uri
}}
369 Translates all escape sequences (
% hex hex) of \arg{uri} into
370 normal characters and returns the result.
372 This is the preferred over deprecated wxURL::ConvertFromURI.
374 If you want to unescape an entire wxURI, use
\helpref{BuildUnescapedURI
}{wxuribuildunescapeduri
} instead,
375 as it performs some optimizations over this method.
377 \docparam{uri
}{string with escaped characters to convert
}