• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | Related Functions | List of all members
KURL Class Reference

#include <kurl.h>

Classes

class  List
 

Public Types

enum  AdjustementFlags { NoAdjustements = 0 , StripFileProtocol = 1 }
 
enum  URIMode {
  Auto , Invalid , RawURI , URL ,
  Mailto
}
 
enum  QueryItemsOptions { CaseInsensitiveKeys = 1 }
 

Public Member Functions

 KURL ()
 
 ~KURL ()
 
 KURL (const TQString &url, int encoding_hint=0)
 
 KURL (const char *url, int encoding_hint=0)
 
 KURL (const TQCString &url, int encoding_hint=0)
 
 KURL (const KURL &u)
 
 KURL (const TQUrl &u)
 
 KURL (const KURL &_baseurl, const TQString &_rel_url, int encoding_hint=0)
 
TQString protocol () const
 
void setProtocol (const TQString &_txt)
 
int uriMode () const
 
TQString user () const
 
void setUser (const TQString &_txt)
 
bool hasUser () const
 
TQString pass () const
 
void setPass (const TQString &_txt)
 
bool hasPass () const
 
TQString host () const
 
void setHost (const TQString &_txt)
 
bool hasHost () const
 
unsigned short int port () const
 
void setPort (unsigned short int _p)
 
TQString path () const
 
TQString path (int _trailing) const
 
void setPath (const TQString &path)
 
bool hasPath () const
 
void setInternalReferenceURL (const TQString &url)
 
TQString internalReferenceURL (void) const
 
void cleanPath (bool cleanDirSeparator=true)
 
void adjustPath (int _trailing)
 
void setEncodedPathAndQuery (const TQString &_txt, int encoding_hint=0)
 
void setEncodedPath (const TQString &_txt, int encoding_hint=0)
 
TQString encodedPathAndQuery (int _trailing=0, bool _no_empty_path=false, int encoding_hint=0) const
 
void setQuery (const TQString &_txt, int encoding_hint=0)
 
TQString query () const
 
TQString ref () const
 
void setRef (const TQString &_txt)
 
bool hasRef () const
 
TQString htmlRef () const
 
TQString encodedHtmlRef () const
 
void setHTMLRef (const TQString &_ref)
 
bool hasHTMLRef () const
 
bool isValid () const
 
TDE_DEPRECATED bool isMalformed () const
 
bool isLocalFile () const
 
void setFileEncoding (const TQString &encoding)
 
TQString fileEncoding () const
 
bool hasSubURL () const
 
void addPath (const TQString &txt)
 
TQString queryItem (const TQString &item) const
 
TQString queryItem (const TQString &item, int encoding_hint) const
 
TQMap< TQString, TQString > queryItems (int options=0) const
 
TQMap< TQString, TQString > queryItems (int options, int encoding_hint) const
 
void addQueryItem (const TQString &_item, const TQString &_value, int encoding_hint=0)
 
void removeQueryItem (const TQString &_item)
 
void setFileName (const TQString &_txt)
 
TQString fileName (bool _ignore_trailing_slash_in_path=true) const
 
TQString directory (bool _strip_trailing_slash_from_result=true, bool _ignore_trailing_slash_in_path=true) const
 
void setDirectory (const TQString &dir)
 
bool cd (const TQString &_dir)
 
TQString url (int _trailing=0, int encoding_hint=0) const
 
TQString prettyURL (int _trailing=0) const
 
TQString prettyURL (int _trailing, AdjustementFlags _flags) const
 
TQString pathOrURL () const
 
TQString htmlURL () const
 
bool isEmpty () const
 
KURL upURL () const
 
bool operator< (const KURL &_u) const
 
KURL & operator= (const KURL &_u)
 
KURL & operator= (const TQString &_url)
 
KURL & operator= (const char *_url)
 
KURL & operator= (const TQUrl &u)
 
bool operator== (const KURL &_u) const
 
bool operator== (const TQString &_u) const
 
bool operator!= (const KURL &_u) const
 
bool operator!= (const TQString &_u) const
 
bool cmp (const KURL &u, bool ignore_trailing=false) const TDE_DEPRECATED
 
bool equals (const KURL &u, bool ignore_trailing=false) const
 
bool equals (const KURL &u, bool ignore_trailing, bool ignore_internalReferenceURLS) const
 
bool isParentOf (const KURL &u) const
 
TQString filename (bool _ignore_trailing_slash_in_path=true) const
 

Static Public Member Functions

static List split (const TQString &_url)
 
static List split (const KURL &_url)
 
static KURL join (const List &_list)
 
static KURL fromPathOrURL (const TQString &text)
 
static TQString encode_string (const TQString &str, int encoding_hint=0)
 
static TQString encode_string_no_slash (const TQString &str, int encoding_hint=0)
 
static TQString decode_string (const TQString &str, int encoding_hint=0)
 
static bool isRelativeURL (const TQString &_url)
 
static TQString relativeURL (const KURL &base_url, const KURL &url, int encoding_hint=0)
 
static TQString relativePath (const TQString &base_dir, const TQString &path, bool *isParent=0)
 
static URIMode uriModeForProtocol (const TQString &protocol)
 

Protected Member Functions

void reset ()
 
void parseURL (const TQString &_url, int encoding_hint=0)
 
void parseRawURI (const TQString &_url, int encoding_hint=0)
 
void parseMailto (const TQString &_url, int encoding_hint=0)
 
void parse (const TQString &_url, int encoding_hint=0)
 

Friends

TQDataStream & operator<< (TQDataStream &s, const KURL &a)
 
TQDataStream & operator>> (TQDataStream &s, KURL &a)
 

Related Functions

(Note that these are not member functions.)

bool urlcmp (const TQString &_url1, const TQString &_url2)
 
bool urlcmp (const TQString &_url1, const TQString &_url2, bool _ignore_trailing, bool _ignore_ref)
 

Detailed Description

Represents and parses a URL.

A prototypical URL looks like:

protocol://user:password@hostname:port/path/to/file.ext#reference
KURL::protocol
TQString protocol() const
Returns the protocol for the URL.
Definition: kurl.h:367

KURL handles escaping of URLs. This means that the specification of a full URL will differ from the corresponding string that would specify a local file or directory in file-operations like fopen. This is because an URL doesn't allow certain characters and escapes them.

For examle:

  • '#' -> "%23" (In a URL the hash-character '#' is used to specify a "reference", i.e. the position within a document)
  • space -> "%20"

The constructor KURL(const TQString&) expects a string properly escaped, or at least non-ambiguous. For instance a local file or directory "/bar/#foo#" would have the URL "file:///bar/%23foo%23". If you have the absolute path and need the URL-escaping you should create KURL via the default-constructor and then call setPath(const TQString&):

