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
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
|
// This is the SIP interface definition for QChar and QString.
//
// Copyright (c) 2007
// Riverbank Computing Limited <info@riverbankcomputing.co.uk>
//
// This file is part of PyQt.
//
// This copy of PyQt 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, or (at your option) any later
// version.
//
// PyQt is supplied 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
// PyQt; see the file LICENSE. If not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
%ExportedDoc
<Sect2><Title>QChar (Qt v2+)</Title>
<FuncSynopsis>
<FuncDef>uchar &<Function>cell</Function> const</FuncDef>
<ParamDef></ParamDef>
</FuncSynopsis>
<Para>
Not implemented.
</Para>
<FuncSynopsis>
<FuncDef>uchar &<Function>row</Function> const</FuncDef>
<ParamDef></ParamDef>
</FuncSynopsis>
<Para>
Not implemented.
</Para>
</Sect2>
<Sect2><Title>QString</Title>
<Para>
A Python string object (or Unicode object) can be used whenever a
<Literal>QString</Literal> can be used. A <Literal>QString</Literal> can be
converted to a Python string object using the Python <Literal>str()</Literal>
function, and to a Python Unicode object using the Python
<Literal>unicode()</Literal> function.
</Para>
<Para>
The Python <Literal>+</Literal>, <Literal>+=</Literal>, <Literal>*</Literal>,
<Literal>*=</Literal>, <Literal>len</Literal>, <Literal>[]</Literal>
(for reading slices and individual characters), <Literal>in</Literal> and
comparison operators are supported.
</Para>
<FuncSynopsis>
<FuncDef>QCharRef <Function>at</Function></FuncDef>
<ParamDef>uint <Parameter>i</Parameter></ParamDef>
</FuncSynopsis>
<Para>
Not yet implemented. (Qt v2+)
</Para>
<FuncSynopsis>
<FuncDef>QChar <Function>constref</Function> const</FuncDef>
<ParamDef>uint <Parameter>i</Parameter></ParamDef>
</FuncSynopsis>
<Para>
Not yet implemented. (Qt v2+)
</Para>
<FuncSynopsis>
<FuncDef>QChar &<Function>ref</Function></FuncDef>
<ParamDef>uint <Parameter>i</Parameter></ParamDef>
</FuncSynopsis>
<Para>
Not yet implemented. (Qt v2+)
</Para>
<FuncSynopsis>
<FuncDef>QString &<Function>setUnicodeCodes</Function></FuncDef>
<ParamDef>const ushort *<Parameter>unicode_as_shorts</Parameter></ParamDef>
<ParamDef>uint <Parameter>len</Parameter></ParamDef>
</FuncSynopsis>
<Para>
Not yet implemented. (Qt v2.1+)
</Para>
<FuncSynopsis>
<FuncDef>QString &<Function>sprintf</Function></FuncDef>
<ParamDef>const char *<Parameter>format</Parameter></ParamDef>
<ParamDef>...</ParamDef>
</FuncSynopsis>
<Para>
Not implemented.
</Para>
<FuncSynopsis>
<FuncDef>short <Function>toShort</Function></FuncDef>
<ParamDef>bool *<Parameter>ok</Parameter> = 0</ParamDef>
</FuncSynopsis>
<Para>
This returns a tuple of the <Literal>short</Literal> result and the
<Literal>ok</Literal> value.
</Para>
<FuncSynopsis>
<FuncDef>ushort <Function>toUShort</Function></FuncDef>
<ParamDef>bool *<Parameter>ok</Parameter> = 0</ParamDef>
</FuncSynopsis>
<Para>
This returns a tuple of the <Literal>ushort</Literal> result and the
<Literal>ok</Literal> value.
</Para>
<FuncSynopsis>
<FuncDef>int <Function>toInt</Function></FuncDef>
<ParamDef>bool *<Parameter>ok</Parameter> = 0</ParamDef>
</FuncSynopsis>
<Para>
This returns a tuple of the <Literal>int</Literal> result and the
<Literal>ok</Literal> value.
</Para>
<FuncSynopsis>
<FuncDef>uint <Function>toUInt</Function></FuncDef>
<ParamDef>bool *<Parameter>ok</Parameter> = 0</ParamDef>
</FuncSynopsis>
<Para>
This returns a tuple of the <Literal>uint</Literal> result and the
<Literal>ok</Literal> value.
</Para>
<FuncSynopsis>
<FuncDef>long <Function>toLong</Function></FuncDef>
<ParamDef>bool *<Parameter>ok</Parameter> = 0</ParamDef>
</FuncSynopsis>
<Para>
This returns a tuple of the <Literal>long</Literal> result and the
<Literal>ok</Literal> value.
</Para>
<FuncSynopsis>
<FuncDef>ulong <Function>toULong</Function></FuncDef>
<ParamDef>bool *<Parameter>ok</Parameter> = 0</ParamDef>
</FuncSynopsis>
<Para>
This returns a tuple of the <Literal>ulong</Literal> result and the
<Literal>ok</Literal> value.
</Para>
<FuncSynopsis>
<FuncDef>float <Function>toFloat</Function></FuncDef>
<ParamDef>bool *<Parameter>ok</Parameter> = 0</ParamDef>
</FuncSynopsis>
<Para>
This returns a tuple of the <Literal>float</Literal> result and the
<Literal>ok</Literal> value.
</Para>
<FuncSynopsis>
<FuncDef>double <Function>toDouble</Function></FuncDef>
<ParamDef>bool *<Parameter>ok</Parameter> = 0</ParamDef>
</FuncSynopsis>
<Para>
This returns a tuple of the <Literal>double</Literal> result and the
<Literal>ok</Literal> value.
</Para>
</Sect2>
%End
%If (Qt_2_00 -)
class QChar
{
%TypeHeaderCode
#include <qstring.h>
%End
public:
QChar();
QChar(char);
// QChar(uchar);
QChar(uchar,uchar);
QChar(const QChar &);
// QChar(ushort);
// QChar(short);
// QChar(uint);
QChar(int);
static const QChar null;
static const QChar replacement;
static const QChar byteOrderMark;
static const QChar byteOrderSwapped;
%If (Qt_2_2_0 -)
static const QChar nbsp;
%End
%If (- Qt_3_0_0)
enum Category {
NoCategory,
Mark_NonSpacing,
Mark_SpacingCombining,
Mark_Enclosing,
Number_DecimalDigit,
Number_Letter,
Number_Other,
Separator_Space,
Separator_Line,
Separator_Paragraph,
Other_Control,
Other_Format,
Other_Surrogate,
Other_PrivateUse,
Other_NotAssigned,
Letter_Uppercase,
Letter_Lowercase,
Letter_Titlecase,
Letter_Modifier,
Letter_Other,
Punctuation_Connector,
Punctuation_Dask,
Punctuation_Open,
Punctuation_Close,
Punctuation_InitialQuote,
Punctuation_FinalQuote,
Punctuation_Other,
Symbol_Math,
Symbol_Currency,
Symbol_Modifier,
Symbol_Other
};
%End
%If (Qt_3_0_0 -)
enum Category {
NoCategory,
Mark_NonSpacing,
Mark_SpacingCombining,
Mark_Enclosing,
Number_DecimalDigit,
Number_Letter,
Number_Other,
Separator_Space,
Separator_Line,
Separator_Paragraph,
Other_Control,
Other_Format,
Other_Surrogate,
Other_PrivateUse,
Other_NotAssigned,
Letter_Uppercase,
Letter_Lowercase,
Letter_Titlecase,
Letter_Modifier,
Letter_Other,
Punctuation_Connector,
Punctuation_Dash,
Punctuation_Open,
Punctuation_Close,
Punctuation_InitialQuote,
Punctuation_FinalQuote,
Punctuation_Other,
Symbol_Math,
Symbol_Currency,
Symbol_Modifier,
Symbol_Other
};
%End
%If (- Qt_3_0_0)
enum Direction {
DirL,
DirR,
DirEN,
DirES,
DirET,
DirAN,
DirCS,
DirB,
DirS,
DirWS,
DirON
};
%End
%If (Qt_3_0_0 -)
enum Direction {
DirL,
DirR,
DirEN,
DirES,
DirET,
DirAN,
DirCS,
DirB,
DirS,
DirWS,
DirON,
DirLRE,
DirLRO,
DirAL,
DirRLE,
DirRLO,
DirPDF,
DirNSM,
DirBN
};
%End
enum Decomposition {
Single,
Canonical,
Font,
NoBreak,
Initial,
Medial,
Final,
Isolated,
Circle,
Super,
Sub,
Vertical,
Wide,
Narrow,
Small,
Square,
Compat,
Fraction
};
enum Joining {
OtherJoining,
Dual,
Right,
Center
};
%If (Qt_3_0_0 -)
enum CombiningClass {
Combining_BelowLeftAttached,
Combining_BelowAttached,
Combining_BelowRightAttached,
Combining_LeftAttached,
Combining_RightAttached,
Combining_AboveLeftAttached,
Combining_AboveAttached,
Combining_AboveRightAttached,
Combining_BelowLeft,
Combining_Below,
Combining_BelowRight,
Combining_Left,
Combining_Right,
Combining_AboveLeft,
Combining_Above,
Combining_AboveRight,
Combining_DoubleBelow,
Combining_DoubleAbove,
Combining_IotaSubscript
};
%End
int digitValue() const;
QChar lower() const;
QChar upper() const;
Category category() const;
Direction direction() const;
Joining joining() const;
bool mirrored() const;
%If (Qt_2_1_0 -)
QChar mirroredChar() const;
%End
%If (- Qt_3_0_0)
QString decomposition() const;
%End
%If (Qt_3_0_0 -)
const QString &decomposition() const;
%End
Decomposition decompositionTag() const;
%If (Qt_3_0_0 -)
unsigned char combiningClass() const;
%End
char latin1() const;
ushort unicode() const;
bool isNull() const;
bool isPrint() const;
bool isPunct() const;
bool isSpace() const;
bool isMark() const;
bool isLetter() const;
bool isNumber() const;
%If (Qt_2_1_0 -)
bool isLetterOrNumber() const;
%End
bool isDigit() const;
%If (Qt_3_0_0 -)
bool isSymbol() const;
%End
// uchar& cell();
// uchar& row();
uchar cell() const;
uchar row() const;
%If (Qt_3_0_0 -)
void setCell(uchar);
void setRow(uchar);
%End
static bool networkOrdered();
bool operator==(char);
bool operator==(QChar);
bool operator!=(QChar);
bool operator!=(char);
bool operator<=(char);
bool operator<=(QChar);
bool operator>=(char);
bool operator>=(QChar);
bool operator<(char);
bool operator<(QChar);
bool operator>(char);
bool operator>(QChar);
};
class QString
{
%TypeHeaderCode
#include <qstring.h>
%End
public:
QString();
QString(QChar);
QString(const QString &);
QString(const QByteArray &);
// QString(const QChar *,uint);
// QString(const char *);
%If (Qt_2_1_0 -)
// This is how we implement QUrl::operator QString() const.
QString(const QUrl &);
%End
%If (Qt_3_0_0 -)
// This is how we implement QKeySequence::operator QString() const.
QString(const QKeySequence &);
// This is how we implement QUuid::operator QString() const.
QString(const QUuid &);
%End
static const QString null;
bool isNull() const;
bool isEmpty() const;
uint length() const;
void truncate(uint);
%If (- Qt_3_0_0)
void fill(QChar,int = -1);
%End
%If (Qt_3_0_0 -)
QString &fill(QChar,int = -1);
%End
QString copy() const;
QString arg(int /Constrained/,int = 0,int = 10) const;
QString arg(double /Constrained/,int = 0,char = 'g',int = -1) const;
%If (Qt_3_2_0 -)
// QString arg(Q_LLONG,int = 0,int = 10) const;
// QString arg(Q_ULLONG,int = 0,int = 10) const;
%End
QString arg(long,int = 0,int = 10) const;
QString arg(ulong,int = 0,int = 10) const;
// QString arg(uint,int = 0,int = 10) const;
// QString arg(short,int = 0,int = 10) const;
// QString arg(ushort,int = 0,int = 10) const;
QString arg(char,int = 0) const;
QString arg(QChar,int = 0) const;
QString arg(const QString&,int = 0) const;
%If (Qt_3_2_0 -)
QString arg(const QString &,const QString &) const;
QString arg(const QString &,const QString &,const QString &) const;
QString arg(const QString &,const QString &,const QString &,
const QString &) const;
%End
// QString &sprintf(const char *,...);
int find(QChar,int = 0,bool = 1) const;
int find(char,int = 0,bool = 1) const;
int find(const QString &,int = 0,bool = 1) const;
int find(const QRegExp &,int = 0) const;
// int find(const char *,int = 0) const;
int findRev(QChar,int = -1,bool = 1) const;
int findRev(char,int = -1,bool = 1) const;
int findRev(const QString &,int = -1,bool = 1) const;
int findRev(const QRegExp &,int = -1) const;
// int findRev(const char *,int = -1) const;
int contains(QChar,bool = 1) const;
int contains(char,bool = 1) const;
// int contains(const char *,bool = 1) const;
int contains(const QString &,bool = 1) const;
int contains(const QRegExp &) const;
%If (Qt_3_0_0 -)
enum SectionFlags {
SectionDefault,
SectionSkipEmpty,
SectionIncludeLeadingSep,
SectionIncludeTrailingSep,
SectionCaseInsensitiveSeps
};
QString section(QChar,int,int = 0xffffffff,int = SectionDefault) const;
// QString section(char,int,int = 0xffffffff,int = SectionDefault) const;
// QString section(const char *,int,int = 0xffffffff,
// int = SectionDefault) const;
QString section(const QString &,int,int = 0xffffffff,
int = SectionDefault) const;
QString section(const QRegExp &,int,int = 0xffffffff,
int = SectionDefault) const;
%End
QString left(uint) const;
QString right(uint) const;
QString mid(uint,uint = 0xffffffff) const;
QString leftJustify(uint,QChar = ' ',bool = 0) const;
QString rightJustify(uint,QChar = ' ',bool = 0) const;
QString lower() const;
QString upper() const;
QString stripWhiteSpace() const;
QString simplifyWhiteSpace() const;
QString &insert(uint,const QString &);
%If (Qt_3_2_0 -)
QString &insert(uint,const QByteArray &);
// QString &insert(uint,const char *);
%End
QString &insert(uint,QChar *,uint);
QString &insert(uint,QChar);
QString &insert(uint,char);
QString &append(char);
%If (Qt_2_2_0 -)
QString &append(QChar);
%End
QString &append(const QString &);
QString &prepend(char);
%If (Qt_2_2_0 -)
QString &prepend(QChar);
%End
QString &prepend(const QString &);
QString &remove(uint,uint);
%If (Qt_3_1_0 -)
QString &remove(const QString &);
%If (Qt_3_2_0 -)
QString &remove(const QString &,bool);
%End
QString &remove(QChar);
QString &remove(char);
QString &remove(const QRegExp &);
%End
QString &replace(uint,uint,const QString &);
QString &replace(uint,uint,const QChar *,uint);
%If (Qt_3_1_0 -)
QString &replace(uint,uint,QChar);
QString &replace(uint,uint,char);
QString &replace(QChar,const QString &);
%If (Qt_3_2_0 -)
QString &replace(QChar,const QString &,bool);
%End
QString &replace(char,const QString &);
%If (Qt_3_2_0 -)
QString &replace(char,const QString &,bool);
%End
QString &replace(const QString &,const QString &);
%If (Qt_3_2_0 -)
QString &replace(const QString &,const QString &,bool);
%End
%End
QString &replace(const QRegExp &,const QString &);
%If (Qt_3_1_0 -)
QString &replace(QChar,QChar);
%End
short toShort(bool * = 0,int = 10) const;
ushort toUShort(bool * = 0,int = 10) const;
int toInt(bool * = 0,int = 10) const;
uint toUInt(bool * = 0,int = 10) const;
long toLong(bool * = 0,int = 10) const;
ulong toULong(bool * = 0,int = 10) const;
%If (Qt_3_2_0 -)
// Q_LLONG toLongLong(bool * = 0,int = 10) const;
// Q_ULLONG toULongLong(bool * = 0,int = 10) const;
%End
float toFloat(bool * = 0) const;
double toDouble(bool * = 0) const;
QString &setNum(int /Constrained/,int = 10);
QString &setNum(double /Constrained/,char = 'g',int = 6);
// QString &setNum(short,int = 10);
// QString &setNum(ushort,int = 10);
// QString &setNum(uint,int = 10);
QString &setNum(long,int = 10);
QString &setNum(ulong,int = 10);
%If (Qt_3_2_0 -)
// QString &setNum(Q_LLONG,int = 10);
// QString &setNum(Q_ULLONG,int = 10);
%End
// QString &setNum(float,char = 'g',int = 6);
static QString number(int /Constrained/,int = 10);
static QString number(double /Constrained/,char = 'g',int = 6);
static QString number(long,int = 10);
static QString number(ulong,int = 10);
%If (Qt_3_2_0 -)
// static QString number(Q_LLONG,int = 10);
// static QString number(Q_ULLONG,int = 10);
%End
// static QString number(uint,int = 10);
void setExpand(uint,QChar);
QString &operator+=(const QString &);
%If (Qt_3_3_0 -)
QString &operator+=(const QByteArray &);
%End
QString &operator+=(QChar);
//QString &operator+=(char);
QString operator*(int);
%MethodCode
sipRes = new QString();
while (a0-- > 0)
*sipRes += *sipCpp;
%End
QString &operator*=(int);
%MethodCode
QString orig(*sipCpp);
sipCpp -> truncate(0);
while (a0-- > 0)
*sipCpp += orig;
%End
QChar at(uint) const;
// QCharRef at(uint);
// QChar constref(uint) const;
// QChar &ref(uint);
// const QChar *unicode() const;
const char *ascii() const;
%If (Qt_3_1_0 -)
static QString fromAscii(const char *,int = -1);
%End
const char *latin1() const;
static QString fromLatin1(const char *,int = -1);
QCString utf8() const;
static QString fromUtf8(const char *,int = -1);
QCString local8Bit() const;
static QString fromLocal8Bit(const char *,int = -1);
%If (Qt_3_1_0 -)
// static QString fromUcs2(const unsigned short *);
// const unsigned short *ucs2() const;
%End
%If (Qt_2_1_0 -)
// QString &setUnicode(const QChar *,uint);
// QString &setUnicodeCodes(const ushort *,uint);
%End
%If (Qt_3_1_0 -)
QString &setAscii(const char *,int = -1);
%End
%If (Qt_2_1_0 -)
QString &setLatin1(const char *,int = -1);
%End
int compare(const QString &) const;
static int compare(const QString &,const QString &);
%If (Qt_3_0_0 -)
int localeAwareCompare(const QString &) const;
static int localeAwareCompare(const QString &,const QString &);
%End
void compose();
%If (- Qt_3_0_0)
QChar::Direction basicDirection();
QString visual(int = 0,int = -1);
%End
%If (Qt_2_2_0 -)
bool startsWith(const QString &) const;
%End
%If (Qt_3_2_0 -)
bool startsWith(const QString &,bool) const;
%End
%If (Qt_3_0_0 -)
bool endsWith(const QString &) const;
%End
%If (Qt_3_2_0 -)
bool endsWith(const QString &,bool) const;
%End
%If (Qt_3_0_0 -)
void setLength(uint);
%End
%If (Qt_3_2_0 -)
uint capacity() const;
void reserve(uint);
void squeeze();
%End
%If (Qt_3_0_0 -)
bool simpleText() const;
bool isRightToLeft() const;
%End
bool operator==(const QString &) const;
bool operator!=(const QString &) const;
bool operator<(const QString &) const;
bool operator<=(const QString &) const;
bool operator>(const QString &) const;
bool operator>=(const QString &) const;
// Force the numeric interpretation so that str + QString gets handled
// as we want.
const QString operator+(const QString &) /Numeric/;
QString operator[](int) const;
%MethodCode
int len;
len = sipCpp -> length();
if ((a0 = (int)sipConvertFromSequenceIndex(a0,len)) < 0)
sipIsErr = 1;
else
sipRes = new QString(sipCpp -> at(a0));
%End
QString operator[](SIP_PYSLICE) const;
%MethodCode
#if PY_VERSION_HEX >= 0x02050000
Py_ssize_t len, start, stop, step, slicelength, i;
#else
int len, start, stop, step, slicelength, i;
#endif
len = sipCpp -> length();
if (sipConvertFromSliceObject(a0,len,&start,&stop,&step,&slicelength) < 0)
sipIsErr = 1;
else
{
sipRes = new QString();
for (i = 0; i < slicelength; ++i)
{
sipRes -> append(sipCpp -> at(start));
start += step;
}
}
%End
int __len__() const;
%MethodCode
sipRes = sipCpp -> length();
%End
int __contains__(const QString &) const;
%MethodCode
sipRes = (sipCpp -> contains(*a0) > 0);
%End
SIP_PYOBJECT __unicode__();
%MethodCode
#if PY_VERSION_HEX >= 0x01060000
sipRes = QStringToPyUnicode(sipCpp);
#else
Py_INCREF(Py_None);
sipRes = Py_None;
#endif
%End
SIP_PYOBJECT __str__();
%MethodCode
#if PY_VERSION_HEX >= 0x01060000
sipRes = QStringToPyUnicode(sipCpp);
#else
const char *s;
Py_BEGIN_ALLOW_THREADS
s = *sipCpp;
Py_END_ALLOW_THREADS
if (s == NULL)
s = "";
sipRes = PyString_FromString(s);
#endif
%End
%TypeCode
#include <qtextcodec.h>
#if PY_VERSION_HEX >= 0x01060000
// Convenience function for converting a QString to a Python Unicode object.
static PyObject *QStringToPyUnicode(QString *qs)
{
PyObject *uobj;
if ((uobj = PyUnicode_FromUnicode(NULL,qs -> length())) == NULL)
return NULL;
Py_UNICODE *pyu = PyUnicode_AS_UNICODE(uobj);
for (uint i = 0; i < qs -> length(); ++i)
*pyu++ = (qs -> at(i)).unicode();
return uobj;
}
#endif
// Convenience function for converting a Python unicode or string object to a
// QString on the heap.
static QString *PyUnicodeStringToQString(PyObject *py)
{
#if PY_VERSION_HEX >= 0x01060000
if (PyUnicode_Check(py))
{
QString *qs = new QString;
#if defined(Py_UNICODE_WIDE)
PY_UNICODE_TYPE *ucode = PyUnicode_AS_UNICODE(py);
int len = PyUnicode_GET_SIZE(py);
for (int i = 0; i < len; ++i)
qs->ref(i) = (uint)ucode[i];
#else
qs -> setUnicodeCodes((ushort *)PyUnicode_AS_UNICODE(py),PyUnicode_GET_SIZE(py));
#endif
return qs;
}
#endif
if (PyString_Check(py))
return new QString(PyString_AS_STRING(py));
return 0;
}
%End
%ConvertToTypeCode
// Allow a Python string (or a unicode string) whenever a QString is
// expected.
if (sipIsErr == NULL)
return (PyString_Check(sipPy) ||
#if PY_VERSION_HEX >= 0x01060000
PyUnicode_Check(sipPy) ||
#endif
sipCanConvertToInstance(sipPy,sipClass_QString,SIP_NO_CONVERTORS));
*sipCppPtr = PyUnicodeStringToQString(sipPy);
if (*sipCppPtr)
return sipGetState(sipTransferObj);
*sipCppPtr = reinterpret_cast<QString *>(sipConvertToInstance(sipPy,sipClass_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
{
*sipPtrPtr = (void *)sipCpp->ucs2();
sipRes = sipCpp->length() * sizeof (ushort);
}
%End
%BIGetSegCountCode
if (sipLenPtr)
*sipLenPtr = sipCpp->length() * sizeof (ushort);
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;
}
if (codec)
{
// A Python string is the most convenient method to
// save the encoded version on the heap.
PyObject *encobj = ((sipWrapper *)sipSelf)->user;
QCString enc;
Py_XDECREF(encobj);
enc = codec->fromUnicode(*sipCpp);
if ((encobj = PyString_FromString(enc.data())) != NULL)
{
*sipPtrPtr = (void *)PyString_AS_STRING(encobj);
sipRes = PyString_GET_SIZE(encobj);
((sipWrapper *)sipSelf)->user = encobj;
}
else
sipRes = -1;
}
else
{
const char *asc = sipCpp->ascii();
*sipPtrPtr = (void *)asc;
sipRes = qstrlen(asc);
}
}
%End
};
%End
%If (- Qt_2_00)
class QString : QByteArray
{
%TypeHeaderCode
#include <qstring.h>
%End
public:
QString();
QString(int);
QString(const QString &);
QString(const char *);
QString(const char *,uint);
bool isNull() const;
bool isEmpty() const;
uint length() const;
bool resize(uint);
bool truncate(uint);
bool fill(char,int = -1);
QString copy() const;
// QString &sprintf(const char *,...);
int find(char,int = 0,bool = 1) const;
int find(const char *,int = 0,bool = 1) const;
int find(const QRegExp &,int = 0) const;
int findRev(char,int = -1,bool = 1) const;
int findRev(const char *,int = -1,bool = 1) const;
int findRev(const QRegExp &,int = -1) const;
int contains(char,bool = 1) const;
int contains(const char *,bool = 1) const;
int contains(const QRegExp &) const;
QString left(uint) const;
QString right(uint) const;
QString mid(uint,uint) const;
QString leftJustify(uint,char = ' ',bool = 0) const;
QString rightJustify(uint,char = ' ',bool = 0) const;
QString lower() const;
QString upper() const;
QString stripWhiteSpace() const;
QString simplifyWhiteSpace() const;
QString &insert(uint,const char *);
QString &insert(uint,char);
QString &append(const char *);
QString &prepend(const char *);
QString &remove(uint,uint);
QString &replace(uint,uint,const char *);
QString &replace(const QRegExp &,const char *);
short toShort(bool * = 0) const;
ushort toUShort(bool * = 0) const;
int toInt(bool * = 0) const;
uint toUInt(bool * = 0) const;
long toLong(bool * = 0) const;
ulong toULong(bool * = 0) const;
float toFloat(bool * = 0) const;
double toDouble(bool * = 0) const;
QString &setStr(const char *);
// QString &setNum(short);
// QString &setNum(ushort);
QString &setNum(int /Constrained/);
// QString &setNum(uint);
// QString &setNum(long);
// QString &setNum(ulong);
// QString &setNum(float,char = 'g',int = 6);
QString &setNum(double,char = 'g',int = 6);
bool setExpand(uint,char);
SIP_PYOBJECT __str__();
%MethodCode
const char *s;
Py_BEGIN_ALLOW_THREADS
s = *sipCpp;
Py_END_ALLOW_THREADS
if (s == NULL)
s = "";
sipRes = PyString_FromString(s);
%End
%ConvertToTypeCode
// Allow a Python string whenever a QString is expected.
if (sipIsErr == NULL)
return (PyString_Check(sipPy) ||
sipCanConvertToInstance(sipPy,sipClass_QString,SIP_NO_CONVERTORS));
if (PyString_Check(sipPy))
{
*sipCppPtr = new QString(PyString_AS_STRING(sipPy));
return sipGetState(sipTransferObj);
}
*sipCppPtr = reinterpret_cast<QString *>(sipConvertToInstance(sipPy,sipClass_QString,sipTransferObj,SIP_NO_CONVERTORS,0,sipIsErr));
return 0;
%End
};
%End
|