]>
git.saurik.com Git - wxWidgets.git/blob - interface/uri.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxURI
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 wxURI is used to extract information from
14 a URI (Uniform Resource Identifier).
16 For information about URIs, see
19 In short, a URL is a URI. In other
20 words, URL is a subset of a URI - all
21 acceptable URLs are also acceptable URIs.
23 wxURI automatically escapes invalid characters in a string,
24 so there is no chance of wxURI "failing" on construction/creation.
26 wxURI supports copy construction and standard assignment
27 operators. wxURI can also be inherited from to provide
28 furthur functionality.
35 class wxURI
: public wxObject
40 Copies this URI from another URI.
43 URI (Uniform Resource Identifier) to initialize with
46 wxURI(const wxChar
* uri
);
47 wxURI(const wxURI
& uri
);
51 Builds the URI from its individual components and adds proper separators.
52 If the URI is not a reference or is not resolved,
53 the URI that is returned from Get is the same one
56 wxString
BuildURI() const;
59 Builds the URI from its individual components, adds proper separators, and
60 returns escape sequences to normal characters.
61 Note that it is preferred to call this over Unescape(BuildURI()) since
62 BuildUnescapedURI() performs some optimizations over the plain method.
64 wxString
BuildUnescapedURI() const;
67 Creates this URI from the string
71 Returns the position at which parsing stopped (there
72 is no such thing as an "invalid" wxURI).
75 string to initialize from
77 const wxChar
* Create(const wxString uri
);
80 Note that on URIs with a "file" scheme wxURI does not
81 parse the userinfo, server, or port portion. This is to keep
82 compatability with wxFileSystem, the old wxURL, and older url specifications.
87 Obtains the fragment of this URI.
88 The fragment of a URI is the last value of the URI,
89 and is the value after a '' character after the path
91 @c http://mysite.com/mypath#fragment
93 const wxString
GetFragment() const;
96 Obtains the host type of this URI, which is of type
101 Server is a host name, or the Server component itself is undefined.
105 Server is a IP version 4 address (XXX.XXX.XXX.XXX)
109 Server is a IP version 6 address ((XXX:)XXX::(XXX)XXX:XXX
113 Server is an IP address, but not versions 4 or 6
115 const HostType
GetHostType() const;
118 Returns the password part of the userinfo component of
119 this URI. Note that this is explicitly depreciated by
120 RFC 1396 and should generally be avoided if possible.
121 @c http://user:password@mysite.com/mypath
123 const wxString
GetPassword() const;
126 Returns the (normalized) path of the URI.
127 The path component of a URI comes
128 directly after the scheme component
129 if followed by zero or one slashes ('/'),
130 or after the server/port component.
131 Absolute paths include the leading '/'
133 @c http://mysite.compath
135 const wxString
GetPath() const;
138 Returns a string representation of the URI's port.
139 The Port of a URI is a value after the server, and
140 must come after a colon (:).
141 @c http://mysite.com:port
142 Note that you can easily get the numeric value of the port
143 by using wxAtoi or wxString::Format.
145 const wxString
GetPort() const;
148 Returns the Query component of the URI.
149 The query component is what is commonly passed to a
150 cgi application, and must come after the path component,
151 and after a '?' character.
152 @c http://mysite.com/mypath?query
154 const wxString
GetQuery() const;
157 Returns the Scheme component of the URI.
158 The first part of the uri.
159 @c scheme://mysite.com
161 const wxString
GetScheme() const;
164 Returns the Server component of the URI.
165 The server of the uri can be a server name or
166 a type of ip address. See
167 GetHostType() for the
168 possible values for the host type of the
170 @c http://server/mypath
172 const wxString
GetServer() const;
175 Returns the username part of the userinfo component of
176 this URI. Note that this is explicitly depreciated by
177 RFC 1396 and should generally be avoided if possible.
178 @c http://user:password@mysite.com/mypath
180 const wxString
GetUser() const;
183 Returns the UserInfo component of the URI.
184 The component of a URI before the server component
185 that is postfixed by a '@' character.
186 @c http://userinfo@mysite.com/mypath
188 const wxString
GetUserInfo() const;
191 Returns @true if the Fragment component of the URI exists.
193 bool HasFragment() const;
196 Returns @true if the Path component of the URI exists.
198 bool HasPath() const;
201 Returns @true if the Port component of the URI exists.
203 bool HasPort() const;
206 Returns @true if the Query component of the URI exists.
208 bool HasQuery() const;
211 Returns @true if the Scheme component of the URI exists.
213 bool HasScheme() const;
216 Returns @true if the Server component of the URI exists.
218 bool HasServer() const;
221 Returns @true if the User component of the URI exists.
223 bool HasUser() const;
226 Returns @true if a valid [absolute] URI, otherwise this URI
227 is a URI reference and not a full URI, and IsReference
230 bool IsReference() const;
233 To obtain individual components you can use
234 one of the following methods
248 However, you should check HasXXX before
249 calling a get method, which determines whether or not the component referred
250 to by the method is defined according to RFC 2396.
251 Consider an undefined component equivalent to a
260 @ref hasserver() HasPort
272 Inherits this URI from a base URI - components that do not
273 exist in this URI are copied from the base, and if this URI's
274 path is not an absolute path (prefixed by a '/'), then this URI's
275 path is merged with the base's path.
276 For instance, resolving "../mydir" from "http://mysite.com/john/doe"
277 results in the scheme (http) and server (mysite.com) being copied into
278 this URI, since they do not exist. In addition, since the path
279 of this URI is not absolute (does not begin with '/'), the path
280 of the base's is merged with this URI's path, resulting in the URI
281 "http://mysite.com/john/mydir".
284 Base URI to inherit from. Must be a full URI and not a reference
286 Currently either wxURI_STRICT or 0, in non-strict
287 mode some compatibility layers are enabled to allow loopholes from RFCs
291 void Resolve(const wxURI
& base
, int flags
= wxURI_STRICT
);
294 Translates all escape sequences (normal characters and returns the result.
295 This is the preferred over deprecated wxURL::ConvertFromURI.
296 If you want to unescape an entire wxURI, use BuildUnescapedURI() instead,
297 as it performs some optimizations over this method.
300 string with escaped characters to convert
302 wxString
Unescape(const wxString
& uri
);
305 Compares this URI to another URI, and returns @true if
308 @param uricomp, otherwise it returns @false.
313 void operator ==(const wxURI
& uricomp
);