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

kdecore

kurl.h
00001 /* This file is part of the KDE libraries
00002  *  Copyright (C) 1999 Torben Weis <weis@kde.org>
00003  *
00004  *  This library is free software; you can redistribute it and/or
00005  *  modify it under the terms of the GNU Library General Public
00006  *  License as published by the Free Software Foundation; either
00007  *  version 2 of the License, or (at your option) any later version.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #ifndef __kurl_h__
00021 #define __kurl_h__
00022 
00023 #include <tqstring.h>
00024 #include <tqvaluelist.h>
00025 #include "kdelibs_export.h"
00026 
00027 class TQUrl;
00028 class TQStringList;
00029 template <typename K, typename V> class TQMap;
00030 
00031 class KURLPrivate;
00032 
00033 // Defines that file-urls look like file:///path/file instead of file:/path/file
00034 #define KURL_TRIPLE_SLASH_FILE_PROT
00035 
00127 class KDECORE_EXPORT KURL
00128 {
00129 public:
00136   enum AdjustementFlags
00137   {
00141     NoAdjustements = 0,
00146     StripFileProtocol = 1
00147   };
00148 
00152   enum URIMode
00153   {
00158     Auto,
00163     Invalid,
00168     RawURI,
00172     URL,
00178     Mailto
00179   };
00180 
00187   class KDECORE_EXPORT List : public TQValueList<KURL>
00188   {
00189   public:
00193       List() { }
00199       List(const KURL &url);
00212       List(const TQStringList &list);
00226       TQStringList toStringList() const;
00227   };
00233   KURL();
00234 
00238   ~KURL();
00239 
00260   KURL( const TQString& url, int encoding_hint = 0 );
00286   KURL( const char * url, int encoding_hint = 0 );
00312   KURL( const TQCString& url, int encoding_hint = 0 );
00313 
00319   KURL( const KURL& u );
00327   KURL( const TQUrl &u );
00353   KURL( const KURL& _baseurl, const TQString& _rel_url, int encoding_hint=0 );
00354 
00367   TQString protocol() const { return m_bIsMalformed ? TQString::null : m_strProtocol; }
00378   void setProtocol( const TQString& _txt );
00379 
00390   int uriMode() const;
00391 
00401   TQString user() const { return m_strUser; }
00415   void setUser( const TQString& _txt );
00425   bool hasUser() const { return !m_strUser.isEmpty(); }
00426 
00440   TQString pass() const { return m_strPass; }
00454   void setPass( const TQString& _txt );
00467   bool hasPass() const { return !m_strPass.isEmpty(); }
00468 
00477   TQString host() const { return m_strHost; }
00478 
00489   void setHost( const TQString& _txt );
00498   bool hasHost() const { return !m_strHost.isEmpty(); }
00499 
00509   unsigned short int port() const { return m_iPort; }
00518   void setPort( unsigned short int _p );
00519 
00532   TQString path() const  { return m_strPath; }
00533 
00563   TQString path( int _trailing ) const;
00564 
00581   void setPath( const TQString& path );
00582 
00591   bool hasPath() const { return !m_strPath.isEmpty(); }
00592 
00606   void cleanPath(bool cleanDirSeparator = true);
00607 
00630   void adjustPath(int _trailing);
00631 
00647   void setEncodedPathAndQuery( const TQString& _txt, int encoding_hint = 0 );
00648 
00659   void setEncodedPath(const TQString& _txt, int encoding_hint = 0 );
00660 
00691   TQString encodedPathAndQuery( int _trailing = 0, bool _no_empty_path = false, int encoding_hint = 0) const;
00692 
00706   void setQuery( const TQString& _txt, int encoding_hint = 0);
00707 
00720   TQString query() const;
00721 
00733   TQString ref() const { return m_strRef_encoded; }
00734 
00746   void setRef( const TQString& _txt ) { m_strRef_encoded = _txt; }
00747 
00758   bool hasRef() const { return !m_strRef_encoded.isNull(); }
00759 
00773   TQString htmlRef() const;
00774 
00785   TQString encodedHtmlRef() const;
00786 
00796   void setHTMLRef( const TQString& _ref );
00797 
00808   bool hasHTMLRef() const;
00809 
00816   bool isValid() const  { return !m_bIsMalformed; }
00827   KDE_DEPRECATED bool isMalformed() const { return !isValid(); }
00828 
00835   bool isLocalFile() const;
00836 
00849   void setFileEncoding(const TQString &encoding);
00850 
00859   TQString fileEncoding() const;
00860 
00870   bool hasSubURL() const;
00871 
00886   void addPath( const TQString& txt );
00887 
00901   TQString queryItem( const TQString& item ) const;
00902 
00918   TQString queryItem( const TQString& item, int encoding_hint ) const;
00919 
00925   enum QueryItemsOptions
00926   {
00930     CaseInsensitiveKeys = 1
00931   };
00932 
00936   TQMap< TQString, TQString > queryItems( int options=0 ) const;
00937 
00955   TQMap< TQString, TQString > queryItems( int options, int encoding_hint ) const;
00956 
00972   void addQueryItem( const TQString& _item, const TQString& _value, int encoding_hint = 0 );
00973 
00984   void removeQueryItem( const TQString& _item );
00985 
01006   void setFileName( const TQString&_txt );
01007 
01025   TQString fileName( bool _ignore_trailing_slash_in_path = true ) const;
01026 
01053   TQString directory( bool _strip_trailing_slash_from_result = true,
01054              bool _ignore_trailing_slash_in_path = true ) const;
01055 
01065   void setDirectory(const TQString &dir);
01066 
01085   bool cd( const TQString& _dir );
01086 
01122   TQString url( int _trailing = 0, int encoding_hint = 0) const;
01123 
01156   TQString prettyURL( int _trailing = 0) const;
01157 
01193   TQString prettyURL( int _trailing, AdjustementFlags _flags) const;
01194   // ### BIC: Merge the two above + spell it as "Adjustment"
01195   // Or remove completely, and let people use pathOrURL() instead
01196 
01215   TQString pathOrURL() const;
01216 
01228   TQString htmlURL() const;
01229 
01230 
01242   bool isEmpty() const;
01243 
01263   KURL upURL( ) const;
01264 
01316   bool operator<(const KURL& _u) const;
01317 
01329   KURL& operator=( const KURL& _u );
01330 
01344   KURL& operator=( const TQString& _url );
01345 
01359   KURL& operator=( const char * _url );
01360 
01373   KURL& operator=( const TQUrl & u );
01374 
01394   bool operator==( const KURL& _u ) const;
01395 
01416   bool operator==( const TQString& _u ) const;
01417 
01430   bool operator!=( const KURL& _u ) const { return !( *this == _u ); }
01431 
01444   bool operator!=( const TQString& _u ) const { return !( *this == _u ); }
01445 
01461   bool cmp( const KURL &u, bool ignore_trailing = false ) const KDE_DEPRECATED;
01462 
01476   bool equals( const KURL &u, bool ignore_trailing = false ) const; // TODO KDE4: add bool _ignore_ref = false
01477 
01489   bool isParentOf( const KURL& u ) const;
01490 
01517   static List split( const TQString& _url );
01518 
01544   static List split( const KURL& _url );
01545 
01559   static KURL join( const List& _list );
01560 
01582   static KURL fromPathOrURL( const TQString& text );
01583 
01601   static TQString encode_string(const TQString &str, int encoding_hint = 0);
01602 
01619   static TQString encode_string_no_slash(const TQString &str, int encoding_hint = 0);
01620 
01639   static TQString decode_string(const TQString &str, int encoding_hint = 0);
01640 
01655   static bool isRelativeURL(const TQString &_url);
01656 
01680   static TQString relativeURL(const KURL &base_url, const KURL &url, int encoding_hint = 0);
01681 
01696   static TQString relativePath(const TQString &base_dir, const TQString &path, bool *isParent=0);
01697 
01710   static URIMode uriModeForProtocol(const TQString& protocol);
01711 
01712 #ifdef KDE_NO_COMPAT
01713 private:
01714 #endif
01715 
01718     TQString filename( bool _ignore_trailing_slash_in_path = true ) const
01719   {
01720     return fileName(_ignore_trailing_slash_in_path);
01721   }
01722 
01723 protected:
01739   void reset();
01740   
01750   void parseURL( const TQString& _url, int encoding_hint = 0 );
01760   void parseRawURI( const TQString& _url, int encoding_hint = 0 );
01770   void parseMailto( const TQString& _url, int encoding_hint = 0 );
01778   void parse( const TQString& _url, int encoding_hint = 0 );
01779 
01780 private:
01781   void _setQuery( const TQString& _txt, int encoding_hint = 0);
01782 
01783   TQString m_strProtocol;
01784   TQString m_strUser;
01785   TQString m_strPass;
01786   TQString m_strHost;
01787   TQString m_strPath;
01788   TQString m_strRef_encoded;
01789   TQString m_strQuery_encoded;
01790   bool m_bIsMalformed : 1;
01791   enum URIMode m_iUriMode : 3;
01792   uint freeForUse     : 4;
01793   unsigned short int m_iPort;
01794   TQString m_strPath_encoded;
01795 
01796   friend KDECORE_EXPORT TQDataStream & operator<< (TQDataStream & s, const KURL & a);
01797   friend KDECORE_EXPORT TQDataStream & operator>> (TQDataStream & s, KURL & a);
01798 private:
01799   KURLPrivate* d;
01800 };
01801 
01809 KDECORE_EXPORT bool urlcmp( const TQString& _url1, const TQString& _url2 );
01810 
01823 KDECORE_EXPORT bool urlcmp( const TQString& _url1, const TQString& _url2, bool _ignore_trailing, bool _ignore_ref );
01824 
01825 KDECORE_EXPORT TQDataStream & operator<< (TQDataStream & s, const KURL & a);
01826 KDECORE_EXPORT TQDataStream & operator>> (TQDataStream & s, KURL & a);
01827 
01828 #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.7.6.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |