//
//     Copyright 2006 Jim Bublitz <jbublitz@nwinternet.com>
//     Earlier copyrights 1998 - 2005 Jim Bublitz and/or Phil Thompson
//     may also apply


//                 Generated by preSip
//            module tdecore  version KDE 3.5.3


// This software is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this library; see the file COPYING.
// If not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.


class KURL
{
%TypeHeaderCode
#include <kurl.h>
%End


public:

    enum AdjustementFlags
    {
        NoAdjustements, 
        StripFileProtocol
    };


%If ( KDE_3_2_0 -  )

    enum URIMode
    {
        Auto, 
        Invalid, 
        RawURI, 
        URL, 
        Mailto
    };

%End

                         KURL ();
                         KURL (const TQString&, int = 0);
                         KURL (const char*, int = 0);
                         KURL (const TQCString&, int = 0);
                         KURL (const KURL&);
                         KURL (const TQUrl&);
                         KURL (const KURL&, const TQString&, int = 0);
    TQString             protocol () const;
    void                 setProtocol (const TQString&);

%If ( KDE_3_2_0 -  )
    int                  uriMode () const;
%End

    TQString             user () const;
    void                 setUser (const TQString&);
    bool                 hasUser () const;
    TQString             pass ()  /PyName=pass_/;
    void                 setPass (const TQString&);
    bool                 hasPass () const;
    TQString             host () const;
    void                 setHost (const TQString&);
    bool                 hasHost () const;
    ushort               port () const;
    void                 setPort (ushort);
    TQString             path () const;
    TQString             path (int) const;
    void                 setPath (const TQString&);
    bool                 hasPath () const;
    void                 cleanPath (bool = 0);
    void                 adjustPath (int);
    void                 setEncodedPathAndQuery (const TQString&, int = 0);
    void                 setEncodedPath (const TQString&, int = 0);
    TQString             encodedPathAndQuery (int = 0, bool = 0, int = 0) const;
    void                 setQuery (const TQString&, int = 0);
    TQString             query () const;
    TQString             ref () const;
    void                 setRef (const TQString&);
    bool                 hasRef () const;
    TQString             htmlRef () const;
    TQString             encodedHtmlRef () const;
    void                 setHTMLRef (const TQString&);
    bool                 hasHTMLRef () const;
    bool                 isValid () const;
    bool                 isMalformed () const;
    bool                 isLocalFile () const;
    void                 setFileEncoding (const TQString&);
    TQString             fileEncoding () const;
    bool                 hasSubURL () const;
    void                 addPath (const TQString&);
    TQString             queryItem (const TQString&) const;

%If ( KDE_3_2_0 -  )
    TQString             queryItem (const TQString&, int) const;
%End


%If ( KDE_3_1_0 -  )

    enum QueryItemsOptions
    {
        CaseInsensitiveKeys
    };

    TQMap<TQString, TQString> queryItems (int = 0) const;

%If ( KDE_3_2_0 -  )
    TQMap<TQString, TQString> queryItems (int, int) const;
%End

    void                 addQueryItem (const TQString&, const TQString&, int = 0);
    void                 removeQueryItem (const TQString&);
%End

    void                 setFileName (const TQString&);
    TQString             fileName (bool = 1) const;
    TQString             directory (bool = 1, bool = 1) const;

%If ( KDE_3_2_0 -  )
    void                 setDirectory (const TQString&);
%End

    bool                 cd (const TQString&);
    TQString             url (int = 0, int = 0) const;
    TQString             prettyURL (int = 0) const;
    TQString             prettyURL (int, KURL::AdjustementFlags) const;

%If ( KDE_3_4_0 -  )
    TQString             pathOrURL () const;
%End


%If ( KDE_3_0_1 -  )
    TQString             htmlURL () const;
%End

    bool                 isEmpty () const;
    KURL                 upURL () const;

%If ( KDE_3_2_0 -  )
    bool                 operator < (const KURL&) const;
%End


%If ( KDE_3_1_4 -  )
    bool                 operator == (const KURL&) const;
    bool                 operator == (const TQString&) const;
    bool                 operator != (const KURL&) const;
    bool                 operator != (const TQString&) const;
%End

    bool                 cmp (const KURL&, bool = 0) const;

%If ( KDE_3_1_0 -  )
    bool                 equals (const KURL&, bool = 0) const;
%End

    bool                 isParentOf (const KURL&) const;
    static KURL::List    split (const TQString&);
    static KURL::List    split (const KURL&);
    static KURL          join (const KURL::List&);

%If ( KDE_3_1_0 -  )
    static KURL          fromPathOrURL (const TQString&);
%End

    static TQString      encode_string (const TQString&, int = 0);
    static TQString      encode_string_no_slash (const TQString&, int = 0);
    static TQString      decode_string (const TQString&, int = 0);
    static bool          isRelativeURL (const TQString&);

%If ( KDE_3_2_0 -  )
    static TQString      relativeURL (const KURL&, const KURL&, int = 0);
    static TQString      relativePath (const TQString&, const TQString&, bool* = 0);
    static KURL::URIMode uriModeForProtocol (const TQString&);
%End

    TQString             filename (bool = 1) const;

protected:
    void                 reset ();

%If ( KDE_3_2_0 -  )
    void                 parseURL (const TQString&, int = 0);
    void                 parseRawURI (const TQString&, int = 0);
    void                 parseMailto (const TQString&, int = 0);
%End