KURL kurl;
kurl.setPath( "/bar/#foo#" );
TQString url = kurl.url(); // -> "file:///bar/%23foo%23"
KURL
Represents and parses a URL.
Definition: kurl.h:128
KURL::setPath
void setPath(const TQString &path)
Sets the decoded path of the URL.
Definition: kurl.cpp:2025
KURL::url
TQString url(int _trailing=0, int encoding_hint=0) const
Returns the URL as string, with all escape sequences intact, encoded in a given charset.
Definition: kurl.cpp:1499

If you have the URL of a local file or directory and need the absolute path, you would use path().

KURL url( "file:///bar/%23foo%23" );
...
if ( url.isLocalFile() )
TQString path = url.path(); // -> "/bar/#foo#"
KURL::path
TQString path() const
Returns the current decoded path.
Definition: kurl.h:532

The other way round: if the user can enter a string, that can be either a path or a URL, then you need to use KURL::fromPathOrURL() to build a KURL.

This must also be considered, when you have separated directory and file strings and need to put them together. While you can simply concatenate normal path strings, you must take care if the directory-part is already an escaped URL. (This might be needed if the user specifies a relative path, and your program supplies the rest from elsewhere.)

Wrong:

TQString dirUrl = "file:///bar/";
TQString fileName = "#foo#";
TQString invalidURL = dirUrl + fileName; // -> "file:///bar/#foo#" won't behave like you would expect.
KURL::fileName
TQString fileName(bool _ignore_trailing_slash_in_path=true) const
Returns the filename of the path.
Definition: kurl.cpp:1709

Instead you should use addPath().

Right:

KURL url( "file:///bar/" );
TQString fileName = "#foo#";
url.addPath( fileName );
TQString validURL = url.url(); // -> "file:///bar/%23foo%23"

Also consider that some URLs contain the password, but this shouldn't be visible. Your program should use prettyURL() every time it displays a URL, whether in the GUI or in debug output or...

KURL url( "ftp://name:password@ftp.faraway.org/bar/%23foo%23");
TQString visibleURL = url.prettyURL(); // -> "ftp://name@ftp.faraway.org/bar/%23foo%23"

Note that prettyURL() doesn't change the character escapes (like "%23"). Otherwise the URL would be invalid and the user wouldn't be able to use it in another context.

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%20you

would 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.

Author
Torben Weis weis@.nosp@m.kde..nosp@m.org

Definition at line 127 of file kurl.h.

Member Enumeration Documentation

◆ AdjustementFlags

enum KURL::AdjustementFlags

Flags to choose how file: URLs are treated when creating their TQString representation with prettyURL(int,AdjustementFlags)

However it is recommended to use pathOrURL() instead of this variant of prettyURL()

Enumerator
NoAdjustements 

Do not treat file: URLs differently.

StripFileProtocol 

Strip the file: protocol from the string, i.e.

return only the path and filename as a local path

Definition at line 136 of file kurl.h.

◆ QueryItemsOptions

enum KURL::QueryItemsOptions

Options for queryItems()

Since
3.1
Enumerator
CaseInsensitiveKeys 

Normalize query keys to lowercase.

Definition at line 935 of file kurl.h.

◆ URIMode

enum KURL::URIMode

Defines the type of URI we are processing.

Enumerator
Auto 

Automatically detected.

Using this mode, an appropriate processing mode will be selected when the URI is first processed.

Invalid 

Invalid URI.

This is something that can't be parsed as a URI at all. The contents are accessible through the protocol() method.

RawURI 

Raw URI.

This type of URI should not be processed in any way. Contents are accessible through the path() method.

URL 

Standards compliant URL.

Process as a syntactically correct URL.

Mailto 

Mailto URI.

path() contains an email address which should have its domain part processed as a DNS name. The email address is accessible through the path() method.

Definition at line 152 of file kurl.h.

Constructor & Destructor Documentation

◆ KURL() [1/7]

KURL::KURL ( )

Constructs an empty URL.

The created instance will also be invalid, see isValid()

Definition at line 461 of file kurl.cpp.

◆ ~KURL()

KURL::~KURL ( )

Destructs the KURL object.

Definition at line 467 of file kurl.cpp.

◆ KURL() [2/7]

KURL::KURL ( const TQString &  url,
int  encoding_hint = 0 
)

Usual constructor, to construct from a string.

Warning
It is dangerous to feed UNIX filenames into this function, this will work most of the time but not always.

For example "/home/Torben%20Weis" will be considered a URL pointing to the file "/home/Torben Weis" instead of to the file "/home/Torben%20Weis".

This means that if you have a usual UNIX like path you should not use this constructor. Instead use fromPathOrURL()

Parameters
urla URL, not a filename. If the URL does not have a protocol part, "file:" is assumed
encoding_hintMIB of original encoding of URL. See TQTextCodec::mibEnum()
See also
fromPathOrURL()

Definition at line 475 of file kurl.cpp.

◆ KURL() [3/7]

KURL::KURL ( const char *  url,
int  encoding_hint = 0 
)

Constructor taking an URL encoded in a C string.

Constructor taking a char * url, which is an encoded representation of the URL, exactly like the usual constructor. This is useful when the URL, in its encoded form, is strictly ASCII.

Warning
It is dangerous to feed UNIX filenames into this function, this will work most of the time but not always.

For example "/home/Torben%20Weis" will be considered a URL pointing to the file "/home/Torben Weis" instead of to the file "/home/Torben%20Weis".

This means that if you have a usual UNIX like path you should not use this constructor. Instead use fromPathOrURL()

Parameters
urlan encoded URL. If the URL does not have a protocol part, "file:" is assumed
encoding_hintMIB of original encoding of URL. See TQTextCodec::mibEnum()
See also
fromPathOrURL()
TQString::fromLatin1()

Definition at line 482 of file kurl.cpp.

◆ KURL() [4/7]

KURL::KURL ( const TQCString &  url,
int  encoding_hint = 0 
)

Constructor taking an URL encoded in a QCString.

Constructor taking a TQCString url, which is an encoded representation of the URL, exactly like the usual constructor. This is useful when the URL, in its encoded form, is strictly ASCII.

Warning
It is dangerous to feed UNIX filenames into this function, this will work most of the time but not always.

For example "/home/Torben%20Weis" will be considered a URL pointing to the file "/home/Torben Weis" instead of to the file "/home/Torben%20Weis".

This means that if you have a usual UNIX like path you should not use this constructor. Instead use fromPathOrURL()

Parameters
urlA encoded URL. If the URL does not have a protocol part, "file:" is assumed
encoding_hintMIB of original encoding of URL. See TQTextCodec::mibEnum()
See also
fromPathOrURL()
TQString::fromLatin1()

Definition at line 489 of file kurl.cpp.

◆ KURL() [5/7]

KURL::KURL ( const KURL &  u)

Copy constructor.

Parameters
uthe KURL to copy

Definition at line 496 of file kurl.cpp.

◆ KURL() [6/7]

KURL::KURL ( const TQUrl &  u)

Constructor taking a Qt URL.

Converts from a Qt URL.

Parameters
uthe QUrl

