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

kdecore

  • kdecore
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 "kdelibs_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 KDECORE_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 KDECORE_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 
606  void cleanPath(bool cleanDirSeparator = true);
607 
630  void adjustPath(int _trailing);
631 
647  void setEncodedPathAndQuery( const TQString& _txt, int encoding_hint = 0 );
648 
659  void setEncodedPath(const TQString& _txt, int encoding_hint = 0 );
660 
691  TQString encodedPathAndQuery( int _trailing = 0, bool _no_empty_path = false, int encoding_hint = 0) const;
692 
706  void setQuery( const TQString& _txt, int encoding_hint = 0);
707 
720  TQString query() const;
721 
733  TQString ref() const { return m_strRef_encoded; }
734 
746  void setRef( const TQString& _txt ) { m_strRef_encoded = _txt; }
747 
758  bool hasRef() const { return !m_strRef_encoded.isNull(); }
759 
773  TQString htmlRef() const;
774 
785  TQString encodedHtmlRef() const;
786 
796  void setHTMLRef( const TQString& _ref );
797 
808  bool hasHTMLRef() const;
809 
816  bool isValid() const { return !m_bIsMalformed; }
827  KDE_DEPRECATED bool isMalformed() const { return !isValid(); }
828 
835  bool isLocalFile() const;
836 
849  void setFileEncoding(const TQString &encoding);
850 
859  TQString fileEncoding() const;
860 
870  bool hasSubURL() const;
871 
886  void addPath( const TQString& txt );
887 
901  TQString queryItem( const TQString& item ) const;
902 
918  TQString queryItem( const TQString& item, int encoding_hint ) const;
919 
925  enum QueryItemsOptions
926  {
930  CaseInsensitiveKeys = 1
931  };
932 
936  TQMap< TQString, TQString > queryItems( int options=0 ) const;
937 
955  TQMap< TQString, TQString > queryItems( int options, int encoding_hint ) const;
956 
972  void addQueryItem( const TQString& _item, const TQString& _value, int encoding_hint = 0 );
973 
984  void removeQueryItem( const TQString& _item );
985 
1006  void setFileName( const TQString&_txt );
1007 
1025  TQString fileName( bool _ignore_trailing_slash_in_path = true ) const;
1026 
1053  TQString directory( bool _strip_trailing_slash_from_result = true,
1054  bool _ignore_trailing_slash_in_path = true ) const;
1055 
1065  void setDirectory(const TQString &dir);
1066 
1085  bool cd( const TQString& _dir );
1086 
1122  TQString url( int _trailing = 0, int encoding_hint = 0) const;
1123 
1156  TQString prettyURL( int _trailing = 0) const;
1157 
1193  TQString prettyURL( int _trailing, AdjustementFlags _flags) const;
1194  // ### BIC: Merge the two above + spell it as "Adjustment"
1195  // Or remove completely, and let people use pathOrURL() instead
1196 
1215  TQString pathOrURL() const;
1216 
1228  TQString htmlURL() const;
1229 
1230 
1242  bool isEmpty() const;
1243 
1263  KURL upURL( ) const;
1264 
1316  bool operator<(const KURL& _u) const;
1317 
1329  KURL& operator=( const KURL& _u );
1330 
1344  KURL& operator=( const TQString& _url );
1345 
1359  KURL& operator=( const char * _url );
1360 
1373  KURL& operator=( const TQUrl & u );
1374 
1394  bool operator==( const KURL& _u ) const;
1395 
1416  bool operator==( const TQString& _u ) const;
1417 
1430  bool operator!=( const KURL& _u ) const { return !( *this == _u ); }
1431 
1444  bool operator!=( const TQString& _u ) const { return !( *this == _u ); }
1445 
1461  bool cmp( const KURL &u, bool ignore_trailing = false ) const KDE_DEPRECATED;
1462 
1476  bool equals( const KURL &u, bool ignore_trailing = false ) const; // TODO KDE4: add bool _ignore_ref = false
1477 
1489  bool isParentOf( const KURL& u ) const;
1490 
1517  static List split( const TQString& _url );
1518 
1544  static List split( const KURL& _url );
1545 
1559  static KURL join( const List& _list );
1560 
1582  static KURL fromPathOrURL( const TQString& text );
1583 
1601  static TQString encode_string(const TQString &str, int encoding_hint = 0);
1602 
1619  static TQString encode_string_no_slash(const TQString &str, int encoding_hint = 0);
1620 
1639  static TQString decode_string(const TQString &str, int encoding_hint = 0);
1640 
1655  static bool isRelativeURL(const TQString &_url);
1656 
1680  static TQString relativeURL(const KURL &base_url, const KURL &url, int encoding_hint = 0);
1681 
1696  static TQString relativePath(const TQString &base_dir, const TQString &path, bool *isParent=0);
1697 
1710  static URIMode uriModeForProtocol(const TQString& protocol);
1711 
1712 #ifdef KDE_NO_COMPAT
1713 private:
1714 #endif
1715 
1718  TQString filename( bool _ignore_trailing_slash_in_path = true ) const
1719  {
1720  return fileName(_ignore_trailing_slash_in_path);
1721  }
1722 
1723 protected:
1739  void reset();
1740 
1750  void parseURL( const TQString& _url, int encoding_hint = 0 );
1760  void parseRawURI( const TQString& _url, int encoding_hint = 0 );
1770  void parseMailto( const TQString& _url, int encoding_hint = 0 );
1778  void parse( const TQString& _url, int encoding_hint = 0 );
1779 
1780 private:
1781  void _setQuery( const TQString& _txt, int encoding_hint = 0);
1782 
1783  TQString m_strProtocol;
1784  TQString m_strUser;
1785  TQString m_strPass;
1786  TQString m_strHost;
1787  TQString m_strPath;
1788  TQString m_strRef_encoded;
1789  TQString m_strQuery_encoded;
1790  bool m_bIsMalformed : 1;
1791  enum URIMode m_iUriMode : 3;
1792  uint freeForUse : 4;
1793  unsigned short int m_iPort;
1794  TQString m_strPath_encoded;
1795 
1796  friend KDECORE_EXPORT TQDataStream & operator<< (TQDataStream & s, const KURL & a);
1797  friend KDECORE_EXPORT TQDataStream & operator>> (TQDataStream & s, KURL & a);
1798 private:
1799  KURLPrivate* d;
1800 };
1801 
1809 KDECORE_EXPORT bool urlcmp( const TQString& _url1, const TQString& _url2 );
1810 
1823 KDECORE_EXPORT bool urlcmp( const TQString& _url1, const TQString& _url2, bool _ignore_trailing, bool _ignore_ref );
1824 
1825 KDECORE_EXPORT TQDataStream & operator<< (TQDataStream & s, const KURL & a);
1826 KDECORE_EXPORT TQDataStream & operator>> (TQDataStream & s, KURL & a);
1827 
1828 #endif

kdecore

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

kdecore

Skip menu "kdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdecore by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |