File: qstring.sip

package info (click to toggle)
python-qt4 4.11.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 40,148 kB
  • ctags: 6,150
  • sloc: python: 125,936; cpp: 12,628; xml: 292; makefile: 259; php: 27; sh: 2
file content (1005 lines) | stat: -rw-r--r-- 33,343 bytes parent folder | download
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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
// qstring.sip generated by MetaSIP
//
// This file is part of the QtCore Python extension module.
//
// Copyright (c) 2015 Riverbank Computing Limited <info@riverbankcomputing.com>
// 
// This file is part of PyQt4.
// 
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file.  Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
// 
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license.  For more information contact
// info@riverbankcomputing.com.
// 
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.


%ModuleCode
#include <qstring.h>
%End

// class QString /AllowNone,API=QString:2 -,DocType="str"/
%MappedType QString /AllowNone,API=QString:2 -,DocType="str"/
{
%TypeHeaderCode
#include <qstring.h>
%End

%ConvertToTypeCode
if (sipIsErr == NULL)
#if PY_MAJOR_VERSION < 3
    return (sipPy == Py_None || PyString_Check(sipPy) || PyUnicode_Check(sipPy));
#else
    return (sipPy == Py_None || PyUnicode_Check(sipPy));
#endif

if (sipPy == Py_None)
{
    // None is the only way to create a null (as opposed to empty) QString.
    *sipCppPtr = new QString();

    return sipGetState(sipTransferObj);
}

#if PY_MAJOR_VERSION < 3
if (PyString_Check(sipPy))
{
    *sipCppPtr = new QString(PyString_AS_STRING(sipPy));

    return sipGetState(sipTransferObj);
}
#endif

*sipCppPtr = new QString(qpycore_PyObject_AsQString(sipPy));

return sipGetState(sipTransferObj);
%End

%ConvertFromTypeCode
    return qpycore_PyObject_FromQString(*sipCpp);
%End
};

class QString /API=QString: - 2/
{
%TypeHeaderCode
#include <qstring.h>
%End

%TypeCode
// This is needed by __hash__().
#include <qhash.h>


// This is needed by the %BIGetCharBufferCode.
#include <qtextcodec.h>
%End

%ConvertToTypeCode
// See the comments for the QByteArray %ConvertToTypeCode for an explanation
// of the conversions that are done below.

if (sipIsErr == NULL)
    return (PyUnicode_Check(sipPy) ||
#if PY_MAJOR_VERSION < 3
            PyString_Check(sipPy) ||
#endif
            sipCanConvertToType(sipPy, sipType_QLatin1String, 0) ||
            sipCanConvertToType(sipPy, sipType_QChar, 0) ||
            sipCanConvertToType(sipPy, sipType_QString, SIP_NO_CONVERTORS));

if (PyUnicode_Check(sipPy))
{
    *sipCppPtr = new QString(qpycore_PyObject_AsQString(sipPy));

    return sipGetState(sipTransferObj);
}

#if PY_MAJOR_VERSION < 3
if (PyString_Check(sipPy))
{
    *sipCppPtr = new QString(PyString_AS_STRING(sipPy));

    return sipGetState(sipTransferObj);
}
#endif

if (sipCanConvertToType(sipPy, sipType_QLatin1String, 0))
{
    int state;
    QLatin1String *q = reinterpret_cast<QLatin1String *>(sipConvertToType(sipPy,
            sipType_QLatin1String, 0, 0, &state, sipIsErr));

    if (*sipIsErr)
    {
        sipReleaseType(q, sipType_QLatin1String, state);
        return 0;
    }

    *sipCppPtr = new QString(*q);

    sipReleaseType(q, sipType_QLatin1String, state);

    return sipGetState(sipTransferObj);
}

if (sipCanConvertToType(sipPy, sipType_QChar, 0))
{
    int state;
    QChar *q = reinterpret_cast<QChar *>(sipConvertToType(sipPy,
            sipType_QChar, 0, 0, &state, sipIsErr));

    if (*sipIsErr)
    {
        sipReleaseType(q, sipType_QChar, state);
        return 0;
    }

    *sipCppPtr = new QString(*q);

    sipReleaseType(q, sipType_QChar, state);

    return sipGetState(sipTransferObj);
}

*sipCppPtr = reinterpret_cast<QString *>(sipConvertToType(sipPy,
        sipType_QString, sipTransferObj, SIP_NO_CONVERTORS, 0, sipIsErr));

return 0;
%End

%BIGetReadBufferCode
    if (sipSegment != 0)
    {
        PyErr_SetString(PyExc_SystemError, "accessing non-existent QString segment");
        sipRes = -1;
    }
    else
    {
        // To keep things easy we convert to a Python Unicode object, keep a
        // reference to it and expose its contents.
        PyObject *uobj = qpycore_PyObject_FromQString(*sipCpp);
    
        if (uobj)
        {
            Py_XDECREF(((sipSimpleWrapper *)sipSelf)->user);
            ((sipSimpleWrapper *)sipSelf)->user = uobj;
    
            *sipPtrPtr = (void *)PyUnicode_AS_UNICODE(uobj);
            sipRes = PyUnicode_GET_DATA_SIZE(uobj);
        }
        else
        {
            sipRes = -1;
        }
    }
%End

%BIGetSegCountCode
    if (sipLenPtr)
        *sipLenPtr = sipCpp->size() * sizeof (Py_UNICODE);
    