Definition at line 537 of file kurl.cpp.

◆ KURL() [7/7]

KURL::KURL ( const KURL &  _baseurl,
const TQString &  _rel_url,
int  encoding_hint = 0 
)

Constructor allowing relative URLs.

Warning
It is dangerous to feed UNIX filenames into this function, this will work most of the time but not always.

For example "/home/Torben%20Weis" will be considered a URL pointing to the file "/home/Torben Weis" instead of to the file "/home/Torben%20Weis".

This means that if you have a usual UNIX like path you should not use this constructor. Instead use fromPathOrURL()

Parameters
_baseurlThe base url.
_rel_urlA relative or absolute URL. If this is an absolute URL then _baseurl will be ignored. If this is a relative URL it will be combined with _baseurl. Note that _rel_url should be encoded too, in any case. So do NOT pass a path here (use setPath() or addPath() or fromPathOrURL() instead)
encoding_hintMIB of original encoding of URL. See TQTextCodec::mibEnum()
See also
fromPathOrURL()

Definition at line 544 of file kurl.cpp.

Member Function Documentation

◆ addPath()

void KURL::addPath ( const TQString &  txt)

Adds to the current path.

Assumes that the current path is a directory. _txt is appended to the current path. The function adds '/' if needed while concatenating. This means it does not matter whether the current path has a trailing '/' or not. If there is none, it becomes appended. If _txt has a leading '/' then this one is stripped.

Parameters
txtthe text to add. It is considered to be decoded
See also
setPath()
hasPath()

Definition at line 1768 of file kurl.cpp.

◆ addQueryItem()

void KURL::addQueryItem ( const TQString &  _item,
const TQString &  _value,
int  encoding_hint = 0 
)

Adds an additional query item.

To replace an existing query item, the item should first be removed with removeQueryItem()

Parameters
_itemname of item to add
_valuevalue of item to add
encoding_hintMIB of encoding to use for _value. See TQTextCodec::mibEnum()
See also
queryItem()
queryItems()
query()

Definition at line 2259 of file kurl.cpp.

◆ adjustPath()

void KURL::adjustPath ( int  _trailing)

Adds or removes a trailing slash to/from the path.

The _trailing parameter allows to ensure the existance or absence of the last (trailing) '/' character in the path. If the URL has no path, then no '/' is added anyway. And on the other side: if the path is just "/", then this character won't be stripped.

Reason: "ftp://weis@host" means something completely different than "ftp://weis@host/". So adding or stripping the '/' would really alter the URL, while "ftp://host/path" and "ftp://host/path/" mean the same directory.

Parameters
_trailingMay be ( -1, 0, +1 ). -1 strips a trailing '/', +1 adds a trailing '/' if there is none yet and 0 returns the path unchanged
See also
hasPath()
cleanPath()

Definition at line 1327 of file kurl.cpp.

◆ cd()

bool KURL::cd ( const TQString &  _dir)

Changes the directory by descending into the given directory.

It is assumed the current URL represents a directory. If _dir starts with a '/' the current URL will be "protocol://host/dir" otherwise _dir will be appended to the path. _dir can be ".."

This function won't strip protocols. That means that when you are in "file:///dir/dir2/my.tgz#tar:/" and you do cd("..") you will still be in "file:///dir/dir2/my.tgz#tar:/"

Parameters
_dirthe directory to change to
Returns
true if successful
See also
directory()
path()

Definition at line 1835 of file kurl.cpp.

◆ cleanPath()

void KURL::cleanPath ( bool  cleanDirSeparator = true)

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.

Parameters
cleanDirSeparatorif true, occurrences of consecutive directory separators (e.g. "/foo//bar") are cleaned up as well
See also
hasPath()
adjustPath()

Definition at line 1288 of file kurl.cpp.

◆ cmp()

bool KURL::cmp ( const KURL &  u,
bool  ignore_trailing = false 
) const

Compares this URL with another one.

The same as equals(), just with a less obvious name.

Parameters
uthe URL to compare this one with
ignore_trailingset to true to ignore trailing '/' characters
Returns
true if both URLs are the same
See also
operator==. This function should be used if you want to ignore trailing '/' characters
Deprecated:
Use equals() instead.

Definition at line 1179 of file kurl.cpp.

◆ decode_string()

TQString KURL::decode_string ( const TQString &  str,
int  encoding_hint = 0 
)
static

Decodes a string as used in URLs.

Convenience function.

Decode %-style encoding and convert from local encoding to unicode.

Reverse of encode_string()

Parameters
strthe string to decode (can be TQString::null)
encoding_hintMIB of original encoding of str . See TQTextCodec::mibEnum()
Returns
the decoded string
See also
encode_string()
encode_string_no_slash()

Definition at line 2101 of file kurl.cpp.

◆ directory()

TQString KURL::directory ( bool  _strip_trailing_slash_from_result = true,
bool  _ignore_trailing_slash_in_path = true 
) const

Returns the directory of the path.

The directory is everything between the last and the second last '/' is returned. For example "file:///hallo/torben/" would return "/hallo/torben/" while "file:///hallo/torben" would return "hallo/".

_ignore_trailing_slash_in_path tells whether a trailing '/' should be ignored. This means that the function would return "/hallo" (or "/hallo" depending on _strip_trailing_slash_from_result) for "file:///hallo/torben/" and "file:///hallo/torben".

Parameters
_strip_trailing_slash_from_resulttells whether the returned result should end with '/' or not. If the path is empty or just "/" then this flag has no effect
_ignore_trailing_slash_in_pathif set to false, then everything behind the last '/' is considered to be the filename
Returns
the directory part of the current path or TQString::null when there is no path. The returned string is decoded
See also
setDirectory()
fileName()
path()

Definition at line 1801 of file kurl.cpp.

◆ encode_string()

TQString KURL::encode_string ( const TQString &  str,
int  encoding_hint = 0 
)
static

Encodes a string for use in URLs.

Convenience function.

Convert unicoded string to local encoding and use %%-style encoding for all common delimiters / non-ascii characters.

Parameters
strthe string to encode (can be TQString::null)
encoding_hintMIB of encoding to use. See TQTextCodec::mibEnum()
Returns
the encoded string
See also
encode_string_no_slash()
decode_string()

Definition at line 2106 of file kurl.cpp.

◆ encode_string_no_slash()

TQString KURL::encode_string_no_slash ( const TQString &  str,
int  encoding_hint = 0 
)
static

Encodes a string for use in URLs.

Convenience function.

Convert unicoded string to local encoding and use %%-style encoding for all common delimiters and non-ascii characters as well as the slash '/'.

Parameters
strthe string to encode (can be TQString::null)
encoding_hintMIB of encoding to use. See TQTextCodec::mibEnum()
See also
encode_string()
decode_string()

Definition at line 2111 of file kurl.cpp.

◆ encodedHtmlRef()

TQString KURL::encodedHtmlRef ( ) const

