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 - most
23 acceptable URLs are also acceptable URIs.
25 wxURI can be used to validate URIs:
29 //will not print "Bad URI" because this is a valid URI
30 if(!myuri.Create(("ftp://mysiteftp.com/mydir")))
35 //will print "Bad URI" because ::x:: is not a valid URI
36 if(!mybaduri.Create(("::x::")))
40 wxURI also has some uses that may not be apparent at first,
41 such as skipping past a URI in a string:
44 wxString mystring = wxT("http://mysite.com A Good Website");
46 //mystring will contain " A Good Website" after URI::Create()
47 mystring = myuri.Extract(mystring);
50 wxURI supports copy construction and standard assignment
51 operators. wxURI can also be inherited from to provide
52 furthur functionality.
54 \wxheading{Derived from
}
58 \wxheading{Include files
}
62 \latexignore{\rtfignore{\wxheading{Members
}}}
64 \membersection{Obtaining individual components
}
66 To obtain individual components you can use
67 one of the following methods:
69 \helpref{GetScheme
}{wxurigetscheme
}\\
70 \helpref{GetUser
}{wxurigetuser
}\\
71 \helpref{GetServer
}{wxurigetserver
}\\
72 \helpref{GetPort
}{wxurigetserver
}\\
73 \helpref{GetPath
}{wxurigetpath
}\\
74 \helpref{GetQuery
}{wxurigetquery
}\\
75 \helpref{GetFragment
}{wxurigetfragment
}
77 However, you should check HasXXX before
80 \helpref{HasScheme
}{wxurihasscheme
}\\
81 \helpref{HasUser
}{wxurihasuser
}\\
82 \helpref{HasServer
}{wxurihasserver
}\\
83 \helpref{HasPort
}{wxurihasserver
}\\
84 \helpref{HasPath
}{wxurihaspath
}\\
85 \helpref{HasQuery
}{wxurihasquery
}\\
86 \helpref{HasFragment
}{wxurihasfragment
}
90 //protocol will hold the http protocol (i.e. "http")
92 wxURI myuri(wxT("http://mysite.com"));
94 protocol = myuri.GetScheme();
97 Also, you can get the numeric value of the URI's port
98 component by calling
\helpref{GetPortValue
}{wxurigetportvalue
},
99 and the host type of the server component by calling
100 \helpref{GetHostType
}{wxurigethosttype
}
102 \membersection{wxURI::wxURI
}\label{wxuriwxuri
}
104 \func{}{wxURI
}{\void}
106 Creates an empty URI. In order for the URI to be
107 useful, Create needs to be called eventually.
109 \membersection{wxURI::
\destruct{wxURI
}}\label{wxuridtor
}
111 \func{}{wxURI
}{\param{const wxChar*
}{uri
}}
113 Constructor for quick creation
115 \docparam{uri
}{string to initialize with
}
118 \func{}{wxURI
}{\param{const wxURI&
}{uri
}}
120 Copies this URI from another URI.
122 \docparam{uri
}{URI (Uniform Resource Identifier) to initialize with
}
125 \membersection{wxURI::Create
}\label{wxuricreate
}
127 \func{const wxChar*
}{Create
}{\param{const wxChar*
}{uri
}}
129 Creates this URI from a string, and parses
\arg{uri
} for validity.
130 Returns the position where parsing stopped in string,
131 or false if
\arg{uri
} is not a valid URI.
133 \docparam{uri
}{string to initialize from
}
135 \membersection{wxURI::Get
}\label{wxuriget
}
137 \constfunc{wxString
}{Get
}{\void}
139 Obtains the full URI.
141 If the URI is not a reference or is not resolved,
142 the URI that is returned from Get is the same one
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}
172 \membersection{wxURI::GetPath
}\label{wxurigetpath
}
174 \constfunc{const wxString&
}{GetPath
}{\void}
176 Returns the (normalized) path of the URI.
178 The path component of a URI comes
179 directly after the scheme component
180 if followed by zero or one slashes ('/'),
181 or after the server/port component.
183 Absolute paths include the leading '/'
186 \tt{http://mysite.com<path>
}
188 \membersection{wxURI::GetPort
}\label{wxurigetport
}
190 \constfunc{const wxString&
}{GetPort
}{\void}
192 Returns a string representation of the URI's port.
194 The Port of a URI is a value after the server, and
195 must come after a colon (:).
197 \tt{http://mysite.com:<port>
}
199 Note that you can easily get the numeric value of the port
200 by using wxAtoi or wxString::Format.
202 \membersection{wxURI::GetQuery
}\label{wxurigetquery
}
204 \constfunc{const wxString&
}{GetQuery
}{\void}
206 Returns the Query component of the URI.
208 The query component is what is commonly passed to a
209 cgi application, and must come after the path component,
210 and after a '?' character.
212 \tt{http://mysite.com/mypath?<query>
}
215 \membersection{wxURI::GetScheme
}\label{wxurigetscheme
}
217 \constfunc{const wxString&
}{GetScheme
}{\void}
219 Returns the Scheme component of the URI.
221 The first part of the uri.
223 \tt{<scheme>://mysite.com
}
226 \membersection{wxURI::GetServer
}\label{wxurigetserver
}
228 \constfunc{const wxString&
}{GetServer
}{\void}
230 Returns the Server component of the URI.
232 The server of the uri can be a server name or
233 a type of ip address. See
234 \helpref{GetHostType
}{wxurigethosttype
} for the
235 possible values for the host type of the
238 \tt{http://<server>/mypath
}
241 \membersection{wxURI::GetUser
}\label{wxurigetuser
}
243 \constfunc{const wxString&
}{GetUser
}{\void}
245 Returns the User component of the URI.
247 The component of a URI before the server component
248 that is postfixed by a '@' character.
250 \tt{http://<user>@mysite.com/mypath
}
252 \membersection{wxURI::HasFragment
}\label{wxurihasfragment
}
254 \constfunc{bool
}{HasFragment
}{\void}
256 Returns true if the Fragment component of the URI exists.
258 \membersection{wxURI::HasPath
}\label{wxurihaspath
}
260 \constfunc{bool
}{HasPath
}{\void}
262 Returns true if the Path component of the URI exists.
264 \membersection{wxURI::HasPort
}\label{wxurihasport
}
266 \constfunc{bool
}{HasPort
}{\void}
268 Returns true if the Port component of the URI exists.
271 \membersection{wxURI::HasQuery
}\label{wxurihasquery
}
273 \constfunc{bool
}{HasQuery
}{\void}
275 Returns true if the Query component of the URI exists.
278 \membersection{wxURI::HasScheme
}\label{wxurihasscheme
}
280 \constfunc{bool
}{HasScheme
}{\void}
282 Returns true if the Scheme component of the URI exists.
285 \membersection{wxURI::HasServer
}\label{wxurihasserver
}
287 \constfunc{bool
}{HasServer
}{\void}
289 Returns true if the Server component of the URI exists.
292 \membersection{wxURI::HasUser
}\label{wxurihasuser
}
294 \constfunc{bool
}{HasUser
}{\void}
296 Returns true if the User component of the URI exists.
299 \membersection{wxURI::IsOk
}\label{wxuriisok
}
301 \constfunc{bool
}{IsOk
}{\void}
303 Returns true if this is a valid URI.
306 \membersection{wxURI::IsReference
}\label{wxuriisreference
}
308 \constfunc{bool
}{IsReference
}{\void}
310 Returns true if a valid
[absolute
] URI, otherwise this URI
311 is a URI reference and not a full URI, and IsReference
315 \membersection{wxURI::operator ==
}\label{wxurioperatorcompare
}
317 \func{void
}{operator ==
}{\param{const wxURI&
}{uricomp
}}
319 Compares this URI to another URI, and returns true if
320 this URI equals uricomp, otherwise it returns false.
322 \docparam{uricomp
}{URI to compare to
}
325 \membersection{wxURI::Extract
}\label{wxuriextract
}
327 \func{static const wxChar*
}{Extract
}{\param{const wxChar*
}{uri
}}
329 Used to determine where a URI ends in a string.
331 Returns the position at which parsing stopped
332 (will return NULL on malformed URIs).
334 \docparam{uri
}{String to create from
}
337 \membersection{wxURI::Resolve
}\label{wxuriresolve
}
339 \func{void
}{Resolve
}{\param{const wxURI\&
}{base
},
\param{const bool\&
}{bStrict = true
}}
341 Inherits this URI from a base URI - components that do not
342 exist in this URI are copied from the base, and if this URI's
343 path is not an absolute path (prefixed by a '/'), then this URI's
344 path is merged with the base's path.
346 For instance, resolving "../mydir" from "http://mysite.com/john/doe"
347 results in the scheme (http) and server (mysite.com) being copied into
348 this URI, since they do not exist. In addition, since the path
349 of this URI is not absolute (does not begin with '/'), the path
350 of the base's is merged with this URI's path, resulting in the URI
351 "http://mysite.com/john/mydir".
353 \docparam{base
}{Base URI to inherit from. Must be a full URI and not a reference
}
354 \docparam{bStrict
}{If false, some compatability layers are enabled to allow
355 loopholes from RFCs prior to
2396}