    sipRes = 1;
%End

%BIGetCharBufferCode
    if (sipSegment != 0)
    {
        PyErr_SetString(PyExc_SystemError, "accessing non-existent QString segment");
        sipRes = -1;
    }
    else
    {
        static QTextCodec *codec = 0;
        static bool check_codec = true;
    
        // For the first time only, try and find a Qt codec that corresponds to the
        // default Python codec.  If one wasn't found then fall back to ASCII
        // (which is actually the codec returned by QTextCodec::codecForCStrings()).
        if (check_codec)
        {
            codec = QTextCodec::codecForName(PyUnicode_GetDefaultEncoding());
            check_codec = false;
        }
    
        QByteArray enc;
    
        if (codec)
            enc = codec->fromUnicode(*sipCpp);
        else
    #if QT_VERSION >= 0x050000
            enc = sipCpp->toLatin1();
    #else
            enc = sipCpp->toAscii();
    #endif
        
        // A Python string is the most convenient method to save the encoded
        // version on the heap.
        PyObject *encobj = ((sipSimpleWrapper *)sipSelf)->user;
    
        Py_XDECREF(encobj);
    
        if ((encobj = PyString_FromStringAndSize(enc.data(), enc.size())) != NULL)
        {
            *sipPtrPtr = (void *)PyString_AS_STRING(encobj);
            sipRes = PyString_GET_SIZE(encobj);
    
            ((sipSimpleWrapper *)sipSelf)->user = encobj;
        }
        else
            sipRes = -1;
    }
%End

%PickleCode
    sipRes = Py_BuildValue((char *)"(O)", qpycore_PyObject_FromQString(*sipCpp));
%End

public:
    QString();
    QString(int size, QChar c);
    QString(const QString &s);
    QString(const QByteArray &a);
    ~QString();
    SIP_PYOBJECT __repr__() const /DocType="str"/;
%MethodCode
        PyObject *uni = qpycore_PyObject_FromQString(*sipCpp);
        
        if (uni)
        {
        #if PY_MAJOR_VERSION >= 3
            sipRes = PyUnicode_FromFormat("PyQt4.QtCore.QString(%R)", uni);
        #else
            sipRes = PyString_FromString("PyQt4.QtCore.QString(");
            PyString_ConcatAndDel(&sipRes, PyObject_Repr(uni));
            PyString_ConcatAndDel(&sipRes, PyString_FromString(")"));
        #endif
        
            Py_DECREF(uni);
        }
%End