Returns the encoded HTML-style reference (the part of the URL after '#')

Returns
the HTML-style reference in its original, encoded, form
See also
htmlRef()
setHTMLRef()
hasHTMLRef()

Definition at line 1934 of file kurl.cpp.

◆ encodedPathAndQuery()

TQString KURL::encodedPathAndQuery ( int  _trailing = 0,
bool  _no_empty_path = false,
int  encoding_hint = 0 
) const

Returns the encoded path and the query.

The _trailing parameter allows to ensure the existance or absence of the last (trailing) '/' character in the path. If the URL has no path, then no '/' is added anyway. And on the other side: if the path is just "/", then this character won't be stripped.

Reason: "ftp://weis@host" means something completely different than "ftp://weis@host/". So adding or stripping the '/' would really alter the URL, while "ftp://host/path" and "ftp://host/path/" mean the same directory.

Parameters
_trailingMay be ( -1, 0, +1 ). -1 strips a trailing '/', +1 adds a trailing '/' if there is none yet and 0 returns the path unchanged
_no_empty_pathif set to true then an empty path is substituted by "/"
encoding_hintMIB of desired encoding of URL. See TQTextCodec::mibEnum()
Returns
the concatenation of the encoded path , '?' and the encoded query
See also
setEncodedPathAndQuery()
path()
query()

Definition at line 1337 of file kurl.cpp.

◆ equals() [1/2]

bool KURL::equals ( const KURL &  u,
bool  ignore_trailing,
bool  ignore_internalReferenceURLS 
) const

Compares this URL with another one.

Parameters
uthe URL to compare this one with
ignore_trailingset to true to ignore trailing '/' characters
ignore_internalReferenceURLSset to true to ignore the internal reference URLs during comparison
Returns
true if both urls are the same
See also
operator==. This function should be used if you want to ignore trailing '/' characters
Since
R14.0.0

Definition at line 1189 of file kurl.cpp.

◆ equals() [2/2]

bool KURL::equals ( const KURL &  u,
bool  ignore_trailing = false 
) const

Compares this URL with another one.

Parameters
uthe URL to compare this one with
ignore_trailingset to true to ignore trailing '/' characters
Returns
true if both urls are the same
See also
operator==. This function should be used if you want to ignore trailing '/' characters
Since
3.1

Definition at line 1184 of file kurl.cpp.

◆ fileEncoding()

TQString KURL::fileEncoding ( ) const

Returns encoding information of the URL.

The encoding information is the content of the "charset" parameter.

Returns
an encoding suitable for TQTextCodec::codecForName() or TQString::null if not encoding was specified

Definition at line 1447 of file kurl.cpp.

◆ fileName()

TQString KURL::fileName ( bool  _ignore_trailing_slash_in_path = true) const

Returns the filename of the path.

_ignore_trailing_slash_in_path tells whether a trailing '/' should be ignored. This means that the function would return "torben" for "file:///hallo/torben/" and "file:///hallo/torben".

Parameters
_ignore_trailing_slash_in_pathif set to false, then everything behind the last '/' is considered to be the filename
Returns
the filename of the current path. The returned string is decoded. TQString::null if there is no file (and thus no path)
See also
setFileName()
directory()
path()

Definition at line 1709 of file kurl.cpp.

◆ filename()

TQString KURL::filename ( bool  _ignore_trailing_slash_in_path = true) const
inline
Deprecated:
change code to call fileName()

Definition at line 1744 of file kurl.h.

◆ fromPathOrURL()

KURL KURL::fromPathOrURL ( const TQString &  text)
static

Creates a KURL object from a TQString representing either an absolute path or a real URL.

Use this method instead of

TQString someDir = ...
KURL url = someDir;

Otherwise some characters (e.g. the '#') won't be encoded properly.

Parameters
textthe string representation of the URL to convert
Returns
the new KURL
See also
pathOrURL()
KURL(const TQString&, int)
Since
3.1

Definition at line 2270 of file kurl.cpp.

◆ hasHost()

bool KURL::hasHost ( ) const
inline

Tests if this URL has a hostname included in it.

Returns
true if the URL has a non-empty host
See also
host()
setHost()

Definition at line 498 of file kurl.h.

◆ hasHTMLRef()

bool KURL::hasHTMLRef ( ) const

Tests if there is an HTML-style reference.

Returns
true if the URL has an HTML-style reference
See also
htmlRef()
encodedHtmlRef()
setHTMLRef()
hasRef()

Definition at line 1960 of file kurl.cpp.

◆ hasPass()

bool KURL::hasPass ( ) const
inline

Tests if this URL has a password included in it.

Note
a password can only appear in a URL string if you also set a user, see setUser().
Returns
true if there is a non-empty password set
See also
pass()
setPass()
hasUser()

Definition at line 467 of file kurl.h.

◆ hasPath()

bool KURL::hasPath ( ) const
inline

Tests if this URL has a path included in it.

Returns
true if there is a non-empty path
See also
path()
setPath()

Definition at line 591 of file kurl.h.

◆ hasRef()

bool KURL::hasRef ( ) const
inline

Tests if the URL has a reference part.

Returns
true if the URL has a reference part. In a URL like "http://www.kde.org/tdebase.tar#tar:/README" it would return true as well
See also
ref()
setRef()

Definition at line 768 of file kurl.h.

◆ hasSubURL()

bool KURL::hasSubURL ( ) const

Tests if the URL has any sub URLs.

See split() for examples for sub URLs.

Returns
true if the file has at least one sub URL
See also
split()

Definition at line 1472 of file kurl.cpp.

◆ hasUser()

bool KURL::hasUser ( ) const
inline

Tests if this URL has a user name included in it.

Returns
true if the URL has an non-empty user name
See also
user()
setUser()
hasPass()

Definition at line 425 of file kurl.h.

◆ host()

TQString KURL::host ( ) const
inline

Returns the decoded hostname included in the URL.

Returns
the name of the host or TQString::null if no host is set
See also
setHost()
hasHost()

Definition at line 477 of file kurl.h.

◆ htmlRef()

TQString KURL::htmlRef ( ) const

Returns decoded the HTML-style reference (the part of the URL after '#')

Returns
the HTML-style reference
See also
encodedHtmlRef()
setHTMLRef()
hasHTMLRef()
split()
hasSubURL()
ref()

Definition at line 1923 of file kurl.cpp.

◆ htmlURL()

TQString KURL::htmlURL ( ) const

Returns the URL as string, escaped for HTML.

Returns
a human readable URL, with no non-necessary encodings/escaped characters which is HTML encoded for safe inclusion in HTML or rich text. Password will not be shown.
See also
prettyURL()
url()
pathOrURL()

Definition at line 1647 of file kurl.cpp.

◆ internalReferenceURL()

TQString KURL::internalReferenceURL ( void  ) const

Definition at line 2337 of file kurl.cpp.

◆ isEmpty()

bool KURL::isEmpty ( ) const

