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

tdecore

  • tdecore
kurl.h
1 /* This file is part of the KDE libraries
2  * Copyright (C) 1999 Torben Weis <weis@kde.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  **/
19 
20 #ifndef __kurl_h__
21 #define __kurl_h__
22 
23 #include <tqstring.h>
24 #include <tqvaluelist.h>
25 #include "tdelibs_export.h"
26 
27 class TQUrl;
28 class TQStringList;
29 template <typename K, typename V> class TQMap;
30 
31 class KURLPrivate;
32 
33 // Defines that file-urls look like file:///path/file instead of file:/path/file
34 #define KURL_TRIPLE_SLASH_FILE_PROT
35 
127 class TDECORE_EXPORT KURL
128 {
129 public:
136  enum AdjustementFlags
137  {
141  NoAdjustements = 0,
146  StripFileProtocol = 1
147  };
148 
152  enum URIMode
153  {
158  Auto,
163  Invalid,
168  RawURI,
172  URL,
178  Mailto
179  };
180 
187  class TDECORE_EXPORT List : public TQValueList<KURL>
188  {
189  public:
193  List() { }
199  List(const KURL &url);
212  List(const TQStringList &list);
226  TQStringList toStringList() const;
227  };
233  KURL();
234 
238  ~KURL();
239 
260  KURL( const TQString& url, int encoding_hint = 0 );
286  KURL( const char * url, int encoding_hint = 0 );
312  KURL( const TQCString& url, int encoding_hint = 0 );
313 
319  KURL( const KURL& u );
327  KURL( const TQUrl &u );
353  KURL( const KURL& _baseurl, const TQString& _rel_url, int encoding_hint=0 );
354 
367  TQString protocol() const { return m_bIsMalformed ? TQString::null : m_strProtocol; }
378  void setProtocol( const TQString& _txt );
379 
390  int uriMode() const;
391 
401  TQString user() const { return m_strUser; }
415  void setUser( const TQString& _txt );
425  bool hasUser() const { return !m_strUser.isEmpty(); }
426 
440  TQString pass() const { return m_strPass; }
454  void setPass( const TQString& _txt );
467  bool hasPass() const { return !m_strPass.isEmpty(); }
468 
477  TQString host() const { return m_strHost; }
478 
489  void setHost( const TQString& _txt );
498  bool hasHost() const { return !m_strHost.isEmpty(); }
499 
509  unsigned short int port() const { return m_iPort; }
518  void setPort( unsigned short int _p );
519 
532  TQString path() const { return m_strPath; }
533 
563  TQString path( int _trailing ) const;
564 
581  void setPath( const TQString& path );
582 
591  bool hasPath() const { return !m_strPath.isEmpty(); }
592 
596  void setInternalReferenceURL( const TQString& url );
597 
601  TQString internalReferenceURL( void ) const;
602 
616  void cleanPath(bool cleanDirSeparator = true);
617 
640  void adjustPath(int _trailing);
641 
657  void setEncodedPathAndQuery( const TQString& _txt, int encoding_hint = 0 );
658 
669  void setEncodedPath(const TQString& _txt, int encoding_hint = 0 );
670 
701  TQString encodedPathAndQuery( int _trailing = 0, bool _no_empty_path = false, int encoding_hint = 0) const;
702 
716  void setQuery( const TQString& _txt, int encoding_hint = 0);
717 
730  TQString query() const;
731 
743  TQString ref() const { return m_strRef_encoded; }
744 
756  void setRef( const TQString& _txt ) { m_strRef_encoded = _txt; }
757 
768  bool hasRef() const { return !m_strRef_encoded.isNull(); }
769 
783  TQString htmlRef() const;
784 
795  TQString encodedHtmlRef() const;
796 
806  void setHTMLRef( const TQString& _ref );
807 
818  bool hasHTMLRef() const;
819 
826  bool isValid() const { return !m_bIsMalformed; }
837  TDE_DEPRECATED bool isMalformed() const { return !isValid(); }
838 
845  bool isLocalFile() const;
846 
859  void setFileEncoding(const TQString &encoding);
860 
869  TQString fileEncoding() const;
870 
880  bool hasSubURL() const;
881 
896  void addPath( const TQString& txt );
897 
911  TQString queryItem( const TQString& item ) const;
912 
928  TQString queryItem( const TQString& item, int encoding_hint ) const;
929 
935  enum QueryItemsOptions
936  {
940  CaseInsensitiveKeys = 1
941  };
942 
946  TQMap< TQString, TQString > queryItems( int options=0 ) const;
947 
965  TQMap< TQString, TQString > queryItems( int options, int encoding_hint ) const;
966 
982  void addQueryItem( const TQString& _item, const TQString& _value, int encoding_hint = 0 );
983 
994  void removeQueryItem( const TQString& _item );
995 
1016  void setFileName( const TQString&_txt );
1017 
1035  TQString fileName( bool _ignore_trailing_slash_in_path = true ) const;
1036 
1063  TQString directory( bool _strip_trailing_slash_from_result = true,
1064  bool _ignore_trailing_slash_in_path = true ) const;
1065 
1075  void setDirectory(const TQString &dir);
1076 
1095  bool cd( const TQString& _dir );
1096 
1132  TQString url( int _trailing = 0, int encoding_hint = 0) const;
1133 
1166  TQString prettyURL( int _trailing = 0) const;
1167 
1203  TQString prettyURL( int _trailing, AdjustementFlags _flags) const;
1204  // ### BIC: Merge the two above + spell it as "Adjustment"
1205  // Or remove completely, and let people use pathOrURL() instead
1206 
1225  TQString pathOrURL() const;
1226 
1238  TQString htmlURL() const;
1239 
1240 
1252  bool isEmpty() const;
1253 
1273  KURL upURL( ) const;
1274 
1326  bool operator<(const KURL& _u) const;
1327 
1339  KURL& operator=( const KURL& _u );
1340 
1354  KURL& operator=( const TQString& _url );
1355 
1369  KURL& operator=( const char * _url );
1370 
1383  KURL& operator=( const TQUrl & u );
1384 
1404  bool operator==( const KURL& _u ) const;
1405 
1426  bool operator==( const TQString& _u ) const;
1427 
1440  bool operator!=( const KURL& _u ) const { return !( *this == _u ); }
1441 
1454  bool operator!=( const TQString& _u ) const { return !( *this == _u ); }
1455 
1471  bool cmp( const KURL &u, bool ignore_trailing = false ) const TDE_DEPRECATED;
1472 
1486  bool equals( const KURL &u, bool ignore_trailing = false ) const;
1487 
1502  bool equals( const KURL &u, bool ignore_trailing, bool ignore_internalReferenceURLS ) const; // TODO KDE4: add bool _ignore_ref = false
1503 
1515  bool isParentOf( const KURL& u ) const;
1516 
1543  static List split( const TQString& _url );
1544 
1570  static List split( const KURL& _url );
1571 
1585  static KURL join( const List& _list );
1586 
1608  static KURL fromPathOrURL( const TQString& text );
1609 
1627  static TQString encode_string(const TQString &str, int encoding_hint = 0);
1628 
1645  static TQString encode_string_no_slash(const TQString &str, int encoding_hint = 0);
1646 
1665  static TQString decode_string(const TQString &str, int encoding_hint = 0);
1666 
1681  static bool isRelativeURL(const TQString &_url);
1682 
1706  static TQString relativeURL(const KURL &base_url, const KURL &url, int encoding_hint = 0);
1707 
1722  static TQString relativePath(const TQString &base_dir, const TQString &path, bool *isParent=0);
1723 
1736  static URIMode uriModeForProtocol(const TQString& protocol);
1737 
1738 #ifdef KDE_NO_COMPAT
1739 private:
1740 #endif
1744  TQString filename( bool _ignore_trailing_slash_in_path = true ) const
1745  {
1746  return fileName(_ignore_trailing_slash_in_path);
1747  }
1748 
1749 protected:
1765  void reset();
1766 
1776  void parseURL( const TQString& _url, int encoding_hint = 0 );
1786  void parseRawURI( const TQString& _url, int encoding_hint = 0 );
1796  void parseMailto( const TQString& _url, int encoding_hint = 0 );
1804  void parse( const TQString& _url, int encoding_hint = 0 );
1805 
1806 private:
1807  void _setQuery( const TQString& _txt, int encoding_hint = 0);
1808 
1809  TQString m_strProtocol;
1810  TQString m_strUser;
1811  TQString m_strPass;
1812  TQString m_strHost;
1813  TQString m_strPath;
1814  TQString m_strRef_encoded;
1815  TQString m_strQuery_encoded;
1816  bool m_bIsMalformed : 1;
1817  enum URIMode m_iUriMode : 3;
1818  uint freeForUse : 4;
1819  unsigned short int m_iPort;
1820  TQString m_strPath_encoded;
1821 
1822  friend TDECORE_EXPORT TQDataStream & operator<< (TQDataStream & s, const KURL & a);
1823  friend TDECORE_EXPORT TQDataStream & operator>> (TQDataStream & s, KURL & a);
1824 private:
1825  KURLPrivate* d;
1826 };
1827 
1835 TDECORE_EXPORT bool urlcmp( const TQString& _url1, const TQString& _url2 );
1836 
1849 TDECORE_EXPORT bool urlcmp( const TQString& _url1, const TQString& _url2, bool _ignore_trailing, bool _ignore_ref );
1850 
1851 TDECORE_EXPORT TQDataStream & operator<< (TQDataStream & s, const KURL & a);
1852 TDECORE_EXPORT TQDataStream & operator>> (TQDataStream & s, KURL & a);
1853 
1854 #endif
KURL::List
KURL::List is a TQValueList that contains KURLs with a few convenience methods.
Definition: kurl.h:188
KURL::List::List
List()
Creates an empty List.
Definition: kurl.h:193
KURL
Represents and parses a URL.
Definition: kurl.h:128
KURL::path
TQString path() const
Returns the current decoded path.
Definition: kurl.h:532
KURL::urlcmp
bool urlcmp(const TQString &_url1, const TQString &_url2)
Compares URLs.
Definition: kurl.cpp:2116
KURL::user
TQString user() const
Returns the decoded user name (login, user id, etc) included in the URL.
Definition: kurl.h:401
KURL::operator!=
bool operator!=(const TQString &_u) const
Tests if this URL is different from the one given as a string.
Definition: kurl.h:1454
KURL::port
unsigned short int port() const
Returns the port number included in the URL.
Definition: kurl.h:509
KURL::AdjustementFlags
AdjustementFlags
Flags to choose how file: URLs are treated when creating their TQString representation with prettyURL...
Definition: kurl.h:137
KURL::setRef
void setRef(const TQString &_txt)
Sets the encoded reference part (everything after '#')
Definition: kurl.h:756
KURL::protocol
TQString protocol() const
Returns the protocol for the URL.
Definition: kurl.h:367
KURL::hasHost
bool hasHost() const
Tests if this URL has a hostname included in it.
Definition: kurl.h:498
KURL::hasPass
bool hasPass() const
Tests if this URL has a password included in it.
Definition: kurl.h:467
KURL::hasUser
bool hasUser() const
Tests if this URL has a user name included in it.
Definition: kurl.h:425
KURL::hasPath
bool hasPath() const
Tests if this URL has a path included in it.
Definition: kurl.h:591
KURL::isMalformed
TDE_DEPRECATED bool isMalformed() const
Tests if the URL is malformed.
Definition: kurl.h:837
KURL::QueryItemsOptions
QueryItemsOptions
Options for queryItems()
Definition: kurl.h:936
KURL::host
TQString host() const
Returns the decoded hostname included in the URL.
Definition: kurl.h:477
KURL::pass
TQString pass() const
Returns the decoded password (corresponding to user()) included in the URL.
Definition: kurl.h:440
KURL::filename
TQString filename(bool _ignore_trailing_slash_in_path=true) const
Definition: kurl.h:1744
KURL::ref
TQString ref() const
Returns the encoded reference of the URL.
Definition: kurl.h:743
KURL::URIMode
URIMode
Defines the type of URI we are processing.
Definition: kurl.h:153
KURL::Invalid
@ Invalid
Invalid URI.
Definition: kurl.h:163
KURL::URL
@ URL
Standards compliant URL.
Definition: kurl.h:172
KURL::Auto
@ Auto
Automatically detected.
Definition: kurl.h:158
KURL::RawURI
@ RawURI
Raw URI.
Definition: kurl.h:168
KURL::operator!=
bool operator!=(const KURL &_u) const
Tests if this URL is different from the given one.
Definition: kurl.h:1440
KURL::isValid
bool isValid() const
Tests if the URL is well formed.
Definition: kurl.h:826
KURL::hasRef
bool hasRef() const
Tests if the URL has a reference part.
Definition: kurl.h:768

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.1
This website is maintained by Timothy Pearson.