    void                 parse (const TQString&, int = 0);

public:
//force

    class List
    {

    public:
                             List ();
                             List (const TQStringList&);
        TQStringList          toStringList () const;
        bool                 isEmpty () const;
        void                 append (const KURL&);
        void                 prepend (const KURL&);
        void                 remove (const KURL&);
        const KURL&          first () const;
        const KURL&          last () const;
        int                  findIndex (const KURL&) const;
        uint                 contains (const KURL&) const;
        uint                 count () const;
        void                 clear ();
        int                  __len__ ()  /NonLazy/;
%MethodCode
//returns (int)
    Py_BEGIN_ALLOW_THREADS
    sipRes = sipCpp -> count();
    Py_END_ALLOW_THREADS
%End

        void                 __setitem__ (int, const KURL&);
%MethodCode
//takes index | (int) | value | (KURL)
    int len;

    len = sipCpp -> count();

    if ((a0 = sipConvertFromSequenceIndex(a0,len)) < 0)
        sipIsErr = 1;
    else
        (*sipCpp)[a0] = *a1;
%End

        void                 __setitem__ (SIP_PYSLICE, const KURL::List&);
%MethodCode
//takes range | (a Python slice) | urlList | (KURL.List)

    int len;
    SIP_SSIZE_T start, stop, step, slicelength;

    len = sipCpp -> count();

    if (sipConvertFromSliceObject(a0,len,&start,&stop,&step,&slicelength) < 0)
        sipIsErr = 1;
    else
    {
        int vlen = a1 -> count();
        if (vlen != slicelength)
        {
            sipBadLengthForSlice(vlen,slicelength);
            sipIsErr = 1;
        }
        else
        {
            KURL::List::ConstIterator it = a1 -> begin();
            for (int i = 0; i < slicelength; ++i)
            {
                (*sipCpp)[start] = *it;
                start += step;
                ++it;
            }
        }
    }
%End

        void                 __delitem__ (int);
%MethodCode
//takes index | (int)
    int len;

    len = sipCpp -> count();

    if ((a0 = sipConvertFromSequenceIndex(a0,len)) < 0)
        sipIsErr = 1;
    else
        sipCpp -> remove(sipCpp -> at(a0));
%End

        void                 __delitem__ (SIP_PYSLICE);
%MethodCode
//takes range | (a Python slice)
    int len;
    SIP_SSIZE_T start, stop, step, slicelength;

    len = sipCpp -> count();
    if (sipConvertFromSliceObject(a0,len,&start,&stop,&step,&slicelength) < 0)
        sipIsErr = 1;
    else
        for (int i = 0; i < slicelength; ++i)
        {
            sipCpp -> remove(sipCpp -> at(start));
            start += step - 1;
        }
%End

        KURL                 operator [] (int);
%MethodCode
//returns (KURL)
//takes index | (int)
    int len;

    len = sipCpp -> count();

    if ((a0 = sipConvertFromSequenceIndex(a0,len)) < 0)
        sipIsErr = 1;
    else
        sipRes = new KURL((*sipCpp)[a0]);
%End

        KURL::List           operator [] (SIP_PYSLICE);
%MethodCode
//returns (KURL.List)
//takes range | (a Python slice)
    int len;
    SIP_SSIZE_T start, stop, step, slicelength;

    len = sipCpp -> count();

    if (sipConvertFromSliceObject(a0,len,&start,&stop,&step,&slicelength) < 0)
        sipIsErr = 1;
    else
    {
        sipRes = new KURL::List();

        for (int i = 0; i < slicelength; ++i)
        {
            (*sipRes) += (*sipCpp)[start];
            start += step;
        }
    }
%End

        KURL::List           operator + (const KURL::List&);
%MethodCode
//returns (KURL.List)
//takes listToAdd | (KURL.List)
    Py_BEGIN_ALLOW_THREADS
//    sipRes = new KURL::List((const KURL::List&)((*sipCpp) + *a0));
    sipRes = new KURL::List (*sipCpp);
    (*sipRes) += (*a0);
    Py_END_ALLOW_THREADS
%End

        KURL::List&          operator += (const KURL::List&);
        KURL::List           operator * (int);
%MethodCode
    sipRes = new KURL::List();

    for (int i = 0; i < a0; ++i)
        (*sipRes) += (*sipCpp);
%End

        KURL::List&          operator *= (int);
%MethodCode
//returns (KURL.List)
//takes val | (int)
    KURL::List orig(*sipCpp);

    sipCpp -> clear();

    for (int i = 0; i < a0; ++i)
        (*sipCpp) += orig;
%End

        bool                 operator == (const KURL::List&);
        bool                 operator != (const KURL::List&);
        int                  __contains__ (KURL)  /NonLazy/;
%MethodCode
//returns (bool)
//takes a0 | (KURL)

    TQString s = a0->url ();
    sipRes = 0;
    KURL::List::Iterator it;
    for (it = sipCpp->begin (); (it != sipCpp->end ()) && (sipRes == 0); it++)
        if (s == (*it).url ())
            sipRes = 1;
%End


    };  // class List


public:
//end

};  // class KURL

bool                 urlcmp (const TQString&, const TQString&);
bool                 urlcmp (const TQString&, const TQString&, bool, bool);

%If ( KDE_3_1_4 -  )
//igx TQDataStream&         operator << (TQDataStream&, const KURL&);
//igx TQDataStream&         operator >> (TQDataStream&, KURL&);
%End