Tests if the KURL is empty.

An empty URL has neither path nor protocol set.

Returns
true if the URL is empty
See also
hasPath()
protocol()
isValid()

Definition at line 652 of file kurl.cpp.

◆ isLocalFile()

bool KURL::isLocalFile ( ) const

Tests if the file is local.

Returns
true if the file is a plain local file and has no filter protocols attached to it

Definition at line 1399 of file kurl.cpp.

◆ isMalformed()

TDE_DEPRECATED bool KURL::isMalformed ( ) const
inline

Tests if the URL is malformed.

Returns
true if the URL is malformed. This function does not test whether sub URLs are well-formed as well
Deprecated:
Use !isValid() instead
See also
isValid()

Definition at line 837 of file kurl.h.

◆ isParentOf()

bool KURL::isParentOf ( const KURL &  u) const

Tests if the given URL is parent of this URL.

For instance, "ftp://host/dir/" is a parent of "ftp://host/dir/subdir/subsubdir/".

Returns
true if this URL is a parent of u (or the same URL as u)
See also
equals()
cd()

Definition at line 1217 of file kurl.cpp.

◆ isRelativeURL()

bool KURL::isRelativeURL ( const TQString &  _url)
static

Tests if a given URL is a relative as opposed to an absolute URL.

Convenience function.

Returns whether _url is likely to be a "relative" URL instead of an "absolute" URL.

Parameters
_urlthe URL to examine
Returns
true when the URL is likely to be "relative", false otherwise
See also
relativeURL()

Definition at line 409 of file kurl.cpp.

◆ isValid()

bool KURL::isValid ( ) const
inline

Tests if the URL is well formed.

Returns
false if the URL is malformed. This function does not test whether sub URLs are well-formed as well

Definition at line 826 of file kurl.h.

◆ join()

KURL KURL::join ( const List &  _list)
static

Joins a list of URLs into a single URL with sub URLs.

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.

Parameters
_listthe list to join
Returns
the joined URL or an invalid URL if the list is empty
See also
split()

Definition at line 1689 of file kurl.cpp.

◆ operator!=() [1/2]

bool KURL::operator!= ( const KURL &  _u) const
inline

Tests if this URL is different from the given one.

Tests by negating the result of operator==()

Parameters
_uthe URL to compare to
Returns
the negated result of operator==()
See also
operator==()
operator<()

Definition at line 1440 of file kurl.h.

◆ operator!=() [2/2]

bool KURL::operator!= ( const TQString &  _u) const
inline

Tests if this URL is different from the one given as a string.

Tests by negating the result of operator==(const TQString &)

Parameters
_uthe URL to compare to
Returns
the negated result of operator==(const TQString &)
See also
operator==(const TQString &)
operator<()

Definition at line 1454 of file kurl.h.

◆ operator<()

bool KURL::operator< ( const KURL &  _u) const

Tests if this URL is less than the given URL.

The current URL is consideres "less than" then _u if (tested in this order):

  • it is not valid but _u is. See isValid()
  • its protocol is "less than" _u's protocol. See protocol()
  • its host is "less than" _u's host. See host()
  • its port is "less than" _u's port. See port()
  • its path is "less than" _u's path. See path()
  • its encoded query is "less than" _u's encoded query. See query()
  • its endoded reference is "less than" _u's encoded reference. See ref()
  • its username is "less than" _u's username. See user()
  • its password is "less than" _u's password. See pass()

Examples:

KURL url1;
KURL url2;
bool lessThan = url1 < url2; // false. Both invalid, no protocols
url2.setProtocol( TQString::null );
lessThan = url1 < url2; // true. url2 is valid because of setProtocol()
url1.setProtocol( TQString::null );
lessThan = url1 < url2; // false. Both valid and everything empty
url1.setProtocol( "http" );
url2.setProtocol( "https" );
lessThan = url1 < url2; // true. "http" < "https"
url2.setHost( "api.kde.org" );
url2.setProtocol( "http" );
url2.setProtocol( "www.kde.org" );
lessThan = url1 < url2; // true. protocols equal and "api" < "www"
url1.setProtocol( "https" );
url2.setProtocol( "http" );
lessThan = url1 < url2; // false. "https" > "http". host doesn't matter yet
KURL::setHost
void setHost(const TQString &_txt)
Sets the hostname to include in the URL.
Definition: kurl.cpp:1998
KURL::setProtocol
void setProtocol(const TQString &_txt)
Sets the protocol for the URL.
Definition: kurl.cpp:1972
Parameters
_uthe URL to compare to
Returns
true if the URL is less than _u. Otherwise false (equal or greater than)
See also
operator==()
TQString::compare()

Definition at line 1105 of file kurl.cpp.

◆ operator=() [1/4]

KURL & KURL::operator= ( const char *  _url)

Assigns the URL, given as a C string, to this one.

This will reset the current URL and parse the given string. See the similar constructor for known limitations.

Parameters
_urlthe C string to parse for values
Returns
a reference to this URL (*this)
See also
equals()
KURL(const char *, int)

Definition at line 1060 of file kurl.cpp.

◆ operator=() [2/4]

KURL & KURL::operator= ( const KURL &  _u)

Copies the values of the given URL into this one.

Just assigns each member using the member's assignment operator.

Parameters
_uthe URL to take the values from
Returns
a reference to this URL (*this)
See also
equals()

Definition at line 1087 of file kurl.cpp.

◆ operator=() [3/4]

KURL & KURL::operator= ( const TQString &  _url)

Assigns the URL, given as a string, to this one.

This will reset the current URL and parse the given string. See the similar constructor for known limitations.

Parameters
_urlthe TQString to parse for values
Returns
a reference to this URL (*this)
See also
equals()
KURL(const TQString &, int)

Definition at line 1052 of file kurl.cpp.

◆ operator=() [4/4]

KURL & KURL::operator= ( const TQUrl &  u)

Assigns the URL, given as a Qt URL, to this one.

This will reset the current URL and parse the given string.

Parameters
uthe Qt URL to take the values from
Returns
a reference to this URL (*this)
See also
equals()
KURL(const TQUrl &)

Definition at line 1069 of file kurl.cpp.

◆ operator==() [1/2]

bool KURL::operator== ( const KURL &  _u) const

Tests if this URL is equal to the given one.

Tests each member for equality unless one of the URLs is invalid in which case they are not considered equal (even if both are invalid).

Same as equals() when used with ignore_trailing set to false (default)

Parameters
_uthe URL to compare to
Returns
true if equal and neither this URL nor _u is malformed. Otherwise false
See also
equals()
isValid()
operator!=()
operator<()

Definition at line 1149 of file kurl.cpp.

◆ operator==() [2/2]

bool KURL::operator== ( const TQString &  _u) const

Tests if this URL is equal to the one given as a string.

Creates a KURL instance for _u and compares with that using the equality operator for two KURLs.

See the respective constructor for known limitations.

