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

tdecore

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 "tdelibs_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 TDECORE_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 TDECORE_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 
00596   void setInternalReferenceURL( const TQString& url );
00597 
00601   TQString internalReferenceURL( void ) const;
00602 
00616   void cleanPath(bool cleanDirSeparator = true);
00617 
00640   void adjustPath(int _trailing);
00641 
00657   void setEncodedPathAndQuery( const TQString& _txt, int encoding_hint = 0 );
00658 
00669   void setEncodedPath(const TQString& _txt, int encoding_hint = 0 );
00670 
00701   TQString encodedPathAndQuery( int _trailing = 0, bool _no_empty_path = false, int encoding_hint = 0) const;
00702 
00716   void setQuery( const TQString& _txt, int encoding_hint = 0);
00717 
00730   TQString query() const;
00731 
00743   TQString ref() const { return m_strRef_encoded; }
00744 
00756   void setRef( const TQString& _txt ) { m_strRef_encoded = _txt; }
00757 
00768   bool hasRef() const { return !m_strRef_encoded.isNull(); }
00769 
00783   TQString htmlRef() const;
00784 
00795   TQString encodedHtmlRef() const;
00796 
00806   void setHTMLRef( const TQString& _ref );
00807 
00818   bool hasHTMLRef() const;
00819 
00826   bool isValid() const  { return !m_bIsMalformed; }
00837   KDE_DEPRECATED bool isMalformed() const { return !isValid(); }
00838 
00845   bool isLocalFile() const;
00846 
00859   void setFileEncoding(const TQString &encoding);
00860 
00869   TQString fileEncoding() const;
00870 
00880   bool hasSubURL() const;
00881 
00896   void addPath( const TQString& txt );
00897 
00911   TQString queryItem( const TQString& item ) const;
00912 
00928   TQString queryItem( const TQString& item, int encoding_hint ) const;
00929 
00935   enum QueryItemsOptions
00936   {
00940     CaseInsensitiveKeys = 1
00941   };
00942 
00946   TQMap< TQString, TQString > queryItems( int options=0 ) const;
00947 
00965   TQMap< TQString, TQString > queryItems( int options, int encoding_hint ) const;
00966 
00982   void addQueryItem( const TQString& _item, const TQString& _value, int encoding_hint = 0 );
00983 
00994   void removeQueryItem( const TQString& _item );
00995 
01016   void setFileName( const TQString&_txt );
01017 
01035   TQString fileName( bool _ignore_trailing_slash_in_path = true ) const;
01036 
01063   TQString directory( bool _strip_trailing_slash_from_result = true,
01064              bool _ignore_trailing_slash_in_path = true ) const;
01065 
01075   void setDirectory(const TQString &dir);
01076 
01095   bool cd( const TQString& _dir );
01096 
01132   TQString url( int _trailing = 0, int encoding_hint = 0) const;
01133 
01166   TQString prettyURL( int _trailing = 0) const;
01167 
01203   TQString prettyURL( int _trailing, AdjustementFlags _flags) const;
01204   // ### BIC: Merge the two above + spell it as "Adjustment"
01205   // Or remove completely, and let people use pathOrURL() instead
01206 
01225   TQString pathOrURL() const;
01226 
01238   TQString htmlURL() const;
01239 
01240 
01252   bool isEmpty() const;
01253 
01273   KURL upURL( ) const;
01274 
01326   bool operator<(const KURL& _u) const;
01327 
01339   KURL& operator=( const KURL& _u );
01340 
01354   KURL& operator=( const TQString& _url );
01355 
01369   KURL& operator=( const char * _url );
01370 
01383   KURL& operator=( const TQUrl & u );
01384 
01404   bool operator==( const KURL& _u ) const;
01405 
01426   bool operator==( const TQString& _u ) const;
01427 
01440   bool operator!=( const KURL& _u ) const { return !( *this == _u ); }
01441 
01454   bool operator!=( const TQString& _u ) const { return !( *this == _u ); }
01455 
01471   bool cmp( const KURL &u, bool ignore_trailing = false ) const KDE_DEPRECATED;
01472 
01486   bool equals( const KURL &u, bool ignore_trailing = false ) const;
01487 
01502   bool equals( const KURL &u, bool ignore_trailing, bool ignore_internalReferenceURLS ) const; // TODO KDE4: add bool _ignore_ref = false
01503 
01515   bool isParentOf( const KURL& u ) const;
01516 
01543   static List split( const TQString& _url );
01544 
01570   static List split( const KURL& _url );
01571 
01585   static KURL join( const List& _list );
01586 
01608   static KURL fromPathOrURL( const TQString& text );
01609 
01627   static TQString encode_string(const TQString &str, int encoding_hint = 0);
01628 
01645   static TQString encode_string_no_slash(const TQString &str, int encoding_hint = 0);
01646 
01665   static TQString decode_string(const TQString &str, int encoding_hint = 0);
01666 
01681   static bool isRelativeURL(const TQString &_url);
01682 
01706   static TQString relativeURL(const KURL &base_url, const KURL &url, int encoding_hint = 0);
01707 
01722   static TQString relativePath(const TQString &base_dir, const TQString &path, bool *isParent=0);
01723 
01736   static URIMode uriModeForProtocol(const TQString& protocol);
01737 
01738 #ifdef KDE_NO_COMPAT
01739 private:
01740 #endif
01741 
01744     TQString filename( bool _ignore_trailing_slash_in_path = true ) const
01745   {
01746     return fileName(_ignore_trailing_slash_in_path);
01747   }
01748 
01749 protected:
01765   void reset();
01766   
01776   void parseURL( const TQString& _url, int encoding_hint = 0 );
01786   void parseRawURI( const TQString& _url, int encoding_hint = 0 );
01796   void parseMailto( const TQString& _url, int encoding_hint = 0 );
01804   void parse( const TQString& _url, int encoding_hint = 0 );
01805 
01806 private:
01807   void _setQuery( const TQString& _txt, int encoding_hint = 0);
01808 
01809   TQString m_strProtocol;
01810   TQString m_strUser;
01811   TQString m_strPass;
01812   TQString m_strHost;
01813   TQString m_strPath;
01814   TQString m_strRef_encoded;
01815   TQString m_strQuery_encoded;
01816   bool m_bIsMalformed : 1;
01817   enum URIMode m_iUriMode : 3;
01818   uint freeForUse     : 4;
01819   unsigned short int m_iPort;
01820   TQString m_strPath_encoded;
01821 
01822   friend TDECORE_EXPORT TQDataStream & operator<< (TQDataStream & s, const KURL & a);
01823   friend TDECORE_EXPORT TQDataStream & operator>> (TQDataStream & s, KURL & a);
01824 private:
01825   KURLPrivate* d;
01826 };
01827 
01835 TDECORE_EXPORT bool urlcmp( const TQString& _url1, const TQString& _url2 );
01836 
01849 TDECORE_EXPORT bool urlcmp( const TQString& _url1, const TQString& _url2, bool _ignore_trailing, bool _ignore_ref );
01850 
01851 TDECORE_EXPORT TQDataStream & operator<< (TQDataStream & s, const KURL & a);
01852 TDECORE_EXPORT TQDataStream & operator>> (TQDataStream & s, KURL & a);
01853 
01854 #endif

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