#include <kurl.h>
Public Types | |
| enum | QueryItemsOptions |
Public Methods | |
| KURL () | |
| ~KURL () | |
| KURL (const QString &url, int encoding_hint=0) | |
| KURL (const char *url, int encoding_hint=0) | |
| KURL (const QCString &url, int encoding_hint=0) | |
| KURL (const KURL &u) | |
| KURL (const QUrl &u) | |
| KURL (const KURL &_baseurl, const QString &_rel_url, int encoding_hint=0) | |
| QString | protocol () const |
| void | setProtocol (const QString &_txt) |
| QString | user () const |
| void | setUser (const QString &_txt) |
| bool | hasUser () const |
| QString | pass () const |
| void | setPass (const QString &_txt) |
| bool | hasPass () const |
| QString | host () const |
| void | setHost (const QString &_txt) |
| bool | hasHost () const |
| unsigned short int | port () const |
| void | setPort (unsigned short int _p) |
| QString | path () const |
| QString | path (int _trailing) const |
| void | setPath (const QString &path) |
| bool | hasPath () const |
| void | cleanPath (bool cleanDirSeparator=true) |
| void | adjustPath (int _trailing) |
| void | setEncodedPathAndQuery (const QString &_txt, int encoding_hint=0) |
| void | setEncodedPath (const QString &_txt, int encoding_hint=0) |
| QString | encodedPathAndQuery (int _trailing=0, bool _no_empty_path=false, int encoding_hint=0) const |
| void | setQuery (const QString &_txt, int encoding_hint=0) |
| QString | query () const |
| QString | ref () const |
| void | setRef (const QString &_txt) |
| bool | hasRef () const |
| QString | htmlRef () const |
| QString | encodedHtmlRef () const |
| void | setHTMLRef (const QString &_ref) |
| bool | hasHTMLRef () const |
| bool | isValid () const |
| bool | isMalformed () const |
| bool | isLocalFile () const |
| void | setFileEncoding (const QString &encoding) |
| QString | fileEncoding () const |
| bool | hasSubURL () const |
| void | addPath (const QString &_txt) |
| QString | queryItem (const QString &_item) const |
| QMap< QString, QString > | queryItems (int options=0) const |
| void | addQueryItem (const QString &_item, const QString &_value, int encoding_hint=0) |
| void | removeQueryItem (const QString &_item) |
| void | setFileName (const QString &_txt) |
| QString | fileName (bool _ignore_trailing_slash_in_path=true) const |
| QString | directory (bool _strip_trailing_slash_from_result=true, bool _ignore_trailing_slash_in_path=true) const |
| bool | cd (const QString &_dir) |
| QString | url (int _trailing=0, int encoding_hint=0) const |
| QString | prettyURL (int _trailing=0) const |
| QString | htmlURL () const |
| QString | prettyURL (int _trailing, AdjustementFlags _flags) const |
| bool | isEmpty () const |
| KURL | upURL () const |
| bool | cmp (const KURL &u, bool ignore_trailing=false) const |
| bool | equals (const KURL &u, bool ignore_trailing=false) const |
| bool | isParentOf (const KURL &u) const |
Static Public Methods | |
| List | split (const QString &_url) |
| List | split (const KURL &_url) |
| KURL | join (const List &_list) |
| KURL | fromPathOrURL (const QString &text) |
| QString | encode_string (const QString &str, int encoding_hint=0) |
| QString | encode_string_no_slash (const QString &str, int encoding_hint=0) |
| QString | decode_string (const QString &str, int encoding_hint=0) |
| bool | isRelativeURL (const QString &_url) |
A prototypical URL looks like:
protocol:/user:password@hostname:port/path/to/file.extreference
KURL has some restrictions regarding the path encoding. KURL works internally with the decoded path and and encoded query. For example,
http://localhost/cgi-bin/test%20me.pl?cmd=Hello%20youwould result in a decoded path "/cgi-bin/test me.pl" and in the encoded query "?cmd=Hello%20you". Since path is internally always encoded you may not use "%00" in the path, although this is OK for the query.
Definition at line 52 of file kurl.h.
|
|
Options for queryItems. Currently, only one option is defined:
|
|
|
Constructs an empty URL. |
|
|
Destructs the KURL object. |
|
||||||||||||
|
Usual constructor, to construct from a string.
|
|
||||||||||||
|
Constructor taking a char *
|
|
||||||||||||
|
Constructor taking a QCString
|
|
|
Copy constructor.
|
|
|
Converts from a QUrl.
|
|
||||||||||||||||
|
Constructor allowing relative URLs.
|
|
|
Adds to the current path. Assumes that the current path is a directory.
|
|
||||||||||||||||
|
Add an additional query item. To replace an existing query item, the item should first be removed with removeQueryItem()
|
|
|
Add or remove a trailing slash to/from the path.
|
|
|
Changes the directory by descending into the given directory. It is assumed the current URL represents a directory. If
|
|
|
Resolves "." and ".." components in path. Some servers seem not to like the removal of extra '/' even though it is against the specification in RFC 2396.
|
|
||||||||||||
|
The same as equals(), just with a less obvious name. Compares this url with
|
|
||||||||||||
|
Convenience function. Decode %-style encoding and convert from local encoding to unicode. Reverse of encode_string()
|
|
||||||||||||
|
Returns the directory of the path.
|
|
||||||||||||
|
Convenience function. Convert unicoded string to local encoding and use %-style encoding for all common delimiters / non-ascii characters.
|
|
||||||||||||
|
Convenience function. Convert unicoded string to local encoding and use %-style encoding for all common delimiters / non-ascii characters as well as the slash '/'.
|
|
|
Returns the HTML reference (the part of the URL after "#") in encoded form.
|
|
||||||||||||||||
|
Returns the encoded path and the query.
|
|
||||||||||||
|
Compares this url with
|
|
|
Returns encoding information from url, the content of the "charset" parameter.
|
|
|
Returns the filename of the path.
|
|
|
Creates a KURL object from a QString representing either an absolute path or a real URL. Use this method instead of QString someDir = ... KURL url = someDir; Otherwise some characters (e.g. the '#') won't be encoded properly.
|
|
|
Test to see if this URL has a hostname included in it.
|
|
|
Checks whether there is a HTML reference.
|
|
|
Test to see if this URL has a password included in it.
|
|
|
Test to see if this URL has a path is included in it.
|
|
|
Checks whether the URL has a reference part.
|
|
|
Checks whether the URL has any sub URLs. See split() for examples for sub URLs.
|
|
|
Test to see if this URL has a user name included in it.
|
|
|
Returns the decoded hostname included in the URL.
|
|
|
Returns the HTML reference (the part of the URL after "#").
|
|
|
Returns the URL as string, escaped for HTML.
|
|
|
Test to see if the KURL is empty.
|
|
|
Checks whether the file is local.
|
|
|
Definition at line 423 of file kurl.h. References isValid(). |
|
|
Checks whether the given URL is parent of this URL. For instance, ftp://host/dir/ is a parent of ftp://host/dir/subdir/subsubdir/.
|
|
|
Convenience function. Returns whether '_url' is likely to be a "relative" URL instead of an "absolute" URL.
|
|
|
Checks whether the URL is well formed.
Definition at line 419 of file kurl.h. Referenced by isMalformed(). |
|
|
Reverses split(). Only the first URL may have a reference. This reference is considered to be HTML-like and is appended at the end of the resulting joined URL.
|
|
|
Returns the decoded password (corresponding to user()) included in the URL.
|
|
|
|
|
|
Returns the current decoded path. This does not include the query.
Definition at line 250 of file kurl.h. Referenced by KDirOperator::isRoot(). |
|
|
Returns the port number included in the URL.
|
|
||||||||||||
|
Returns the URL as string, escaped for HTML. Example: http://localhost:8080/test.cgi?test=hello world&name=fred
|
|
|
Returns the URL as string in human-friendly format. Example: http://localhost:8080/test.cgi?test=hello world&name=fred
|
|
|
Returns the protocol for the URL (i.e., file, http, etc.).
|
|
|
Returns the query of the URL. The query may contain the 0 character. If a query is present it always starts with a '?'. A single '?' means an empty query. An empty string means no query.
|
|
|
Returns the value of a certain query item.
|
|
|
Returns the list of query items as a map mapping keys to values.
|
|
|
The reference is never decoded automatically.
|
|
|
Remove an item from the query.
|
|
||||||||||||
|
Sets the (already encoded) path
|
|
||||||||||||
|
This is useful for HTTP. It looks first for '?' and decodes then. The encoded path is the concatenation of the current path and the query.
|
|
|
Adds encoding information to url by adding a "charset" parameter. If there is already a charset parameter, it will be replaced.
|
|
|
Sets the filename of the path. In comparison to addPath() this function does not assume that the current path is a directory. This is only assumed if the current path ends with '/'. Any reference is reset.
|
|
|
Sets the hostname included in the URL. Special characters in the hostname will appear encoded in the URL.
|
|
|
Sets the HTML-style reference.
|
|
|
Sets the password (corresponding to user()) included in the URL. Special characters in the password will appear encoded in the URL. Note that a password can only appear in a URL string if you also set a user.
|
|
|
Sets the path of the URL. The query is not changed by this function.
|
|
|
Sets the port number included in the URL.
|
|
|
Sets the protocol for the URL (i.e., file, http, etc.)
|
|
||||||||||||
|
|
|
|
Sets the reference part (everything after '#').
|
|
|
Sets the user name (login, user id, ...) included in the URL. Special characters in the user name will appear encoded in the URL.
|
|
|
Splits nested URLs like file:/home/weis/kde.tgz#gzip:/#tar:/kdebase A URL like http://www.kde.org#tar:/kde/README.hml#ref1 will be split in http://www.kde.org and tar:/kde/README.htmlref1. That means in turn that "ref1" is an HTML-style reference and not a new sub URL. Since HTML-style references mark a certain position in a document this reference is appended to every URL. The idea behind this is that browsers, for example, only look at the first URL while the rest is not of interest to them.
|
|
|
Splits nested URLs like file:/home/weis/kde.tgz#gzip:/#tar:/kdebase A URL like http://www.kde.org#tar:/kde/README.hml#ref1 will be split in http://www.kde.org and tar:/kde/README.htmlref1. That means in turn that "ref1" is an HTML-style reference and not a new sub URL. Since HTML-style references mark a certain position in a document this reference is appended to every URL. The idea behind this is that browsers, for example, only look at the first URL while the rest is not of interest to them.
|
|
|
This function is useful to implement the "Up" button in a file manager for example. cd() never strips a sub-protocol. That means that if you are in file:/home/x.tgz#gzip:/#tar:/ and hit the up button you expect to see file:/home. The algorithm tries to go up on the right-most URL. If that is not possible it strips the right most URL. It continues stripping URLs.
|
|
||||||||||||
|
Returns the URL as string.
|
|
|
Returns the decoded user name (login, user id, ...) included in the URL.
|
1.2.18