    int size() const;
    int count() const /__len__/;
    void resize(int size);
    QString &fill(QChar ch, int size = -1);
    void truncate(int pos);
    void chop(int n);
    void squeeze();
%If (Qt_5_0_0 -)
    QString arg(int a /Constrained/, int fieldWidth = 0, int base = 10, QChar fillChar = QLatin1Char(' ')) const;
%End
%If (- Qt_5_0_0)
    QString arg(int a /Constrained/, int fieldWidth = 0, int base = 10, const QChar &fillChar = QLatin1Char(' ')) const;
%End
%If (Qt_5_0_0 -)
    QString arg(double a /Constrained/, int fieldWidth = 0, char format = 'g', int precision = -1, QChar fillChar = QLatin1Char(' ')) const;
%End
%If (- Qt_5_0_0)
    QString arg(double a /Constrained/, int fieldWidth = 0, char format = 'g', int precision = -1, const QChar &fillChar = QLatin1Char(' ')) const;
%End
%If (Qt_5_0_0 -)
    QString arg(qlonglong a, int fieldwidth = 0, int base = 10, QChar fillChar = QLatin1Char(' ')) const;
%End
%If (- Qt_5_0_0)
    QString arg(qlonglong a, int fieldWidth = 0, int base = 10, const QChar &fillChar = QLatin1Char(' ')) const;
%End
%If (Qt_5_0_0 -)
    QString arg(qulonglong a, int fieldwidth = 0, int base = 10, QChar fillChar = QLatin1Char(' ')) const;
%End
%If (- Qt_5_0_0)
    QString arg(qulonglong a, int fieldWidth = 0, int base = 10, const QChar &fillChar = QLatin1Char(' ')) const;
%End
%If (Qt_5_0_0 -)
    QString arg(const QString &a, int fieldWidth = 0, QChar fillChar = QLatin1Char(' ')) const;
%End
%If (- Qt_5_0_0)
    QString arg(const QString &a, int fieldWidth = 0, const QChar &fillChar = QLatin1Char(' ')) const;
%End
    QString arg(const QString &a1, const QString &a2) const;
    QString arg(const QString &a1, const QString &a2, const QString &a3) const;
    QString arg(const QString &a1, const QString &a2, const QString &a3, const QString &a4) const;
%If (Qt_4_3_0 -)
    QString arg(const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5) const;
%End
%If (Qt_4_3_0 -)
    QString arg(const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6) const;
%End
%If (Qt_4_3_0 -)
    QString arg(const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6, const QString &a7) const;
%End
%If (Qt_4_3_0 -)
    QString arg(const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6, const QString &a7, const QString &a8) const;
%End
%If (Qt_4_3_0 -)
    QString arg(const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6, const QString &a7, const QString &a8, const QString &a9) const;
%End
    int count(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%If (Qt_4_8_0 -)
    int count(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
    int count(const QRegExp &) const;
    int indexOf(const QString &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%If (Qt_4_8_0 -)
    int indexOf(const QStringRef &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_5_0 -)
    int indexOf(const QLatin1String &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
    int indexOf(const QRegExp &rx, int from = 0) const;
    int lastIndexOf(const QString &str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%If (Qt_4_8_0 -)
    int lastIndexOf(const QStringRef &str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_5_0 -)
    int lastIndexOf(const QLatin1String &str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
    int lastIndexOf(const QRegExp &rx, int from = -1) const;
%If (Qt_5_0_0 -)
    bool contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (- Qt_5_0_0)
    QBool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_5_0_0 -)
    bool contains(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 - Qt_5_0_0)
    QBool contains(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_5_0_0 -)
    bool contains(const QRegExp &rx) const;
%End
%If (- Qt_5_0_0)
    QBool contains(const QRegExp &rx) const;
%End

    enum SectionFlag
    {
        SectionDefault,
        SectionSkipEmpty,
        SectionIncludeLeadingSep,
        SectionIncludeTrailingSep,
        SectionCaseInsensitiveSeps,
    };

    typedef QFlags<QString::SectionFlag> SectionFlags;
    QString section(const QString &sep, int start, int end = -1, QFlags<QString::SectionFlag> flags = SectionDefault) const;
    QString section(const QRegExp &reg, int start, int end = -1, QFlags<QString::SectionFlag> flags = SectionDefault) const;
    QString left(int len) const;
    QString right(int len) const;
    QString mid(int position, int n = -1) const;
    bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%If (Qt_4_8_0 -)
    bool startsWith(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
    bool startsWith(const QLatin1String &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
    bool endsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%If (Qt_4_8_0 -)
    bool endsWith(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
    bool endsWith(const QLatin1String &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
    QString leftJustified(int width, QChar fillChar = QLatin1Char(' '), bool truncate = false) const;
    QString rightJustified(int width, QChar fillChar = QLatin1Char(' '), bool truncate = false) const;
    QString toLower() const;
    QString toUpper() const;
    QString trimmed() const;
    QString simplified() const;
    QString &insert(int i, const QString &s);
    QString &insert(int i, const QLatin1String &s);
    QString &append(const QString &s);
    QString &append(const QLatin1String &s);
    QString &prepend(const QString &s);
    QString &prepend(const QLatin1String &s);
    QString &operator+=(QChar::SpecialCharacter c);
    QString &operator+=(const QString &s);
    QString &operator+=(const QLatin1String &s);
    QString &remove(int i, int len);
    QString &remove(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive);
    QString &replace(int i, int len, const QString &after);
    QString &replace(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
    QString &replace(const QRegExp &rx, const QString &after);
    QString &remove(const QRegExp &rx);

    enum SplitBehavior
    {
        KeepEmptyParts,
        SkipEmptyParts,
    };

    QStringList split(const QString &sep, QString::SplitBehavior behavior = QString::KeepEmptyParts, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
    QStringList split(const QRegExp &sep, QString::SplitBehavior behavior = QString::KeepEmptyParts) const;

    enum NormalizationForm
    {
        NormalizationForm_D,
        NormalizationForm_C,
        NormalizationForm_KD,
        NormalizationForm_KC,
    };

%If (Qt_5_0_0 -)
    QString normalized(QString::NormalizationForm mode, QChar::UnicodeVersion version = QChar::Unicode_Unassigned) const;
%End
%If (- Qt_5_0_0)
    QString normalized(QString::NormalizationForm mode) const;
%End
%If (- Qt_5_0_0)
    QString normalized(QString::NormalizationForm mode, QChar::UnicodeVersion version) const;
%End
%If (PyQt_Deprecated_5_0)
    QByteArray toAscii() const;
%End
    QByteArray toLatin1() const;
    QByteArray toUtf8() const;
    QByteArray toLocal8Bit() const;
%If (PyQt_Deprecated_5_0)
    static QString fromAscii(const char *str /Encoding="ASCII"/, int size = -1);
%End
    static QString fromLatin1(const char *str /Encoding="Latin-1"/, int size = -1);
    static QString fromUtf8(const char *str /Encoding="UTF-8"/, int size = -1);
    static QString fromLocal8Bit(const char *str /Encoding="None"/, int size = -1);
%If (Qt_5_0_0 -)
    int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (- Qt_5_0_0)
    int compare(const QString &s) const;
%End
%If (Qt_4_2_0 - Qt_5_0_0)
    int compare(const QString &s, Qt::CaseSensitivity cs) const;
%End
%If (Qt_4_2_0 -)
    int compare(const QLatin1String &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_5_0 -)
    int compare(const QStringRef &ref, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_5_0_0 -)
    static int compare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive);
%End
%If (- Qt_5_0_0)
    static int compare(const QString &s1, const QString &s2);
%End
%If (Qt_4_2_0 - Qt_5_0_0)
    static int compare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs);
%End
%If (Qt_4_2_0 -)
    static int compare(const QString &s1, const QLatin1String &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive);
%End
%If (Qt_4_2_0 -)
    static int compare(const QLatin1String &s1, const QString &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive);
%End
%If (Qt_4_5_0 -)
    static int compare(const QString &s1, const QStringRef &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive);
%End
    int localeAwareCompare(const QString &s) const;
%If (Qt_4_5_0 -)
    int localeAwareCompare(const QStringRef &s) const;
%End
    static int localeAwareCompare(const QString &s1, const QString &s2);
%If (Qt_4_5_0 -)
    static int localeAwareCompare(const QString &s1, const QStringRef &s2);
%End
    short toShort(bool *ok = 0, int base = 10) const;
    ushort toUShort(bool *ok = 0, int base = 10) const;
    int toInt(bool *ok = 0, int base = 10) const;
    uint toUInt(bool *ok = 0, int base = 10) const;
    long toLong(bool *ok = 0, int base = 10) const;
    ulong toULong(bool *ok = 0, int base = 10) const;
    qlonglong toLongLong(bool *ok = 0, int base = 10) const;
    qulonglong toULongLong(bool *ok = 0, int base = 10) const;
    float toFloat(bool *ok = 0) const;
    double toDouble(bool *ok = 0) const;
    QString &setNum(int n /Constrained/, int base = 10);
    QString &setNum(double n /Constrained/, char format = 'g', int precision = 6);
    QString &setNum(qlonglong n, int base = 10);
    QString &setNum(qulonglong n, int base = 10);
    static QString number(int n /Constrained/, int base = 10);
    static QString number(double n /Constrained/, char format = 'g', int precision = 6);
    static QString number(qlonglong n, int base = 10);
    static QString number(qulonglong n, int base = 10);
    bool operator==(const QString &s) const;
%MethodCode
        // In Qt5 this is a global operator and so SIP appends it to the list of class operators.
        // However these must appear before the corresponding QByteArray argument operator.
        #if QT_VERSION >= 0x050000
            sipRes = operator==(*sipCpp, *a0);
        #else
            sipRes = sipCpp->QString::operator==(*a0);
        #endif
%End

    bool operator<(const QString &s) const;
%MethodCode
        // In Qt5 this is a global operator and so SIP appends it to the list of class operators.
        // However these must appear before the corresponding QByteArray argument operator.
        #if QT_VERSION >= 0x050000
            sipRes = operator<(*sipCpp, *a0);
        #else
            sipRes = sipCpp->QString::operator<(*a0);
        #endif
%End

    bool operator>(const QString &s) const;
%MethodCode
        // In Qt5 this is a global operator and so SIP appends it to the list of class operators.
        // However these must appear before the corresponding QByteArray argument operator.
        #if QT_VERSION >= 0x050000
            sipRes = operator>(*sipCpp, *a0);
        #else
            sipRes = sipCpp->QString::operator<(*a0);
        #endif
%End

    bool operator!=(const QString &s) const;
%MethodCode
        // In Qt5 this is a global operator and so SIP appends it to the list of class operators.
        // However these must appear before the corresponding QByteArray argument operator.
        #if QT_VERSION >= 0x050000
            sipRes = operator!=(*sipCpp, *a0);
        #else
            sipRes = sipCpp->QString::operator!=(*a0);
        #endif
%End

    bool operator<=(const QString &s) const;
%MethodCode
        // In Qt5 this is a global operator and so SIP appends it to the list of class operators.
        // However these must appear before the corresponding QByteArray argument operator.
        #if QT_VERSION >= 0x050000
            sipRes = operator<=(*sipCpp, *a0);
        #else
            sipRes = sipCpp->QString::operator<=(*a0);
        #endif
%End

    bool operator>=(const QString &s) const;
%MethodCode
        // In Qt5 this is a global operator and so SIP appends it to the list of class operators.
        // However these must appear before the corresponding QByteArray argument operator.
        #if QT_VERSION >= 0x050000
            sipRes = operator>=(*sipCpp, *a0);
        #else
            sipRes = sipCpp->QString::operator>=(*a0);
        #endif
%End

    bool operator==(const QLatin1String &s) const;
    bool operator<(const QLatin1String &s) const;
    bool operator>(const QLatin1String &s) const;
    bool operator!=(const QLatin1String &s) const;
    bool operator<=(const QLatin1String &s) const;
    bool operator>=(const QLatin1String &s) const;
    QString &prepend(const QByteArray &s);
    QString &append(const QByteArray &s);
    QString &operator+=(const QByteArray &s);
    bool operator==(const QByteArray &s) const;
    bool operator!=(const QByteArray &s) const;
    bool operator<(const QByteArray &s) const;
    bool operator>(const QByteArray &s) const;
    bool operator<=(const QByteArray &s) const;
    bool operator>=(const QByteArray &s) const;
    void push_back(const QString &s);
    void push_front(const QString &s);
    bool isNull() const;
    bool isSimpleText() const;
    bool isRightToLeft() const;
    int length() const;
    const QChar at(int i) const;
    QString operator[](int i) const;
%MethodCode
        // Note that we return a QString (rather than a QChar as Qt does).  This makes
        // things a bit easier in Python (because it doesn't distinguish between
        // characters and strings), although now that a QChar can be used whenever a
        // QString is expected it doesn't really matter.
        SIP_SSIZE_T idx = sipConvertFromSequenceIndex(a0, sipCpp->count());
        
        if (idx < 0)
            sipIsErr = 1;
        else
            sipRes = new QString(sipCpp->operator[]((int)idx));
%End

    QString operator[](SIP_PYSLICE slice) const;
%MethodCode
        SIP_SSIZE_T len, start, stop, step, slicelength, i;
        
        len = sipCpp->length();
        
        #if PY_VERSION_HEX >= 0x03020000
        if (PySlice_GetIndicesEx(a0, len, &start, &stop, &step, &slicelength) < 0)
        #else
        if (PySlice_GetIndicesEx((PySliceObject *)a0, len, &start, &stop, &step, &slicelength) < 0)
        #endif
            sipIsErr = 1;
        else
        {
            sipRes = new QString();
        
            for (i = 0; i < slicelength; ++i)
            {
                sipRes -> append(sipCpp->at(start));
                start += step;
            }
        }
%End

    int __contains__(const QString &s) const;
%MethodCode
        // It looks like you can't assign QBool to int.
        sipRes = bool(sipCpp->contains(*a0));
%End

    SIP_PYOBJECT __str__() const /DocType="str"/;
%MethodCode
        sipRes = qpycore_PyObject_FromQString(*sipCpp);
%End

    long __hash__() const;
%MethodCode
        sipRes = qHash(*sipCpp);
%End

    QString operator*(int m) const;
%MethodCode
        sipRes = new QString();
        
        while (a0-- > 0)
            *sipRes += *sipCpp;
%End

    QString &operator*=(int m);
%MethodCode
        QString orig(*sipCpp);
        
        sipCpp->clear();
        
        while (a0-- > 0)
            *sipCpp += orig;
%End

    bool isEmpty() const;
    void clear();
    int capacity() const;
    void reserve(int asize);
%If (Qt_4_3_0 -)
    QString toCaseFolded() const;
%End
%If (Qt_4_5_0 -)
    QString &replace(const QLatin1String &before, const QLatin1String &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
%End
%If (Qt_4_5_0 -)
    QString &replace(const QLatin1String &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
%End
%If (Qt_4_5_0 -)
    QString &replace(const QString &before, const QLatin1String &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
%End
%If (Qt_4_5_0 -)
    QString repeated(int times) const;
%End
%If (Qt_4_8_0 -)
    void swap(QString &other);
%End
%If (Qt_5_0_0 -)
    QString toHtmlEscaped() const;
%End
%If (Qt_5_0_0 -)
    static QString fromLatin1(const QByteArray &str);
%End
%If (Qt_5_0_0 -)
    static QString fromUtf8(const QByteArray &str);
%End
%If (Qt_5_0_0 -)
    static QString fromLocal8Bit(const QByteArray &str);
%End
};

class QLatin1String /API=QString: - 2/
{
%TypeHeaderCode
#include <qstring.h>
%End

%PickleCode
    sipRes = Py_BuildValue((char *)"(s)", sipCpp->latin1());
%End

public:
    explicit QLatin1String(const char *s /Encoding="Latin-1",KeepReference/);
    SIP_PYOBJECT __repr__() const /DocType="str"/;
%MethodCode
        PyObject *str = SIPBytes_FromString(sipCpp->latin1());
        
        if (str)
        {
        #if PY_MAJOR_VERSION >= 3
            sipRes = PyUnicode_FromFormat("PyQt4.QtCore.QLatin1String(%R)", str);
        #else
            sipRes = PyString_FromString("PyQt4.QtCore.QLatin1String(");
            PyString_ConcatAndDel(&sipRes, PyObject_Repr(str));
            PyString_ConcatAndDel(&sipRes, PyString_FromString(")"));
        #endif
        
            Py_DECREF(str);
        }
%End

    const char *latin1() const /Encoding="None"/;
    bool operator==(const QString &s) const;
    bool operator!=(const QString &s) const;
    bool operator>(const QString &s) const;
    bool operator<(const QString &s) const;
    bool operator>=(const QString &s) const;
    bool operator<=(const QString &s) const;
%If (Qt_5_0_0 -)
    int size() const;
%End
};

const QString operator+(const QString &s1, const QString &s2) /Numeric/;
const QString operator+(QChar s1, const QString &s2) /Numeric/;
const QString operator+(const QByteArray &ba, const QString &s) /Numeric/;
const QString operator+(const QString &s, const QByteArray &ba) /Numeric/;
QDataStream &operator<<(QDataStream &, const QString & /Constrained/) /API=QString: - 2/;
QDataStream &operator>>(QDataStream &, QString & /Constrained/) /API=QString: - 2/;
QFlags<QString::SectionFlag> operator|(QString::SectionFlag f1, QFlags<QString::SectionFlag> f2);
%If (Qt_5_0_0 -)
bool operator==(QLatin1String s1, QLatin1String s2);
%End
%If (Qt_4_3_0 - Qt_5_0_0)
bool operator==(const QLatin1String &s1, const QLatin1String &s2);
%End
%If (Qt_5_0_0 -)
bool operator!=(QLatin1String s1, QLatin1String s2);
%End
%If (Qt_4_3_0 - Qt_5_0_0)
bool operator!=(const QLatin1String &s1, const QLatin1String &s2);
%End
%If (Qt_5_0_0 -)
bool operator<(QLatin1String s1, QLatin1String s2);
%End
%If (Qt_4_3_0 - Qt_5_0_0)
bool operator<(const QLatin1String &s1, const QLatin1String &s2);
%End
%If (Qt_5_0_0 -)
bool operator<=(QLatin1String s1, QLatin1String s2);
%End
%If (Qt_4_3_0 - Qt_5_0_0)
bool operator<=(const QLatin1String &s1, const QLatin1String &s2);
%End
%If (Qt_5_0_0 -)
bool operator>(QLatin1String s1, QLatin1String s2);
%End
%If (Qt_4_3_0 - Qt_5_0_0)
bool operator>(const QLatin1String &s1, const QLatin1String &s2);
%End
%If (Qt_5_0_0 -)
bool operator>=(QLatin1String s1, QLatin1String s2);
%End
%If (Qt_4_3_0 - Qt_5_0_0)
bool operator>=(const QLatin1String &s1, const QLatin1String &s2);
%End
%If (Qt_4_3_0 -)
void qSwap(QString &value1, QString &value2) /API=QString: - 2/;
%End
%If (Qt_4_3_0 -)
// class QStringRef /API=QString:2 - /
%MappedType QStringRef /API=QString:2 - /
{
%TypeHeaderCode
#include <qstring.h>
%End

%ConvertToTypeCode
    // Qt only ever returns a QStringRef so this conversion isn't needed.
    return 0;
%End

%ConvertFromTypeCode
    return qpycore_PyObject_FromQString(sipCpp->toString());
%End
};
%End
%If (Qt_4_3_0 -)

class QStringRef /API=QString: - 2/
{
%TypeHeaderCode
#include <qstring.h>
%End

public:
    QStringRef();
    QStringRef(const QString *aString, int aPosition, int aSize);
    QStringRef(const QString *aString);
    QStringRef(const QStringRef &other);
    ~QStringRef();
    const QString *string() const;
    int position() const;
    int size() const;
    int count() const /__len__/;
    int length() const;
    const QChar *unicode() const;
    const QChar *data() const;
    const QChar *constData() const;
    void clear();
    QString toString() const;
    bool isEmpty() const;
    bool isNull() const;
    QStringRef appendTo(QString *string) const;
    const QChar at(int i) const;
%If (Qt_4_5_0 -)
    int compare(const QString &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_5_0 -)
    int compare(const QStringRef &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_5_0 -)
    int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_5_0 -)
    static int compare(const QStringRef &s1, const QString &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive);
%End
%If (Qt_4_5_0 -)
    static int compare(const QStringRef &s1, const QStringRef &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive);
%End
%If (Qt_4_5_0 -)
    static int compare(const QStringRef &s1, QLatin1String s2, Qt::CaseSensitivity cs = Qt::CaseSensitive);
%End
%If (Qt_4_5_0 -)
    int localeAwareCompare(const QString &s) const;
%End
%If (Qt_4_5_0 -)
    int localeAwareCompare(const QStringRef &s) const;
%End
%If (Qt_4_5_0 -)
    static int localeAwareCompare(const QStringRef &s1, const QString &s2);
%End
%If (Qt_4_5_0 -)
    static int localeAwareCompare(const QStringRef &s1, const QStringRef &s2);
%End
    SIP_PYOBJECT __str__() const /DocType="str"/;
%MethodCode
        sipRes = qpycore_PyObject_FromQString(sipCpp->toString());
%End

%If (Qt_4_8_0 -)
    int indexOf(const QString &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 -)
    int indexOf(QLatin1String str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 -)
    int indexOf(const QStringRef &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 -)
    int lastIndexOf(const QString &str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 -)
    int lastIndexOf(QLatin1String str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 -)
    int lastIndexOf(const QStringRef &str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 -)
    int count(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 -)
    int count(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 -)
    bool startsWith(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 -)
    bool startsWith(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 -)
    bool startsWith(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 -)
    bool endsWith(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 -)
    bool endsWith(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 -)
    bool endsWith(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 -)
%If (PyQt_Deprecated_5_0)
    QByteArray toAscii() const;
%End
%End
%If (Qt_4_8_0 -)
    QByteArray toLatin1() const;
%End
%If (Qt_4_8_0 -)
    QByteArray toUtf8() const;
%End
%If (Qt_4_8_0 -)
    QByteArray toLocal8Bit() const;
%End
%If (Qt_4_8_0 -)
    QVector<unsigned int> toUcs4() const;
%End
%If (Qt_5_0_0 -)
    bool contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 - Qt_5_0_0)
    QBool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_5_0_0 -)
    bool contains(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 - Qt_5_0_0)
    QBool contains(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_5_0_0 -)
    bool contains(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
%If (Qt_4_8_0 - Qt_5_0_0)
    QBool contains(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
%End
};

%End
%If (Qt_4_3_0 -)
bool operator==(const QStringRef &s1, const QStringRef &s2);
%End
%If (Qt_4_3_0 -)
bool operator!=(const QStringRef &s1, const QStringRef &s2);
%End
%If (Qt_4_3_0 -)
bool operator==(const QString &s1, const QStringRef &s2);
%End
%If (Qt_4_3_0 -)
bool operator!=(const QString &s1, const QStringRef &s2);
%End
%If (Qt_4_3_0 -)
bool operator==(const QStringRef &s1, const QString &s2);
%End
%If (Qt_4_3_0 -)
bool operator!=(const QStringRef &s1, const QString &s2);
%End
%If (Qt_5_0_0 -)
bool operator==(QLatin1String s1, const QStringRef &s2);
%End
%If (Qt_4_3_0 - Qt_5_0_0)
bool operator==(const QLatin1String &s1, const QStringRef &s2);
%End
%If (Qt_5_0_0 -)
bool operator!=(QLatin1String s1, const QStringRef &s2);
%End
%If (Qt_4_3_0 - Qt_5_0_0)
bool operator!=(const QLatin1String &s1, const QStringRef &s2);
%End
%If (Qt_5_0_0 -)
bool operator==(const QStringRef &s1, QLatin1String s2);
%End
%If (Qt_4_3_0 - Qt_5_0_0)
bool operator==(const QStringRef &s1, const QLatin1String &s2);
%End
%If (Qt_5_0_0 -)
bool operator!=(const QStringRef &s1, QLatin1String s2);
%End
%If (Qt_4_3_0 - Qt_5_0_0)
bool operator!=(const QStringRef &s1, const QLatin1String &s2);
%End
%If (Qt_4_3_0 -)
bool operator<(const QStringRef &s1, const QStringRef &s2);
%End
%If (Qt_4_3_0 -)
bool operator>(const QStringRef &s1, const QStringRef &s2);
%End
%If (Qt_4_3_0 -)
bool operator<=(const QStringRef &s1, const QStringRef &s2);
%End
%If (Qt_4_3_0 -)
bool operator>=(const QStringRef &s1, const QStringRef &s2);
%End