summaryrefslogtreecommitdiffstats
path: root/sip/tdecore/kurl.sip
blob: 495f3f46eb4722a7f72228c51400047c10626391 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
//
//     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