Parameters
_uthe string to compare to
Returns
true if equal and neither this URL nor _u is malformed. Otherwise false
See also
KURL(const TQString &, int)
operator==(const KURL &)
equals()
isValid()
operator!=()
operator<()

Definition at line 1173 of file kurl.cpp.

◆ parse()

void KURL::parse ( const TQString &  _url,
int  encoding_hint = 0 
)
protected

Parses the given string and fills the URL's values on success.

Parameters
_urlthe string to parse
encoding_hintMIB of original encoding of str . See TQTextCodec::mibEnum()

Definition at line 657 of file kurl.cpp.

◆ parseMailto()

void KURL::parseMailto ( const TQString &  _url,
int  encoding_hint = 0 
)
protected

Parses the given string and fills the URL's values on success.

Treats the string as a "mailto:" URI.

Parameters
_urlthe string to parse
encoding_hintMIB of original encoding of str . See TQTextCodec::mibEnum()

Definition at line 760 of file kurl.cpp.

◆ parseRawURI()

void KURL::parseRawURI ( const TQString &  _url,
int  encoding_hint = 0 
)
protected

Parses the given string and fills the URL's values on success.

Treats the string as a generic URI.

Parameters
_urlthe string to parse
encoding_hintMIB of original encoding of str . See TQTextCodec::mibEnum()

Definition at line 727 of file kurl.cpp.

◆ parseURL()

void KURL::parseURL ( const TQString &  _url,
int  encoding_hint = 0 
)
protected

Parses the given string and fills the URL's values on success.

Treats the string as an URL.

Parameters
_urlthe string to parse
encoding_hintMIB of original encoding of str . See TQTextCodec::mibEnum()

Definition at line 779 of file kurl.cpp.

◆ pass()

TQString KURL::pass ( ) const
inline

Returns the decoded password (corresponding to user()) included in the URL.

Note
a password can only appear in a URL string if you also set a user, see setUser().
Returns
the password or TQString::null if it does not exist
See also
setPass()
hasPass()
hasUser()

Definition at line 440 of file kurl.h.

◆ path() [1/2]

TQString KURL::path ( ) const
inline

Returns the current decoded path.

This does not include the query.

Returns
the path of the URL (without query), or TQString::null if no path is set
See also
path(int)
setPath()
hasPath()

Definition at line 532 of file kurl.h.

◆ path() [2/2]

TQString KURL::path ( int  _trailing) const

Returns the current decoded path.

This does not include the query, see query() for accessing it.

The _trailing parameter allows to ensure the existance or absence of the last (trailing) '/' character in the path. If the URL has no path, then no '/' is added anyway. And on the other side: if the path is just "/", then this character won't be stripped.

Reason: "ftp://weis@host" means something completely different than "ftp://weis@host/". So adding or stripping the '/' would really alter the URL, while "ftp://host/path" and "ftp://host/path/" mean the same directory.

Parameters
_trailingMay be ( -1, 0, +1 ). -1 strips a trailing '/', +1 adds a trailing '/' if there is none yet and 0 returns the path unchanged
Returns
the path of the URL (without query), or TQString::null if no path is set
See also
path()
setPath()
hasPath()
adjustPath()

Definition at line 1394 of file kurl.cpp.

◆ pathOrURL()

TQString KURL::pathOrURL ( ) const

Returns the URL as a string depending if it is a local file.

It will be either the URL (as prettyURL() would return) or, when the URL is a local file without query or ref, the path().

Use this method, together with its opposite, fromPathOrURL(), to display and even let the user edit URLs.

Returns
the path or URL string depending on its properties
See also
prettyURL()
path()
url()
isLocalFile()
Since
3.4

Definition at line 1638 of file kurl.cpp.

◆ port()

unsigned short int KURL::port ( ) const
inline

Returns the port number included in the URL.

Returns
the port number or 0 if there is no port number specified in the URL
See also
setPort()
host()

Definition at line 509 of file kurl.h.

◆ prettyURL() [1/2]

TQString KURL::prettyURL ( int  _trailing,
AdjustementFlags  _flags 
) const

Returns the URL as string in human-friendly format Example:

http://localhost:8080/test.cgi?test=hello world&name=fred

Does not contain the password if the URL has one, use url() if you need to have it in the string.

The _trailing parameter allows to ensure the existance or absence of the last (trailing) '/' character in the path. If the URL has no path, then no '/' is added anyway. And on the other side: if the path is just "/", then this character won't be stripped.

Reason: "ftp://weis@host" means something completely different than "ftp://weis@host/". So adding or stripping the '/' would really alter the URL, while "ftp://host/path" and "ftp://host/path/" mean the same directory.

Parameters
_trailingMay be ( -1, 0, +1 ). -1 strips a trailing '/', +1 adds a trailing '/' if there is none yet and 0 returns the path unchanged
_flagsif StripFileProtocol, "file://" will be stripped. The use of this method is now discouraged, better use pathOrURL().
Returns
a human readable URL, with no non-necessary encodings/escaped characters. Password will not be shown
See also
prettyURL()
url()
pathOrURL()

Definition at line 1626 of file kurl.cpp.

◆ prettyURL() [2/2]

TQString KURL::prettyURL ( int  _trailing = 0) const

Returns the URL as string in human-friendly format.

Example:

http://localhost:8080/test.cgi?test=hello world&name=fred

Does not contain the password if the URL has one, use url() if you need to have it in the string.

The _trailing parameter allows to ensure the existance or absence of the last (trailing) '/' character in the path. If the URL has no path, then no '/' is added anyway. And on the other side: if the path is just "/", then this character won't be stripped.

Reason: "ftp://weis@host" means something completely different than "ftp://weis@host/". So adding or stripping the '/' would really alter the URL, while "ftp://host/path" and "ftp://host/path/" mean the same directory.

Parameters
_trailingMay be ( -1, 0, +1 ). -1 strips a trailing '/', +1 adds a trailing '/' if there is none yet and 0 returns the path unchanged
Returns
a human readable URL, with no non-necessary encodings/escaped characters. Password will not be shown
See also
url()
pathOrURL()

Definition at line 1559 of file kurl.cpp.

◆ protocol()

TQString KURL::protocol ( ) const
inline

Returns the protocol for the URL.

Examples for a protocol string are "file", "http", etc. but also "mailto:" and other pseudo protocols.

Returns
the protocol of the URL, does not include the colon. If the URL is malformed, TQString::null will be returned
See also
setProtocol()
isValid()

Definition at line 367 of file kurl.h.

◆ query()

TQString KURL::query ( ) const

Returns the encoded 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 encoded query or TQString::null if there is none
See also
setQuery()

Definition at line 2094 of file kurl.cpp.

◆ queryItem() [1/2]

TQString KURL::queryItem ( const TQString &  item) const

Returns the value of a certain query item.

Parameters
itemitem whose value we want
Returns
the value of the given query item name or TQString::null if the specified item does not exist
See also
addQueryItem()
removeQueryItem()
queryItems()
query()

