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
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
}.
21 In short, a URL
\em{is
} a URI. In other
22 words, URL is a subset of a URI - all
23 acceptable URLs are also acceptable URIs.
25 wxURI supports copy construction and standard assignment
26 operators. wxURI can also be inherited from to provide
27 furthur functionality.
29 \wxheading{Derived from
}
31 \helpref{wxObject
}{wxobject
}
33 \wxheading{Include files
}
37 \latexignore{\rtfignore{\wxheading{Members
}}}
39 \membersection{Obtaining individual components
}
41 To obtain individual components you can use
42 one of the following methods:
44 \helpref{GetScheme
}{wxurigetscheme
}\\
45 \helpref{GetUser
}{wxurigetuser
}\\
46 \helpref{GetServer
}{wxurigetserver
}\\
47 \helpref{GetPort
}{wxurigetserver
}\\
48 \helpref{GetPath
}{wxurigetpath
}\\
49 \helpref{GetQuery
}{wxurigetquery
}\\
50 \helpref{GetFragment
}{wxurigetfragment
}
52 However, you should check HasXXX before
53 calling a get method:\\
55 \helpref{HasScheme
}{wxurihasscheme
}\\
56 \helpref{HasUser
}{wxurihasuser
}\\
57 \helpref{HasServer
}{wxurihasserver
}\\
58 \helpref{HasPort
}{wxurihasserver
}\\
59 \helpref{HasPath
}{wxurihaspath
}\\
60 \helpref{HasQuery
}{wxurihasquery
}\\
61 \helpref{HasFragment
}{wxurihasfragment
}
65 //protocol will hold the http protocol (i.e. "http")
67 wxURI myuri(wxT("http://mysite.com"));
69 protocol = myuri.GetScheme();
72 \membersection{wxURI::wxURI
}\label{wxuriwxuri
}
78 \func{}{wxURI
}{\param{const wxChar*
}{uri
}}
80 Constructor for quick creation.
82 \docparam{uri
}{string to initialize with
}
84 \func{}{wxURI
}{\param{const wxURI\&
}{uri
}}
86 Copies this URI from another URI.
88 \docparam{uri
}{URI (Uniform Resource Identifier) to initialize with
}
91 \membersection{wxURI::BuildURI
}\label{wxuribuilduri
}
93 \constfunc{wxString
}{BuildURI
}{\void}
95 Builds the URI from its individual components and adds proper seperators.
97 If the URI is not a reference or is not resolved,
98 the URI that is returned from Get is the same one
102 \membersection{wxURI::BuildUnescapedURI
}\label{wxuribuildunescapeduri
}
104 \constfunc{wxString
}{BuildUnescapedURI
}{\void}
106 Builds the URI from its individual components, adds proper seperators, and
107 returns escape sequences to normal characters.
109 Note that it is preferred to call this over Unescape(BuildURI()) since
110 BuildUnescapedURI performs some optimizations over the plain method.
113 \membersection{wxURI::Create
}\label{wxuricreate
}
115 \func{void
}{Create
}{\param{const wxChar*
}{uri
}}
117 Creates this URI from the string
\arg{uri
}.
119 \docparam{uri
}{string to initialize from
}
122 \membersection{wxURI::GetFragment
}\label{wxurigetfragment
}
124 \constfunc{const wxString&
}{GetFragment
}{\void}
126 Obtains the fragment of this URI.
128 The fragment of a URI is the last value of the URI,
129 and is the value after a '#' character after the path
132 \tt{http://mysite.com/mypath\#<fragment>
}
134 \membersection{wxURI::GetHostType
}\label{wxurigethosttype
}
136 \constfunc{const HostType\&
}{GetHostType
}{\void}
138 Obtains the host type of this URI, which is of type
142 \begin{twocollist
}\itemsep=
0pt
143 \twocolitem{{\bf wxURI
\_REGNAME}}{Server is a host name, or the Server component itself is undefined.
}
144 \twocolitem{{\bf wxURI
\_IPV4ADDRESS}}{Server is a IP version
4 address (XXX.XXX.XXX.XXX)
}
145 \twocolitem{{\bf wxURI
\_IPV6ADDRESS}}{Server is a IP version
6 address ((XXX:)XXX::(XXX)XXX:XXX
}
146 \twocolitem{{\bf wxURI
\_IPVFUTURE}}{Server is an IP address, but not versions
4 or
6}
149 \membersection{wxURI::GetPath
}\label{wxurigetpath
}
151 \constfunc{const wxString&
}{GetPath
}{\void}
153 Returns the (normalized) path of the URI.
155 The path component of a URI comes
156 directly after the scheme component
157 if followed by zero or one slashes ('/'),
158 or after the server/port component.
160 Absolute paths include the leading '/'
163 \tt{http://mysite.com<path>
}
165 \membersection{wxURI::GetPort
}\label{wxurigetport
}
167 \constfunc{const wxString&
}{GetPort
}{\void}
169 Returns a string representation of the URI's port.
171 The Port of a URI is a value after the server, and
172 must come after a colon (:).
174 \tt{http://mysite.com:<port>
}
176 Note that you can easily get the numeric value of the port
177 by using wxAtoi or wxString::Format.
179 \membersection{wxURI::GetQuery
}\label{wxurigetquery
}
181 \constfunc{const wxString&
}{GetQuery
}{\void}
183 Returns the Query component of the URI.
185 The query component is what is commonly passed to a
186 cgi application, and must come after the path component,
187 and after a '?' character.
189 \tt{http://mysite.com/mypath?<query>
}
192 \membersection{wxURI::GetScheme
}\label{wxurigetscheme
}
194 \constfunc{const wxString&
}{GetScheme
}{\void}
196 Returns the Scheme component of the URI.
198 The first part of the uri.
200 \tt{<scheme>://mysite.com
}
203 \membersection{wxURI::GetServer
}\label{wxurigetserver
}
205 \constfunc{const wxString&
}{GetServer
}{\void}
207 Returns the Server component of the URI.
209 The server of the uri can be a server name or
210 a type of ip address. See
211 \helpref{GetHostType
}{wxurigethosttype
} for the
212 possible values for the host type of the
215 \tt{http://<server>/mypath
}
218 \membersection{wxURI::GetUser
}\label{wxurigetuser
}
220 \constfunc{const wxString&
}{GetUser
}{\void}
222 Returns the User component of the URI.
224 The component of a URI before the server component
225 that is postfixed by a '@' character.
227 \tt{http://<user>@mysite.com/mypath
}
229 \membersection{wxURI::HasFragment
}\label{wxurihasfragment
}
231 \constfunc{bool
}{HasFragment
}{\void}
233 Returns
\true if the Fragment component of the URI exists.
235 \membersection{wxURI::HasPath
}\label{wxurihaspath
}
237 \constfunc{bool
}{HasPath
}{\void}
239 Returns
\true if the Path component of the URI exists.
241 \membersection{wxURI::HasPort
}\label{wxurihasport
}
243 \constfunc{bool
}{HasPort
}{\void}
245 Returns
\true if the Port component of the URI exists.
248 \membersection{wxURI::HasQuery
}\label{wxurihasquery
}
250 \constfunc{bool
}{HasQuery
}{\void}
252 Returns
\true if the Query component of the URI exists.
255 \membersection{wxURI::HasScheme
}\label{wxurihasscheme
}
257 \constfunc{bool
}{HasScheme
}{\void}
259 Returns
\true if the Scheme component of the URI exists.
262 \membersection{wxURI::HasServer
}\label{wxurihasserver
}
264 \constfunc{bool
}{HasServer
}{\void}
266 Returns
\true if the Server component of the URI exists.
269 \membersection{wxURI::HasUser
}\label{wxurihasuser
}
271 \constfunc{bool
}{HasUser
}{\void}
273 Returns
\true if the User component of the URI exists.
276 \membersection{wxURI::IsReference
}\label{wxuriisreference
}
278 \constfunc{bool
}{IsReference
}{\void}
280 Returns
\true if a valid
[absolute
] URI, otherwise this URI
281 is a URI reference and not a full URI, and IsReference
285 \membersection{wxURI::operator ==
}\label{wxurioperatorcompare
}
287 \func{void
}{operator ==
}{\param{const wxURI\&
}{uricomp
}}
289 Compares this URI to another URI, and returns
\true if
290 this URI equals
\arg{uricomp
}, otherwise it returns
\false.
292 \docparam{uricomp
}{URI to compare to
}
295 \membersection{wxURI::Resolve
}\label{wxuriresolve
}
297 \func{void
}{Resolve
}{\param{const wxURI\&
}{base
},
\param{int
}{flags =
\texttt{wxURI
\_STRICT}}}
299 Inherits this URI from a base URI - components that do not
300 exist in this URI are copied from the base, and if this URI's
301 path is not an absolute path (prefixed by a '/'), then this URI's
302 path is merged with the base's path.
304 For instance, resolving "../mydir" from "http://mysite.com/john/doe"
305 results in the scheme (http) and server (mysite.com) being copied into
306 this URI, since they do not exist. In addition, since the path
307 of this URI is not absolute (does not begin with '/'), the path
308 of the base's is merged with this URI's path, resulting in the URI
309 "http://mysite.com/john/mydir".
311 \docparam{base
}{Base URI to inherit from. Must be a full URI and not a reference
}
312 \docparam{flags
}{Currently either
\texttt{wxURI
\_STRICT} or $
0$, in non strict
313 mode some compatability layers are enabled to allow loopholes from RFCs prior
316 \membersection{wxURI::Unescape
}\label{wxuriunescape
}
318 \func{wxString
}{Unescape
}{\param{const wxString\&
}{uri
}}
320 Translates all escape sequences (
% hex hex) of \arg{uri} into
321 normal characters and returns the result.
323 This is the preferred over wxURL::ConvertFromURI.
325 If you want to unescape an entire wxURI, use BuildUnescapedURI instead,
326 as it performs some optimizations over this method.
328 \docparam{uri
}{string with escaped characters to convert
}