# kdecore Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# 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., 59 Temple Place - Suite 330,
    00017  *  Boston, MA 02111-1307, USA.
    00018  **/
    00019
    00020 #ifndef __kurl_h__
    00021 #define __kurl_h__ "$Id: kurl.h,v 1.102.2.2 2003/02/22 09:54:36 kalass Exp $"
    00022
    00023 #include <qstring.h>
    00024 #include <qvaluelist.h>
    00025
    00026 class QUrl;
    00027 class QStringList;
    00028 template <typename K, typename V> class QMap;
    00029
    00030 class KURLPrivate;
    00052 class KURL
    00053 {
    00054 public:
    00055   enum AdjustementFlags
    00056   {
    00057     NoAdjustements = 0,
    00058     StripFileProtocol = 1
    00059   };
    00060
    00067   class List : public QValueList<KURL>
    00068   {
    00069   public:
    00073       List() { }
    00079       List(const KURL &url);
    00085       List(const QStringList &list);
    00090       QStringList toStringList() const;
    00091   };
    00095   KURL();
    00096
    00100   ~KURL();
    00101
    00118   KURL( const QString& url, int encoding_hint = 0 );
    00128   KURL( const char * url, int encoding_hint = 0 );
    00138   KURL( const QCString& url, int encoding_hint = 0 );
    00143   KURL( const KURL& u );
    00148   KURL( const QUrl &u );
    00161   KURL( const KURL& _baseurl, const QString& _rel_url, int encoding_hint=0 );
    00162
    00168   QString protocol() const { return m_bIsMalformed ? QString::null : m_strProtocol; }
    00173   void setProtocol( const QString& _txt );
    00174
    00179   QString user() const { return m_strUser; }
    00186   void setUser( const QString& _txt );
    00191   bool hasUser() const { return !m_strUser.isEmpty(); }
    00192
    00197   QString pass() const { return m_strPass; }
    00208   void setPass( const QString& _txt );
    00213   bool hasPass() const { return !m_strPass.isEmpty(); }
    00214
    00219   QString host() const { return m_strHost; }
    00226   void setHost( const QString& _txt );
    00231   bool hasHost() const { return !m_strHost.isEmpty(); }
    00232
    00238   unsigned short int port() const { return m_iPort; }
    00243   void setPort( unsigned short int _p );
    00244
    00250   QString path() const  { return m_strPath; }
    00251
    00265   QString path( int _trailing ) const;
    00266
    00275   void setPath( const QString& path );
    00276
    00281   bool hasPath() const { return !m_strPath.isEmpty(); }
    00282
    00291   void cleanPath(bool cleanDirSeparator = true);
    00292
    00304   void adjustPath(int _trailing);
    00305
    00313   void setEncodedPathAndQuery( const QString& _txt, int encoding_hint = 0 );
    00314
    00321   void setEncodedPath(const QString& _txt, int encoding_hint = 0 );
    00322
    00340   QString encodedPathAndQuery( int _trailing = 0, bool _no_empty_path = false, int encoding_hint = 0) const;
    00341
    00350   void setQuery( const QString& _txt, int encoding_hint = 0);
    00351
    00360   QString query() const;
    00361
    00366   QString ref() const { return m_strRef_encoded; }
    00367
    00372   void setRef( const QString& _txt ) { m_strRef_encoded = _txt; }
    00373
    00380   bool hasRef() const { return !m_strRef_encoded.isNull(); }
    00381
    00389   QString htmlRef() const;
    00390
    00396   QString encodedHtmlRef() const;
    00397
    00405   void setHTMLRef( const QString& _ref );
    00406
    00412   bool hasHTMLRef() const;
    00413
    00419   bool isValid() const  { return !m_bIsMalformed; }
    00423   bool isMalformed() const { return !isValid(); }
    00424
    00430   bool isLocalFile() const;
    00431
    00438   void setFileEncoding(const QString &encoding);
    00439
    00446   QString fileEncoding() const;
    00447
    00454   bool hasSubURL() const;
    00455
    00466   void addPath( const QString& _txt );
    00467
    00476   QString queryItem( const QString& _item ) const;
    00477
    00486   enum QueryItemsOptions { CaseInsensitiveKeys = 1 };
    00487
    00498   QMap< QString, QString > queryItems( int options=0 ) const;
    00499
    00510   void addQueryItem( const QString& _item, const QString& _value, int encoding_hint = 0 );
    00511
    00517   void removeQueryItem( const QString& _item );
    00518
    00532   void setFileName( const QString&_txt );
    00533
    00544   QString fileName( bool _ignore_trailing_slash_in_path = true ) const;
    00545
    00557   QString directory( bool _strip_trailing_slash_from_result = true,
    00558                      bool _ignore_trailing_slash_in_path = true ) const;
    00559
    00573   bool cd( const QString& _dir );
    00574
    00588   QString url( int _trailing = 0, int encoding_hint = 0) const;
    00589
    00596   QString prettyURL( int _trailing = 0) const;
    00597
    00598
    00605   QString htmlURL() const;
    00606
    00613   QString prettyURL( int _trailing, AdjustementFlags _flags) const;
    00614   // ### BIC: Merge the two above
    00615
    00620   bool isEmpty() const;
    00621
    00630   KURL upURL( ) const;
    00631
    00632   KURL& operator=( const KURL& _u );
    00633   KURL& operator=( const QString& _url );
    00634   KURL& operator=( const char * _url );
    00635   KURL& operator=( const QUrl & u );
    00636
    00637   bool operator==( const KURL& _u ) const;
    00638   bool operator==( const QString& _u ) const;
    00639   bool operator!=( const KURL& _u ) const { return !( *this == _u ); }
    00640   bool operator!=( const QString& _u ) const { return !( *this == _u ); }
    00641
    00651   bool cmp( const KURL &u, bool ignore_trailing = false ) const;
    00652
    00661   bool equals( const KURL &u, bool ignore_trailing = false ) const;
    00662
    00668   bool isParentOf( const KURL& u ) const;
    00669
    00685   static List split( const QString& _url );
    00686
    00702   static List split( const KURL& _url );
    00703
    00711   static KURL join( const List& _list );
    00712
    00726   static KURL fromPathOrURL( const QString& text );
    00727
    00738   static QString encode_string(const QString &str, int encoding_hint = 0);
    00739
    00750   static QString encode_string_no_slash(const QString &str, int encoding_hint = 0);
    00751
    00762   static QString decode_string(const QString &str, int encoding_hint = 0);
    00763
    00772   static bool isRelativeURL(const QString &_url);
    00773
    00774 #ifdef KDE_NO_COMPAT
    00775 private:
    00776 #endif
    00777   QString filename( bool _ignore_trailing_slash_in_path = true ) const
    00778   {
    00779     return fileName(_ignore_trailing_slash_in_path);
    00780   }
    00781
    00782 protected:
    00783   void reset();
    00784   void parse( const QString& _url, int encoding_hint = 0);
    00785
    00786 private:
    00787   QString m_strProtocol;
    00788   QString m_strUser;
    00789   QString m_strPass;
    00790   QString m_strHost;
    00791   QString m_strPath;
    00792   QString m_strRef_encoded;
    00793   QString m_strQuery_encoded;
    00794   bool m_bIsMalformed : 1;
    00795   int freeForUse      : 7;
    00796   unsigned short int m_iPort;
    00797   QString m_strPath_encoded;
    00798
    00799   friend QDataStream & operator<< (QDataStream & s, const KURL & a);
    00800   friend QDataStream & operator>> (QDataStream & s, KURL & a);
    00801 private:
    00802   KURLPrivate* d;
    00803 };
    00804
    00811 bool urlcmp( const QString& _url1, const QString& _url2 );
    00812
    00822 bool urlcmp( const QString& _url1, const QString& _url2, bool _ignore_trailing, bool _ignore_ref );
    00823
    00824 QDataStream & operator<< (QDataStream & s, const KURL & a);
    00825 QDataStream & operator>> (QDataStream & s, KURL & a);
    00826
    00827 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:46:59 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001