Definition at line 2205 of file kurl.cpp.

◆ queryItem() [2/2]

TQString KURL::queryItem ( const TQString &  item,
int  encoding_hint 
) const

Returns the value of a certain query item.

Parameters
itemitem whose value we want
encoding_hintMIB of encoding of query. See TQTextCodec::mibEnum()
Returns
the value of the given query item name or TQString::null if the specified item does not exist
See also
addQueryItem()
removeQueryItem()
queryItems()
query()

Definition at line 2210 of file kurl.cpp.

◆ queryItems() [1/2]

TQMap< TQString, TQString > KURL::queryItems ( int  options,
int  encoding_hint 
) const

Returns the list of query items as a map mapping keys to values.

Parameters
optionsany of QueryItemsOptions ORed together
encoding_hintMIB of encoding of query. See TQTextCodec::mibEnum()
Returns
the map of query items or the empty map if the URL has no query items
See also
queryItem()
addQueryItem()
removeQueryItem()
query()
Since
3.1

Definition at line 2174 of file kurl.cpp.

◆ queryItems() [2/2]

TQMap< TQString, TQString > KURL::queryItems ( int  options = 0) const

Definition at line 2170 of file kurl.cpp.

◆ ref()

TQString KURL::ref ( ) const
inline

Returns the encoded reference of the URL.

The reference is never decoded automatically.

Returns
the undecoded reference, or TQString::null if there is none
See also
setRef()
hasRef()
htmlRef()

Definition at line 743 of file kurl.h.

◆ relativePath()

TQString KURL::relativePath ( const TQString &  base_dir,
const TQString &  path,
bool *  isParent = 0 
)
static

Creates a path relative to a base path for a given input path.

Convenience function

Returns a relative path based on base_dir that points to path.

Parameters
base_dirthe base directory to derive from
paththe new target directory
isParentan optional pointer to a boolean which, if provided, will be set to reflect whether path has base_dir as a parent dir
See also
relativeURL()

Definition at line 2320 of file kurl.cpp.

◆ relativeURL()

TQString KURL::relativeURL ( const KURL &  base_url,
const KURL &  url,
int  encoding_hint = 0 
)
static

Creates an URL relative to a base URL for a given input URL.

Convenience function

Returns a "relative URL" based on base_url that points to url.

If no "relative URL" can be created, e.g. because the protocol and/or hostname differ between base_url and url an absolute URL is returned.

Note
if base_url represents a directory, it should contain a trailing slash
Parameters
base_urlthe URL to derive from
urlthe URL to point to relatively from base_url
encoding_hintMIB of original encoding of str . See TQTextCodec::mibEnum()
See also
isRelativeURL()
relativePath()
adjustPath()

Definition at line 2341 of file kurl.cpp.

◆ removeQueryItem()

void KURL::removeQueryItem ( const TQString &  _item)

Removea an item from the query.

Parameters
_itemname of item to remove
See also
addQueryItem()
queryItem()
queryItems()
query()

Definition at line 2236 of file kurl.cpp.

◆ reset()

void KURL::reset ( )
protected

Resets the members to their "null" state.

All TQString members get reset to TQString::null, the port to 0 the URIMode to Auto and the URL becomes invalid.

This is like assigning a null URL, but more efficient as it doesn't require the temporary object.

Called by constructors, assignment operators and the parse methods in case of a parsing error.

See also
isValid()
isEmpty()

Definition at line 637 of file kurl.cpp.

◆ setDirectory()

void KURL::setDirectory ( const TQString &  dir)

Sets the directory of the path, leaving the filename empty.

Parameters
dirthe decoded directory to set
See also
directory()
setFileName()
setPath()

Definition at line 2039 of file kurl.cpp.

◆ setEncodedPath()

void KURL::setEncodedPath ( const TQString &  _txt,
int  encoding_hint = 0 
)

Sets the (already encoded) path of the URL.

Parameters
_txtthe new encoded path
encoding_hintMIB of original encoding of _txt . See TQTextCodec::mibEnum()
See also
setEncodedPathAndQuery()
setPath()

Definition at line 1365 of file kurl.cpp.

◆ setEncodedPathAndQuery()

void KURL::setEncodedPathAndQuery ( const TQString &  _txt,
int  encoding_hint = 0 
)

Sets both path and query of the URL in their encoded form.

This is useful for HTTP. It looks first for '?' and decodes then, see setEncodedPath(). The encoded path is the concatenation of the current path and the query.

Parameters
_txtthe new encoded path and encoded query
encoding_hintMIB of original encoding of _txt . See TQTextCodec::mibEnum()
See also
encodedPathAndQuery()
setPath()
setQuery()

Definition at line 1379 of file kurl.cpp.

◆ setFileEncoding()

void KURL::setFileEncoding ( const TQString &  encoding)

Adds file encoding information.

Adds encoding information to the URL by adding a "charset" parameter. If there is already a charset parameter, it will be replaced.

Parameters
encodingthe encoding to add or TQString::null to remove the encoding
See also
fileEncoding()
TQTextCodec::codecForName()

Definition at line 1418 of file kurl.cpp.

◆ setFileName()

void KURL::setFileName ( const TQString &  _txt)

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 '/'.

If the current path ends with '/' then _txt is just appended, otherwise all text behind the last '/' in the current path is erased and _txt is appended then. It does not matter whether _txt starts with '/' or not.

Any reference is reset.

Parameters
_txtthe filename to be set. It is considered to be decoded
See also
fileName()
setDirectory()
setPath()

Definition at line 1249 of file kurl.cpp.

◆ setHost()

void KURL::setHost ( const TQString &  _txt)

Sets the hostname to include in the URL.

Special characters in the hostname will appear encoded in the URL.

Parameters
_txtthe new name of the host or TQString::null to remove the host
See also
host()
hasHost()

Definition at line 1998 of file kurl.cpp.

◆ setHTMLRef()

void KURL::setHTMLRef ( const TQString &  _ref)

Sets the decoded HTML-style reference.

Parameters
_refthe new reference. This is considered to be not encoded in contrast to setRef(). Use TQString::null to remove it
See also
htmlRef()
hasHTMLRef()

Definition at line 1945 of file kurl.cpp.

◆ setInternalReferenceURL()

void KURL::setInternalReferenceURL ( const TQString &  url)

Definition at line 2333 of file kurl.cpp.

◆ setPass()

void KURL::setPass ( const TQString &  _txt)

Sets the password (corresponding to user()) to include in the URL.

Special characters in the password will appear encoded in the URL.

Note
a password can only appear in a URL string if you also set a user, see setUser().
Parameters
_txtthe password to set or TQString::null to remove the password
See also
pass()
hasPass()
hasUser()

Definition at line 1989 of file kurl.cpp.

◆ setPath()

void KURL::setPath ( const TQString &  path)

Sets the decoded path of the URL.

This does not changed the query, see setQuery() for that.

