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{wxURL
}{wxurl
}
43 \latexignore{\rtfignore{\wxheading{Members
}}}
45 \membersection{Obtaining individual components
}\label{obtainingwxuricomponents
}
47 To obtain individual components you can use
48 one of the following methods
50 \helpref{GetScheme
}{wxurigetscheme
}\\
51 \helpref{GetUserInfo
}{wxurigetuserinfo
}\\
52 \helpref{GetServer
}{wxurigetserver
}\\
53 \helpref{GetPort
}{wxurigetport
}\\
54 \helpref{GetPath
}{wxurigetpath
}\\
55 \helpref{GetQuery
}{wxurigetquery
}\\
56 \helpref{GetFragment
}{wxurigetfragment
}
58 However, you should check HasXXX before
59 calling a get method, which determines whether or not the component referred
60 to by the method is defined according to RFC
2396.
62 Consider an undefined component equivalent to a
65 \helpref{HasScheme
}{wxurihasscheme
}\\
66 \helpref{HasUserInfo
}{wxurihasuserinfo
}\\
67 \helpref{HasServer
}{wxurihasserver
}\\
68 \helpref{HasPort
}{wxurihasserver
}\\
69 \helpref{HasPath
}{wxurihaspath
}\\
70 \helpref{HasQuery
}{wxurihasquery
}\\
71 \helpref{HasFragment
}{wxurihasfragment
}
75 //protocol will hold the http protocol (i.e. "http")
77 wxURI myuri(wxT("http://mysite.com"));
79 protocol = myuri.GetScheme();
82 \membersection{Deviations from the RFC
}\label{deviationsfromrfc
}
84 Note that on URIs with a "file" scheme wxURI does not
85 parse the userinfo, server, or port portion. This is to keep
86 compatability with wxFileSystem, the old wxURL, and older url specifications.
88 \membersection{wxURI::wxURI
}\label{wxuriwxuri
}
94 \func{}{wxURI
}{\param{const wxChar*
}{uri
}}
96 Constructor for quick creation.
98 \docparam{uri
}{string to initialize with
}
100 \func{}{wxURI
}{\param{const wxURI\&
}{uri
}}
102 Copies this URI from another URI.
104 \docparam{uri
}{URI (Uniform Resource Identifier) to initialize with
}
107 \membersection{wxURI::BuildURI
}\label{wxuribuilduri
}
109 \constfunc{wxString
}{BuildURI
}{\void}
111 Builds the URI from its individual components and adds proper separators.
113 If the URI is not a reference or is not resolved,
114 the URI that is returned from Get is the same one
118 \membersection{wxURI::BuildUnescapedURI
}\label{wxuribuildunescapeduri
}
120 \constfunc{wxString
}{BuildUnescapedURI
}{\void}
122 Builds the URI from its individual components, adds proper separators, and
123 returns escape sequences to normal characters.
125 Note that it is preferred to call this over Unescape(BuildURI()) since
126 \helpref{BuildUnescapedURI
}{wxuribuildunescapeduri
} performs some optimizations over the plain method.
129 \membersection{wxURI::Create
}\label{wxuricreate
}
131 \func{const wxChar*
}{Create
}{\param{const wxString&
}{uri
}}
133 Creates this URI from the string
\arg{uri
}.
135 Returns the position at which parsing stopped (there
136 is no such thing as an "invalid" wxURI).
138 \docparam{uri
}{string to initialize from
}
141 \membersection{wxURI::GetFragment
}\label{wxurigetfragment
}
143 \constfunc{const wxString&
}{GetFragment
}{\void}
145 Obtains the fragment of this URI.
147 The fragment of a URI is the last value of the URI,
148 and is the value after a '#' character after the path
151 \tt{http://mysite.com/mypath\#<fragment>
}
153 \membersection{wxURI::GetHostType
}\label{wxurigethosttype
}
155 \constfunc{const HostType\&
}{GetHostType
}{\void}
157 Obtains the host type of this URI, which is of type
161 \begin{twocollist
}\itemsep=
0pt
162 \twocolitem{{\bf wxURI
\_REGNAME}}{Server is a host name, or the Server component itself is undefined.
}
163 \twocolitem{{\bf wxURI
\_IPV4ADDRESS}}{Server is a IP version
4 address (XXX.XXX.XXX.XXX)
}
164 \twocolitem{{\bf wxURI
\_IPV6ADDRESS}}{Server is a IP version
6 address ((XXX:)XXX::(XXX)XXX:XXX
}
165 \twocolitem{{\bf wxURI
\_IPVFUTURE}}{Server is an IP address, but not versions
4 or
6}
169 \membersection{wxURI::GetPassword
}\label{wxurigetpassword
}
171 \constfunc{const wxString&
}{GetPassword
}{\void}
173 Returns the password part of the userinfo component of
174 this URI. Note that this is explicitly depreciated by
175 RFC
1396 and should generally be avoided if possible.
177 \tt{http://<user>:<password>@mysite.com/mypath
}
180 \membersection{wxURI::GetPath
}\label{wxurigetpath
}
182 \constfunc{const wxString&
}{GetPath
}{\void}
184 Returns the (normalized) path of the URI.
186 The path component of a URI comes
187 directly after the scheme component
188 if followed by zero or one slashes ('/'),
189 or after the server/port component.
191 Absolute paths include the leading '/'
194 \tt{http://mysite.com<path>
}
196 \membersection{wxURI::GetPort
}\label{wxurigetport
}
198 \constfunc{const wxString&
}{GetPort
}{\void}
200 Returns a string representation of the URI's port.
202 The Port of a URI is a value after the server, and
203 must come after a colon (:).
205 \tt{http://mysite.com:<port>
}
207 Note that you can easily get the numeric value of the port
208 by using wxAtoi or wxString::Format.
210 \membersection{wxURI::GetQuery
}\label{wxurigetquery
}
212 \constfunc{const wxString&
}{GetQuery
}{\void}
214 Returns the Query component of the URI.
216 The query component is what is commonly passed to a
217 cgi application, and must come after the path component,
218 and after a '?' character.
220 \tt{http://mysite.com/mypath?<query>
}
223 \membersection{wxURI::GetScheme
}\label{wxurigetscheme
}
225 \constfunc{const wxString&
}{GetScheme
}{\void}
227 Returns the Scheme component of the URI.
229 The first part of the uri.
231 \tt{<scheme>://mysite.com
}
234 \membersection{wxURI::GetServer
}\label{wxurigetserver
}
236 \constfunc{const wxString&
}{GetServer
}{\void}
238 Returns the Server component of the URI.
240 The server of the uri can be a server name or
241 a type of ip address. See
242 \helpref{GetHostType
}{wxurigethosttype
} for the
243 possible values for the host type of the
246 \tt{http://<server>/mypath
}
249 \membersection{wxURI::GetUser
}\label{wxurigetuser
}
251 \constfunc{const wxString&
}{GetUser
}{\void}
253 Returns the username part of the userinfo component of
254 this URI. Note that this is explicitly depreciated by
255 RFC
1396 and should generally be avoided if possible.
257 \tt{http://<user>:<password>@mysite.com/mypath
}
260 \membersection{wxURI::GetUserInfo
}\label{wxurigetuserinfo
}
262 \constfunc{const wxString&
}{GetUserInfo
}{\void}
264 Returns the UserInfo component of the URI.
266 The component of a URI before the server component
267 that is postfixed by a '@' character.
269 \tt{http://<userinfo>@mysite.com/mypath
}
272 \membersection{wxURI::HasFragment
}\label{wxurihasfragment
}
274 \constfunc{bool
}{HasFragment
}{\void}
276 Returns
\true if the Fragment component of the URI exists.
279 \membersection{wxURI::HasPath
}\label{wxurihaspath
}
281 \constfunc{bool
}{HasPath
}{\void}
283 Returns
\true if the Path component of the URI exists.
286 \membersection{wxURI::HasPort
}\label{wxurihasport
}
288 \constfunc{bool
}{HasPort
}{\void}
290 Returns
\true if the Port component of the URI exists.
293 \membersection{wxURI::HasQuery
}\label{wxurihasquery
}
295 \constfunc{bool
}{HasQuery
}{\void}
297 Returns
\true if the Query component of the URI exists.
300 \membersection{wxURI::HasScheme
}\label{wxurihasscheme
}
302 \constfunc{bool
}{HasScheme
}{\void}
304 Returns
\true if the Scheme component of the URI exists.
307 \membersection{wxURI::HasServer
}\label{wxurihasserver
}
309 \constfunc{bool
}{HasServer
}{\void}
311 Returns
\true if the Server component of the URI exists.
314 \membersection{wxURI::HasUser
}\label{wxurihasuserinfo
}
316 \constfunc{bool
}{HasUser
}{\void}
318 Returns
\true if the User component of the URI exists.
321 \membersection{wxURI::IsReference
}\label{wxuriisreference
}
323 \constfunc{bool
}{IsReference
}{\void}
325 Returns
\true if a valid
[absolute
] URI, otherwise this URI
326 is a URI reference and not a full URI, and IsReference
330 \membersection{wxURI::operator ==
}\label{wxurioperatorcompare
}
332 \func{void
}{operator ==
}{\param{const wxURI\&
}{uricomp
}}
334 Compares this URI to another URI, and returns
\true if
335 this URI equals
\arg{uricomp
}, otherwise it returns
\false.
337 \docparam{uricomp
}{URI to compare to
}
340 \membersection{wxURI::Resolve
}\label{wxuriresolve
}
342 \func{void
}{Resolve
}{\param{const wxURI\&
}{base
},
\param{int
}{flags =
\texttt{wxURI
\_STRICT}}}
344 Inherits this URI from a base URI - components that do not
345 exist in this URI are copied from the base, and if this URI's
346 path is not an absolute path (prefixed by a '/'), then this URI's
347 path is merged with the base's path.
349 For instance, resolving "../mydir" from "http://mysite.com/john/doe"
350 results in the scheme (http) and server (mysite.com) being copied into
351 this URI, since they do not exist. In addition, since the path
352 of this URI is not absolute (does not begin with '/'), the path
353 of the base's is merged with this URI's path, resulting in the URI
354 "http://mysite.com/john/mydir".
356 \docparam{base
}{Base URI to inherit from. Must be a full URI and not a reference
}
357 \docparam{flags
}{Currently either
\texttt{wxURI
\_STRICT} or $
0$, in non-strict
358 mode some compatibility layers are enabled to allow loopholes from RFCs prior
361 \membersection{wxURI::Unescape
}\label{wxuriunescape
}
363 \func{wxString
}{Unescape
}{\param{const wxString\&
}{uri
}}
365 Translates all escape sequences (
% hex hex) of \arg{uri} into
366 normal characters and returns the result.
368 This is the preferred over deprecated wxURL::ConvertFromURI.
370 If you want to unescape an entire wxURI, use
\helpref{BuildUnescapedURI
}{wxuribuildunescapeduri
} instead,
371 as it performs some optimizations over this method.
373 \docparam{uri
}{string with escaped characters to convert
}