The path is considered to be decoded, i.e. characters not allowed in path, for example '?' will be encoded and does not indicate the beginning of the query part. Something that might look encoded, like "%3f" will not become decoded.

Parameters
paththe new, decoded, path or TQString::null to remove the path
See also
path()
path(int)
hasPath()

Definition at line 2025 of file kurl.cpp.

◆ setPort()

void KURL::setPort ( unsigned short int  _p)

Sets the port number to include in the URL.

Parameters
_pthe new port number or 0 to have no port number
See also
port()
setHost()

Definition at line 2020 of file kurl.cpp.

◆ setProtocol()

void KURL::setProtocol ( const TQString &  _txt)

Sets the protocol for the URL.

Examples for a protocol string are "file", "http", etc. but also "mailto:" and other pseudo protocols.

Parameters
_txtthe new protocol of the URL (without colon)
See also
protocol()

Definition at line 1972 of file kurl.cpp.

◆ setQuery()

void KURL::setQuery ( const TQString &  _txt,
int  encoding_hint = 0 
)

Sets the encoded query of the URL.

The query should start with a '?'. If it doesn't '?' is prepended.

Parameters
_txtthis is considered to be encoded. This has a good reason: the query may contain the '0' character
encoding_hintMIB of the encoding. Reserved, should be 0 . See TQTextCodec::mibEnum()
See also
query()

Definition at line 2047 of file kurl.cpp.

◆ setRef()

void KURL::setRef ( const TQString &  _txt)
inline

Sets the encoded reference part (everything after '#')

This is considered to be encoded, i.e. characters that are not allowed as part of the reference will not be encoded.

Parameters
_txtthe encoded reference or TQString::null to remove it
See also
ref()
hasRef()

Definition at line 756 of file kurl.h.

◆ setUser()

void KURL::setUser ( const TQString &  _txt)

Sets the user name (login, user id, etc) to include in the URL.

Special characters in the user name will appear encoded in the URL. If there is a password associated with the user, it can be set using setPass().

Parameters
_txtthe name of the user or TQString::null to remove the user
See also
user()
hasUser()
hasPass()

Definition at line 1980 of file kurl.cpp.

◆ split() [1/2]

KURL::List KURL::split ( const KURL &  _url)
static

Splits nested URLs into a list of URLs.

Example for a nested URL:

file:

A URL like "http://www.kde.org#tar:/kde/README.hml#ref1" will be split in "http://www.kde.org#ref1" and "tar:/kde/README.html#ref1".

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.

Parameters
_urlthe URL that has to be split
Returns
an empty list on error or the list of split URLs
See also
hasSubURL()
join()

Definition at line 1652 of file kurl.cpp.

◆ split() [2/2]

KURL::List KURL::split ( const TQString &  _url)
static

Splits nested URLs into a list of URLs.

Example for a nested URL:

file:

A URL like "http://www.kde.org#tar:/kde/README.hml#ref1" will be split in "http://www.kde.org#ref1" and "tar:/kde/README.html#ref1".

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.

Parameters
_urlthe URL that has to be split
Returns
an empty list on error or the list of split URLs
See also
hasSubURL()
KURL(const TQString&, int)
join()

Definition at line 1684 of file kurl.cpp.

◆ upURL()

KURL KURL::upURL ( ) const

Returns the URL that is the best possible candidate for on level higher in the path hierachy.

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 until it can go up.

Returns
a URL that is a level higher
See also
cd()
split()
hasSubURL()
path()

Definition at line 1887 of file kurl.cpp.

◆ uriMode()

int KURL::uriMode ( ) const

Returns the URI processing mode for the URL.

Returns
the URI processing mode set for this URL
See also
URIMode
uriModeForProtocol()
Since
3.2

Definition at line 2374 of file kurl.cpp.

◆ uriModeForProtocol()

KURL::URIMode KURL::uriModeForProtocol ( const TQString &  protocol)
static

Determines which URI mode is suitable for processing URIs of a given protocol.

Parameters
protocolthe protocol name. See protocol()
Returns
the URIMode suitable for the given protocol
See also
uriMode()
Since
3.2

Definition at line 2379 of file kurl.cpp.

◆ url()

TQString KURL::url ( int  _trailing = 0,
int  encoding_hint = 0 
) const

Returns the URL as string, with all escape sequences intact, encoded in a given charset.

This is used in particular for encoding URLs in UTF-8 before using them in a drag and drop operation.

Note
that the string returned by url() will include the password of the URL. If you want to show the URL to the user, use prettyURL().

The _trailing parameter allows to ensure the existance or absence of the last (trailing) '/' character in the path. If the URL has no path, then no '/' is added anyway. And on the other side: if the path is just "/", then this character won't be stripped.

Reason: "ftp://weis@host" means something completely different than "ftp://weis@host/". So adding or stripping the '/' would really alter the URL, while "ftp://host/path" and "ftp://host/path/" mean the same directory.

Parameters
_trailingMay be ( -1, 0, +1 ). -1 strips a trailing '/', +1 adds a trailing '/' if there is none yet and 0 returns the path unchanged
encoding_hintMIB of encoding to use. See TQTextCodec::mibEnum()
Returns
the complete URL, with all escape sequences intact, encoded in a given charset
See also
prettyURL()
pathOrURL()
htmlURL()

Definition at line 1499 of file kurl.cpp.

◆ user()

TQString KURL::user ( ) const
inline

Returns the decoded user name (login, user id, etc) included in the URL.

Returns
the user name or TQString::null if there is no user name
See also
setUser()
hasUser()

Definition at line 401 of file kurl.h.

Friends And Related Function Documentation

◆ operator<<

TQDataStream & operator<< ( TQDataStream &  s,
const KURL &  a 
)
friend

Definition at line 503 of file kurl.cpp.

◆ operator>>

TQDataStream & operator>> ( TQDataStream &  s,
KURL &  a 
)
friend

Definition at line 515 of file kurl.cpp.

◆ urlcmp() [1/2]

bool urlcmp ( const TQString &  _url1,
const TQString &  _url2 
)
related

Compares URLs.

They are parsed, split and compared. Two malformed URLs with the same string representation are nevertheless considered to be unequal. That means no malformed URL equals anything else.

Definition at line 2116 of file kurl.cpp.

◆ urlcmp() [2/2]

bool urlcmp ( const TQString &  _url1,
const TQString &  _url2,
bool  _ignore_trailing,
bool  _ignore_ref 
)
related

Compares URLs.

They are parsed, split and compared. Two malformed URLs with the same string representation are nevertheless considered to be unequal. That means no malformed URL equals anything else.

Parameters
_url1A reference URL
_url2A URL that will be compared with the reference URL
_ignore_trailingDescribed in KURL::cmp
_ignore_refIf true, disables comparison of HTML-style references.

Definition at line 2135 of file kurl.cpp.


The documentation for this class was generated from the following files:
  • kurl.h
  • kurl.cpp

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.