source: trunk/doc/html/qstring-h.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 39.4 KB
RevLine 
[190]1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/include/qstring.h:1 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>qstring.h Include File</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>qstring.h</h1>
33
34<p>This is the verbatim text of the qstring.h include file. It is provided only for illustration; the copyright remains with Trolltech.
35<hr>
36<pre>
37/****************************************************************************
38** $Id: qstring-h.html 2051 2007-02-21 10:04:20Z chehrlic $
39**
40** Definition of the QString class, and related Unicode functions.
41**
42** Created : 920609
43**
44** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
45**
46** This file is part of the tools module of the Qt GUI Toolkit.
47**
48** This file may be distributed under the terms of the Q Public License
49** as defined by Trolltech ASA of Norway and appearing in the file
50** LICENSE.QPL included in the packaging of this file.
51**
52** This file may be distributed and/or modified under the terms of the
53** GNU General Public License version 2 as published by the Free Software
54** Foundation and appearing in the file LICENSE.GPL included in the
55** packaging of this file.
56**
57** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
58** licenses may use this file in accordance with the Qt Commercial License
59** Agreement provided with the Software.
60**
61** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
62** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
63**
64** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
65** information about Qt Commercial License Agreements.
66** See http://www.trolltech.com/qpl/ for QPL licensing information.
67** See http://www.trolltech.com/gpl/ for GPL licensing information.
68**
69** Contact info@trolltech.com if any conditions of this licensing are
70** not clear to you.
71**
72**********************************************************************/
73
74#ifndef QSTRING_H
75#define QSTRING_H
76
77#ifndef QT_H
78#include "qcstring.h"
79#endif // QT_H
80
81#ifndef QT_NO_CAST_ASCII
82#include &lt;limits.h&gt;
83#endif
84
85#ifndef QT_NO_STL
86#if defined ( Q_CC_MSVC_NET ) &amp;&amp; _MSC_VER &lt; 1310 // Avoids nasty warning for xlocale, line 450
87# pragma warning ( push )
88# pragma warning ( disable : 4189 )
89# include &lt;string&gt;
90# pragma warning ( pop )
91#else
92# include &lt;string&gt;
93#endif
94#if defined(Q_WRONG_SB_CTYPE_MACROS) &amp;&amp; defined(_SB_CTYPE_MACROS)
95#undef _SB_CTYPE_MACROS
96#endif
97#endif
98
99
100/*****************************************************************************
101 QString class
102 *****************************************************************************/
103
104class QRegExp;
105class QString;
106class QCharRef;
107template &lt;class T&gt; class QDeepCopy;
108
109class Q_EXPORT QChar {
110public:
111 QChar();
112 QChar( char c );
113 QChar( uchar c );
114 QChar( uchar c, uchar r );
115 QChar( const QChar&amp; c ); // ### remove in 4.0 to allow compiler optimization
116 QChar( ushort rc );
117 QChar( short rc );
118 QChar( uint rc );
119 QChar( int rc );
120
121 QT_STATIC_CONST QChar null; // 0000
122 QT_STATIC_CONST QChar replacement; // FFFD
123 QT_STATIC_CONST QChar byteOrderMark; // FEFF
124 QT_STATIC_CONST QChar byteOrderSwapped; // FFFE
125 QT_STATIC_CONST QChar nbsp; // 00A0
126
127 // Unicode information
128
129 enum Category
130 {
131 NoCategory,
132
133 Mark_NonSpacing, // Mn
134 Mark_SpacingCombining, // Mc
135 Mark_Enclosing, // Me
136
137 Number_DecimalDigit, // Nd
138 Number_Letter, // Nl
139 Number_Other, // No
140
141 Separator_Space, // Zs
142 Separator_Line, // Zl
143 Separator_Paragraph, // Zp
144
145 Other_Control, // Cc
146 Other_Format, // Cf
147 Other_Surrogate, // Cs
148 Other_PrivateUse, // Co
149 Other_NotAssigned, // Cn
150
151 Letter_Uppercase, // Lu
152 Letter_Lowercase, // Ll
153 Letter_Titlecase, // Lt
154 Letter_Modifier, // Lm
155 Letter_Other, // Lo
156
157 Punctuation_Connector, // Pc
158 Punctuation_Dash, // Pd
159 Punctuation_Dask = Punctuation_Dash, // oops
160 Punctuation_Open, // Ps
161 Punctuation_Close, // Pe
162 Punctuation_InitialQuote, // Pi
163 Punctuation_FinalQuote, // Pf
164 Punctuation_Other, // Po
165
166 Symbol_Math, // Sm
167 Symbol_Currency, // Sc
168 Symbol_Modifier, // Sk
169 Symbol_Other // So
170 };
171
172 enum Direction
173 {
174 DirL, DirR, DirEN, DirES, DirET, DirAN, DirCS, DirB, DirS, DirWS, DirON,
175 DirLRE, DirLRO, DirAL, DirRLE, DirRLO, DirPDF, DirNSM, DirBN
176 };
177
178 enum Decomposition
179 {
180 Single, Canonical, Font, NoBreak, Initial, Medial,
181 Final, Isolated, Circle, Super, Sub, Vertical,
182 Wide, Narrow, Small, Square, Compat, Fraction
183 };
184
185 enum Joining
186 {
187 OtherJoining, Dual, Right, Center
188 };
189
190 enum CombiningClass
191 {
192 Combining_BelowLeftAttached = 200,
193 Combining_BelowAttached = 202,
194 Combining_BelowRightAttached = 204,
195 Combining_LeftAttached = 208,
196 Combining_RightAttached = 210,
197 Combining_AboveLeftAttached = 212,
198 Combining_AboveAttached = 214,
199 Combining_AboveRightAttached = 216,
200
201 Combining_BelowLeft = 218,
202 Combining_Below = 220,
203 Combining_BelowRight = 222,
204 Combining_Left = 224,
205 Combining_Right = 226,
206 Combining_AboveLeft = 228,
207 Combining_Above = 230,
208 Combining_AboveRight = 232,
209
210 Combining_DoubleBelow = 233,
211 Combining_DoubleAbove = 234,
212 Combining_IotaSubscript = 240
213 };
214
215 // ****** WHEN ADDING FUNCTIONS, CONSIDER ADDING TO QCharRef TOO
216
217 int digitValue() const;
218 QChar lower() const;
219 QChar upper() const;
220
221 Category category() const;
222 Direction direction() const;
223 Joining joining() const;
224 bool mirrored() const;
225 QChar mirroredChar() const;
226 const QString &amp;decomposition() const; // ### return just QString in 4.0
227 Decomposition decompositionTag() const;
228 unsigned char combiningClass() const;
229
230 char latin1() const { return ucs &gt; 0xff ? 0 : (char) ucs; }
231 ushort unicode() const { return ucs; }
232#ifdef Q_NO_PACKED_REFERENCE
233 ushort &amp;unicode() { return *(&amp;ucs); }
234#else
235 ushort &amp;unicode() { return ucs; }
236#endif
237#ifndef QT_NO_CAST_ASCII
238 // like all ifdef'd code this is undocumented
239 operator char() const { return latin1(); }
240#endif
241
242 bool isNull() const { return unicode()==0; }
243 bool isPrint() const;
244 bool isPunct() const;
245 bool isSpace() const;
246 bool isMark() const;
247 bool isLetter() const;
248 bool isNumber() const;
249 bool isLetterOrNumber() const;
250 bool isDigit() const;
251 bool isSymbol() const;
252
253 uchar cell() const { return ((uchar) ucs &amp; 0xff); }
254 uchar row() const { return ((uchar) (ucs&gt;&gt;8)&amp;0xff); }
255 void setCell( uchar cell ) { ucs = (ucs &amp; 0xff00) + cell; }
256 void setRow( uchar row ) { ucs = (((ushort) row)&lt;&lt;8) + (ucs&amp;0xff); }
257
258 static bool networkOrdered() {
259 int wordSize;
260 bool bigEndian = FALSE;
261 qSysInfo( &amp;wordSize, &amp;bigEndian );
262 return bigEndian;
263 }
264
265 friend inline bool operator==( char ch, QChar c );
266 friend inline bool operator==( QChar c, char ch );
267 friend inline bool operator==( QChar c1, QChar c2 );
268 friend inline bool operator!=( QChar c1, QChar c2 );
269 friend inline bool operator!=( char ch, QChar c );
270 friend inline bool operator!=( QChar c, char ch );
271 friend inline bool operator&lt;=( QChar c, char ch );
272 friend inline bool operator&lt;=( char ch, QChar c );
273 friend inline bool operator&lt;=( QChar c1, QChar c2 );
274
275private:
276 ushort ucs;
277#if defined(QT_QSTRING_UCS_4)
278 ushort grp;
279#endif
280} Q_PACKED;
281
282inline QChar::QChar() : ucs( 0 )
283#ifdef QT_QSTRING_UCS_4
284 , grp( 0 )
285#endif
286{
287}
288inline QChar::QChar( char c ) : ucs( (uchar)c )
289#ifdef QT_QSTRING_UCS_4
290 , grp( 0 )
291#endif
292{
293}
294inline QChar::QChar( uchar c ) : ucs( c )
295#ifdef QT_QSTRING_UCS_4
296 , grp( 0 )
297#endif
298{
299}
300inline QChar::QChar( uchar c, uchar r ) : ucs( (r &lt;&lt; 8) | c )
301#ifdef QT_QSTRING_UCS_4
302 , grp( 0 )
303#endif
304{
305}
306inline QChar::QChar( const QChar&amp; c ) : ucs( c.ucs )
307#ifdef QT_QSTRING_UCS_4
308 , grp( c.grp )
309#endif
310{
311}
312
313inline QChar::QChar( ushort rc ) : ucs( rc )
314#ifdef QT_QSTRING_UCS_4
315 , grp( 0 )
316#endif
317{
318}
319inline QChar::QChar( short rc ) : ucs( (ushort) rc )
320#ifdef QT_QSTRING_UCS_4
321 , grp( 0 )
322#endif
323{
324}
325inline QChar::QChar( uint rc ) : ucs( (ushort ) (rc &amp; 0xffff) )
326#ifdef QT_QSTRING_UCS_4
327 , grp( (ushort) ((rc &gt;&gt; 16) &amp; 0xffff) )
328#endif
329{
330}
331inline QChar::QChar( int rc ) : ucs( (ushort) (rc &amp; 0xffff) )
332#ifdef QT_QSTRING_UCS_4
333 , grp( (ushort) ((rc &gt;&gt; 16) &amp; 0xffff) )
334#endif
335{
336}
337
338inline bool operator==( char ch, QChar c )
339{
340 return ((uchar) ch) == c.ucs;
341}
342
343inline bool operator==( QChar c, char ch )
344{
345 return ((uchar) ch) == c.ucs;
346}
347
348inline bool operator==( QChar c1, QChar c2 )
349{
350 return c1.ucs == c2.ucs;
351}
352
353inline bool operator!=( QChar c1, QChar c2 )
354{
355 return c1.ucs != c2.ucs;
356}
357
358inline bool operator!=( char ch, QChar c )
359{
360 return ((uchar)ch) != c.ucs;
361}
362
363inline bool operator!=( QChar c, char ch )
364{
365 return ((uchar) ch) != c.ucs;
366}
367
368inline bool operator&lt;=( QChar c, char ch )
369{
370 return c.ucs &lt;= ((uchar) ch);
371}
372
373inline bool operator&lt;=( char ch, QChar c )
374{
375 return ((uchar) ch) &lt;= c.ucs;
376}
377
378inline bool operator&lt;=( QChar c1, QChar c2 )
379{
380 return c1.ucs &lt;= c2.ucs;
381}
382
383inline bool operator&gt;=( QChar c, char ch ) { return ch &lt;= c; }
384inline bool operator&gt;=( char ch, QChar c ) { return c &lt;= ch; }
385inline bool operator&gt;=( QChar c1, QChar c2 ) { return c2 &lt;= c1; }
386inline bool operator&lt;( QChar c, char ch ) { return !(ch&lt;=c); }
387inline bool operator&lt;( char ch, QChar c ) { return !(c&lt;=ch); }
388inline bool operator&lt;( QChar c1, QChar c2 ) { return !(c2&lt;=c1); }
389inline bool operator&gt;( QChar c, char ch ) { return !(ch&gt;=c); }
390inline bool operator&gt;( char ch, QChar c ) { return !(c&gt;=ch); }
391inline bool operator&gt;( QChar c1, QChar c2 ) { return !(c2&gt;=c1); }
392
393// internal
394struct Q_EXPORT QStringData : public QShared {
395 QStringData() :
396 QShared(), unicode(0), ascii(0), len(0), issimpletext(TRUE), maxl(0), islatin1(FALSE) { ref(); }
397 QStringData(QChar *u, uint l, uint m) :
398 QShared(), unicode(u), ascii(0), len(l), issimpletext(FALSE), maxl(m), islatin1(FALSE) { }
399 ~QStringData() { if ( unicode ) delete[] ((char*)unicode);
400 if ( ascii ) delete[] ascii; }
401
402 void deleteSelf();
403 QChar *unicode;
404 char *ascii;
405 void setDirty() {
406 if ( ascii ) {
407 delete [] ascii;
408 ascii = 0;
409 }
410 issimpletext = FALSE;
411 }
412#ifdef Q_OS_MAC9
413 uint len;
414#else
415 uint len : 30;
416#endif
417 uint issimpletext : 1;
418#ifdef Q_OS_MAC9
419 uint maxl;
420#else
421 uint maxl : 30;
422#endif
423 uint islatin1 : 1;
424
425private:
426#if defined(Q_DISABLE_COPY)
427 QStringData( const QStringData&amp; );
428 QStringData&amp; operator=( const QStringData&amp; );
429#endif
430};
431
432
433class Q_EXPORT QString
434{
435public:
436 QString(); // make null string
437 QString( QChar ); // one-char string
438 QString( const QString &amp; ); // impl-shared copy
439 QString( const QByteArray&amp; ); // deep copy
440 QString( const QChar* unicode, uint length ); // deep copy
441#ifndef QT_NO_CAST_ASCII
442 QString( const char *str ); // deep copy
443#endif
444#ifndef QT_NO_STL
445 QString( const std::string&amp; ); // deep copy
446#endif
447 ~QString();
448
449 QString &amp;operator=( const QString &amp; ); // impl-shared copy
450 QString &amp;operator=( const char * ); // deep copy
451#ifndef QT_NO_STL
452 QString &amp;operator=( const std::string&amp; ); // deep copy
453#endif
454 QString &amp;operator=( const QCString&amp; ); // deep copy
455 QString &amp;operator=( QChar c );
456 QString &amp;operator=( char c );
457
458 QT_STATIC_CONST QString null;
459
460 bool isNull() const;
461 bool isEmpty() const;
462 uint length() const;
463 void truncate( uint pos );
464
465 QString &amp; fill( QChar c, int len = -1 );
466
467 QString copy() const;
468
469 QString arg( long a, int fieldWidth = 0, int base = 10 ) const;
470 QString arg( ulong a, int fieldWidth = 0, int base = 10 ) const;
471 QString arg( Q_LLONG a, int fieldwidth=0, int base=10 ) const;
472 QString arg( Q_ULLONG a, int fieldwidth=0, int base=10 ) const;
473 QString arg( int a, int fieldWidth = 0, int base = 10 ) const;
474 QString arg( uint a, int fieldWidth = 0, int base = 10 ) const;
475 QString arg( short a, int fieldWidth = 0, int base = 10 ) const;
476 QString arg( ushort a, int fieldWidth = 0, int base = 10 ) const;
477 QString arg( double a, int fieldWidth = 0, char fmt = 'g',
478 int prec = -1 ) const;
479 QString arg( char a, int fieldWidth = 0 ) const;
480 QString arg( QChar a, int fieldWidth = 0 ) const;
481 QString arg( const QString&amp; a, int fieldWidth = 0 ) const;
482 QString arg( const QString&amp; a1, const QString&amp; a2 ) const;
483 QString arg( const QString&amp; a1, const QString&amp; a2,
484 const QString&amp; a3 ) const;
485 QString arg( const QString&amp; a1, const QString&amp; a2, const QString&amp; a3,
486 const QString&amp; a4 ) const;
487
488#ifndef QT_NO_SPRINTF
489 QString &amp;sprintf( const char* format, ... )
490#if defined(Q_CC_GNU) &amp;&amp; !defined(__INSURE__)
491 __attribute__ ((format (printf, 2, 3)))
492#endif
493 ;
494#endif
495
496 int find( QChar c, int index=0, bool cs=TRUE ) const;
497 int find( char c, int index=0, bool cs=TRUE ) const;
498 int find( const QString &amp;str, int index=0, bool cs=TRUE ) const;
499#ifndef QT_NO_REGEXP
500 int find( const QRegExp &amp;, int index=0 ) const;
501#endif
502#ifndef QT_NO_CAST_ASCII
503 int find( const char* str, int index=0 ) const;
504#endif
505 int findRev( QChar c, int index=-1, bool cs=TRUE) const;
506 int findRev( char c, int index=-1, bool cs=TRUE) const;
507 int findRev( const QString &amp;str, int index=-1, bool cs=TRUE) const;
508#ifndef QT_NO_REGEXP
509 int findRev( const QRegExp &amp;, int index=-1 ) const;
510#endif
511#ifndef QT_NO_CAST_ASCII
512 int findRev( const char* str, int index=-1 ) const;
513#endif
514 int contains( QChar c, bool cs=TRUE ) const;
515 int contains( char c, bool cs=TRUE ) const
516 { return contains(QChar(c), cs); }
517#ifndef QT_NO_CAST_ASCII
518 int contains( const char* str, bool cs=TRUE ) const;
519#endif
520 int contains( const QString &amp;str, bool cs=TRUE ) const;
521#ifndef QT_NO_REGEXP
522 int contains( const QRegExp &amp; ) const;
523#endif
524
525 enum SectionFlags {
526 SectionDefault = 0x00,
527 SectionSkipEmpty = 0x01,
528 SectionIncludeLeadingSep = 0x02,
529 SectionIncludeTrailingSep = 0x04,
530 SectionCaseInsensitiveSeps = 0x08
531 };
532 QString section( QChar sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const;
533 QString section( char sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const;
534#ifndef QT_NO_CAST_ASCII
535 QString section( const char *in_sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const;
536#endif
537 QString section( const QString &amp;in_sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const;
538#ifndef QT_NO_REGEXP
539 QString section( const QRegExp &amp;reg, int start, int end = 0xffffffff, int flags = SectionDefault ) const;
540#endif
541
542 QString left( uint len ) const;
543 QString right( uint len ) const;
544 QString mid( uint index, uint len=0xffffffff) const;
545
546 QString leftJustify( uint width, QChar fill=' ', bool trunc=FALSE)const;
547 QString rightJustify( uint width, QChar fill=' ',bool trunc=FALSE)const;
548
549 QString lower() const;
550 QString upper() const;
551
552 QString stripWhiteSpace() const;
553 QString simplifyWhiteSpace() const;
554
555 QString &amp;insert( uint index, const QString &amp; );
556#ifndef QT_NO_CAST_ASCII
557 QString &amp;insert( uint index, const QByteArray &amp; );
558 QString &amp;insert( uint index, const char * );
559#endif
560 QString &amp;insert( uint index, const QChar*, uint len );
561 QString &amp;insert( uint index, QChar );
562 QString &amp;insert( uint index, char c ) { return insert(index,QChar(c)); }
563 QString &amp;append( char );
564 QString &amp;append( QChar );
565 QString &amp;append( const QString &amp; );
566#ifndef QT_NO_CAST_ASCII
567 QString &amp;append( const QByteArray &amp; );
568 QString &amp;append( const char * );
569#endif
570#if !defined(QT_NO_STL) &amp;&amp; !defined(QT_NO_CAST_ASCII)
571 QString &amp;append( const std::string&amp; );
572#endif
573 QString &amp;prepend( char );
574 QString &amp;prepend( QChar );
575 QString &amp;prepend( const QString &amp; );
576#ifndef QT_NO_CAST_ASCII
577 QString &amp;prepend( const QByteArray &amp; );
578 QString &amp;prepend( const char * );
579#endif
580#if !defined(QT_NO_STL) &amp;&amp; !defined(QT_NO_CAST_ASCII)
581 QString &amp;prepend( const std::string&amp; );
582#endif
583 QString &amp;remove( uint index, uint len );
584#if defined(Q_QDOC)
585 QString &amp;remove( const QString &amp; str, bool cs = TRUE );
586#else
587 // ### Qt 4.0: merge these two into one, and remove Q_QDOC hack
588 QString &amp;remove( const QString &amp; );
589 QString &amp;remove( const QString &amp;, bool cs );
590#endif
591 QString &amp;remove( QChar c );
592 QString &amp;remove( char c )
593 { return remove( QChar(c) ); }
594#ifndef QT_NO_CAST_ASCII
595 QString &amp;remove( const char * );
596#endif
597#ifndef QT_NO_REGEXP
598 QString &amp;remove( const QRegExp &amp; );
599#endif
600 QString &amp;replace( uint index, uint len, const QString &amp; );
601 QString &amp;replace( uint index, uint len, const QChar*, uint clen );
602 QString &amp;replace( uint index, uint len, QChar );
603 QString &amp;replace( uint index, uint len, char c )
604 { return replace( index, len, QChar(c) ); }
605#if defined(Q_QDOC)
606 QString &amp;replace( QChar c, const QString &amp; after, bool cs = TRUE );
607 QString &amp;replace( char c, const QString &amp; after, bool cs = TRUE );
608 QString &amp;replace( const QString &amp; before, const QString &amp; after,
609 bool cs = TRUE );
610#else
611 // ### Qt 4.0: merge these two into one, and remove Q_QDOC hack
612 QString &amp;replace( QChar c, const QString &amp; );
613 QString &amp;replace( QChar c, const QString &amp;, bool );
614
615 // ### Qt 4.0: merge these two into one, and remove Q_QDOC hack
616 QString &amp;replace( char c, const QString &amp; after )
617 { return replace( QChar(c), after, TRUE ); }
618 QString &amp;replace( char c, const QString &amp; after, bool cs )
619 { return replace( QChar(c), after, cs ); }
620
621 // ### Qt 4.0: merge these two into one, and remove Q_QDOC hack
622 QString &amp;replace( const QString &amp;, const QString &amp; );
623 QString &amp;replace( const QString &amp;, const QString &amp;, bool );
624#endif
625#ifndef QT_NO_REGEXP_CAPTURE
626 QString &amp;replace( const QRegExp &amp;, const QString &amp; );
627#endif
628 QString &amp;replace( QChar, QChar );
629
630 short toShort( bool *ok=0, int base=10 ) const;
631 ushort toUShort( bool *ok=0, int base=10 ) const;
632 int toInt( bool *ok=0, int base=10 ) const;
633 uint toUInt( bool *ok=0, int base=10 ) const;
634 long toLong( bool *ok=0, int base=10 ) const;
635 ulong toULong( bool *ok=0, int base=10 ) const;
636 Q_LLONG toLongLong( bool *ok=0, int base=10 ) const;
637 Q_ULLONG toULongLong( bool *ok=0, int base=10 ) const;
638 float toFloat( bool *ok=0 ) const;
639 double toDouble( bool *ok=0 ) const;
640
641 QString &amp;setNum( short, int base=10 );
642 QString &amp;setNum( ushort, int base=10 );
643 QString &amp;setNum( int, int base=10 );
644 QString &amp;setNum( uint, int base=10 );
645 QString &amp;setNum( long, int base=10 );
646 QString &amp;setNum( ulong, int base=10 );
647 QString &amp;setNum( Q_LLONG, int base=10 );
648 QString &amp;setNum( Q_ULLONG, int base=10 );
649 QString &amp;setNum( float, char f='g', int prec=6 );
650 QString &amp;setNum( double, char f='g', int prec=6 );
651
652 static QString number( long, int base=10 );
653 static QString number( ulong, int base=10);
654 static QString number( Q_LLONG, int base=10 );
655 static QString number( Q_ULLONG, int base=10);
656 static QString number( int, int base=10 );
657 static QString number( uint, int base=10);
658 static QString number( double, char f='g', int prec=6 );
659
660 void setExpand( uint index, QChar c );
661
662 QString &amp;operator+=( const QString &amp;str );
663#ifndef QT_NO_CAST_ASCII
664 QString &amp;operator+=( const QByteArray &amp;str );
665 QString &amp;operator+=( const char *str );
666#endif
667#if !defined(QT_NO_STL) &amp;&amp; !defined(QT_NO_CAST_ASCII)
668 QString &amp;operator+=( const std::string&amp; );
669#endif
670 QString &amp;operator+=( QChar c );
671 QString &amp;operator+=( char c );
672
673 QChar at( uint i ) const
674 { return i &lt; d-&gt;len ? d-&gt;unicode[i] : QChar::null; }
675 QChar operator[]( int i ) const { return at((uint)i); }
676 QCharRef at( uint i );
677 QCharRef operator[]( int i );
678
679 QChar constref(uint i) const
680 { return at(i); }
681 QChar&amp; ref(uint i)
682 { // Optimized for easy-inlining by simple compilers.
683 if ( d-&gt;count != 1 || i &gt;= d-&gt;len )
684 subat( i );
685 d-&gt;setDirty();
686 return d-&gt;unicode[i];
687 }
688
689 const QChar* unicode() const { return d-&gt;unicode; }
690 const char* ascii() const;
691 static QString fromAscii(const char*, int len=-1);
692 const char* latin1() const;
693 static QString fromLatin1(const char*, int len=-1);
694 QCString utf8() const;
695 static QString fromUtf8(const char*, int len=-1);
696 QCString local8Bit() const;
697 static QString fromLocal8Bit(const char*, int len=-1);
698 bool operator!() const;
699#ifndef QT_NO_ASCII_CAST
700 operator const char *() const { return ascii(); }
701#endif
702#ifndef QT_NO_STL
703 operator std::string() const { return ascii() ? ascii() : ""; }
704#endif
705
706 static QString fromUcs2( const unsigned short *ucs2 );
707 const unsigned short *ucs2() const;
708
709 QString &amp;setUnicode( const QChar* unicode, uint len );
710 QString &amp;setUnicodeCodes( const ushort* unicode_as_ushorts, uint len );
711 QString &amp;setAscii( const char*, int len=-1 );
712 QString &amp;setLatin1( const char*, int len=-1 );
713
714 int compare( const QString&amp; s ) const;
715 static int compare( const QString&amp; s1, const QString&amp; s2 )
716 { return s1.compare( s2 ); }
717
718 int localeAwareCompare( const QString&amp; s ) const;
719 static int localeAwareCompare( const QString&amp; s1, const QString&amp; s2 )
720 { return s1.localeAwareCompare( s2 ); }
721
722#ifndef QT_NO_DATASTREAM
723 friend Q_EXPORT QDataStream &amp;operator&gt;&gt;( QDataStream &amp;, QString &amp; );
724#endif
725
726 void compose();
727
728#ifndef QT_NO_COMPAT
729 const char* data() const { return ascii(); }
730#endif
731
732#if defined(Q_QDOC)
733 bool startsWith( const QString&amp; str, bool cs = TRUE ) const;
734 bool endsWith( const QString&amp; str, bool cs = TRUE ) const;
735#else
736 // ### Qt 4.0: merge these two into one, and remove Q_QDOC hack
737 bool startsWith( const QString&amp; str ) const;
738 bool startsWith( const QString&amp; str, bool cs ) const;
739
740 // ### Qt 4.0: merge these two into one, and remove Q_QDOC hack
741 bool endsWith( const QString&amp; str ) const;
742 bool endsWith( const QString&amp; str, bool cs ) const;
743#endif
744
745 void setLength( uint newLength );
746
747 uint capacity() const;
748 void reserve( uint minCapacity );
749 void squeeze();
750
751 bool simpleText() const { if ( !d-&gt;issimpletext ) checkSimpleText(); return (bool)d-&gt;issimpletext; }
752 bool isRightToLeft() const;
753
754
755private:
756 QString( int size, bool /* dummy */ ); // allocate size incl. \0
757
758 void deref();
759 void real_detach();
760 void subat( uint );
761 QString multiArg( int numArgs, const QString&amp; a1, const QString&amp; a2,
762 const QString&amp; a3 = QString::null,
763 const QString&amp; a4 = QString::null ) const;
764
765 void checkSimpleText() const;
766 void grow( uint newLength );
767#ifndef QT_NO_CAST_ASCII
768 QString &amp;insertHelper( uint index, const char *s, uint len=UINT_MAX );
769 QString &amp;operatorPlusEqHelper( const char *s, uint len2=UINT_MAX );
770#endif
771
772 static QChar* latin1ToUnicode( const char*, uint * len, uint maxlen=(uint)-1 );
773 static QChar* latin1ToUnicode( const QByteArray&amp;, uint * len );
774 static char* unicodeToLatin1( const QChar*, uint len );
775
776 QStringData *d;
777 static QStringData* shared_null;
778 static QStringData* makeSharedNull();
779
780 friend class QConstString;
781 friend class QTextStream;
782 QString( QStringData* dd, bool /* dummy */ ) : d(dd) { }
783
784 // needed for QDeepCopy
785 void detach();
786 friend class QDeepCopy&lt;QString&gt;;
787};
788
789class Q_EXPORT QCharRef {
790 friend class QString;
791 QString&amp; s;
792 uint p;
793 QCharRef(QString* str, uint pos) : s(*str), p(pos) { }
794
795public:
796 // most QChar operations repeated here
797
798 // all this is not documented: We just say "like QChar" and let it be.
799#ifndef Q_QDOC
800 ushort unicode() const { return s.constref(p).unicode(); }
801 char latin1() const { return s.constref(p).latin1(); }
802
803 // An operator= for each QChar cast constructors
804 QCharRef operator=(char c ) { s.ref(p)=c; return *this; }
805 QCharRef operator=(uchar c ) { s.ref(p)=c; return *this; }
806 QCharRef operator=(QChar c ) { s.ref(p)=c; return *this; }
807 QCharRef operator=(const QCharRef&amp; c ) { s.ref(p)=c.unicode(); return *this; }
808 QCharRef operator=(ushort rc ) { s.ref(p)=rc; return *this; }
809 QCharRef operator=(short rc ) { s.ref(p)=rc; return *this; }
810 QCharRef operator=(uint rc ) { s.ref(p)=rc; return *this; }
811 QCharRef operator=(int rc ) { s.ref(p)=rc; return *this; }
812
813 operator QChar () const { return s.constref(p); }
814
815 // each function...
816 bool isNull() const { return unicode()==0; }
817 bool isPrint() const { return s.constref(p).isPrint(); }
818 bool isPunct() const { return s.constref(p).isPunct(); }
819 bool isSpace() const { return s.constref(p).isSpace(); }
820 bool isMark() const { return s.constref(p).isMark(); }
821 bool isLetter() const { return s.constref(p).isLetter(); }
822 bool isNumber() const { return s.constref(p).isNumber(); }
823 bool isLetterOrNumber() { return s.constref(p).isLetterOrNumber(); }
824 bool isDigit() const { return s.constref(p).isDigit(); }
825
826 int digitValue() const { return s.constref(p).digitValue(); }
827 QChar lower() const { return s.constref(p).lower(); }
828 QChar upper() const { return s.constref(p).upper(); }
829
830 QChar::Category category() const { return s.constref(p).category(); }
831 QChar::Direction direction() const { return s.constref(p).direction(); }
832 QChar::Joining joining() const { return s.constref(p).joining(); }
833 bool mirrored() const { return s.constref(p).mirrored(); }
834 QChar mirroredChar() const { return s.constref(p).mirroredChar(); }
835 const QString &amp;decomposition() const { return s.constref(p).decomposition(); }
836 QChar::Decomposition decompositionTag() const { return s.constref(p).decompositionTag(); }
837 unsigned char combiningClass() const { return s.constref(p).combiningClass(); }
838
839 // Not the non-const ones of these.
840 uchar cell() const { return s.constref(p).cell(); }
841 uchar row() const { return s.constref(p).row(); }
842#endif
843};
844
845inline QCharRef QString::at( uint i ) { return QCharRef(this,i); }
846inline QCharRef QString::operator[]( int i ) { return at((uint)i); }
847
848
849class Q_EXPORT QConstString : private QString {
850public:
851 QConstString( const QChar* unicode, uint length );
852 ~QConstString();
853 const QString&amp; string() const { return *this; }
854};
855
856
857/*****************************************************************************
858 QString stream functions
859 *****************************************************************************/
860#ifndef QT_NO_DATASTREAM
861Q_EXPORT QDataStream &amp;operator&lt;&lt;( QDataStream &amp;, const QString &amp; );
862Q_EXPORT QDataStream &amp;operator&gt;&gt;( QDataStream &amp;, QString &amp; );
863#endif
864
865/*****************************************************************************
866 QString inline functions
867 *****************************************************************************/
868
869// These two move code into makeSharedNull() and deletesData()
870// to improve cache-coherence (and reduce code bloat), while
871// keeping the common cases fast.
872//
873// No safe way to pre-init shared_null on ALL compilers/linkers.
874inline QString::QString() :
875 d(shared_null ? shared_null : makeSharedNull())
876{
877 d-&gt;ref();
878}
879//
880inline QString::~QString()
881{
882 if ( d-&gt;deref() ) {
883 if ( d != shared_null )
884 d-&gt;deleteSelf();
885 }
886}
887
888// needed for QDeepCopy
889inline void QString::detach()
890{ real_detach(); }
891
892inline QString QString::section( QChar sep, int start, int end, int flags ) const
893{ return section(QString(sep), start, end, flags); }
894
895inline QString QString::section( char sep, int start, int end, int flags ) const
896{ return section(QChar(sep), start, end, flags); }
897
898#ifndef QT_NO_CAST_ASCII
899inline QString QString::section( const char *in_sep, int start, int end, int flags ) const
900{ return section(QString(in_sep), start, end, flags); }
901#endif
902
903inline QString &amp;QString::operator=( QChar c )
904{ *this = QString(c); return *this; }
905
906inline QString &amp;QString::operator=( char c )
907{ *this = QString(QChar(c)); return *this; }
908
909inline bool QString::isNull() const
910{ return unicode() == 0; }
911
912inline bool QString::operator!() const
913{ return isNull(); }
914
915inline uint QString::length() const
916{ return d-&gt;len; }
917
918inline uint QString::capacity() const
919{ return d-&gt;maxl; }
920
921inline bool QString::isEmpty() const
922{ return length() == 0; }
923
924inline QString QString::copy() const
925{ return QString( *this ); }
926
927#ifndef QT_NO_CAST_ASCII
928inline QString &amp;QString::insert( uint index, const char *s )
929{ return insertHelper( index, s ); }
930
931inline QString &amp;QString::insert( uint index, const QByteArray &amp;s )
932{
933 int pos = s.find( 0 );
934 return insertHelper( index, s, pos==-1 ? s.size() : pos );
935}
936#endif
937
938inline QString &amp;QString::prepend( const QString &amp; s )
939{ return insert(0,s); }
940
941inline QString &amp;QString::prepend( QChar c )
942{ return insert(0,c); }
943
944inline QString &amp;QString::prepend( char c )
945{ return insert(0,c); }
946
947#ifndef QT_NO_CAST_ASCII
948inline QString &amp;QString::prepend( const QByteArray &amp; s )
949{ return insert(0,s); }
950#endif
951
952#ifndef QT_NO_CAST_ASCII
953inline QString &amp;QString::operator+=( const QByteArray &amp;s )
954{
955 int pos = s.find( 0 );
956 return operatorPlusEqHelper( s, pos==-1 ? s.size() : pos );
957}
958#endif
959
960inline QString &amp;QString::append( const QString &amp; s )
961{ return operator+=(s); }
962
963#ifndef QT_NO_CAST_ASCII
964inline QString &amp;QString::append( const QByteArray &amp;s )
965{ return operator+=(s); }
966
967inline QString &amp;QString::append( const char * s )
968{ return operator+=(s); }
969#endif
970
971inline QString &amp;QString::append( QChar c )
972{ return operator+=(c); }
973
974inline QString &amp;QString::append( char c )
975{ return operator+=(c); }
976
977#ifndef QT_NO_STL
978inline QString &amp;QString::operator=( const std::string&amp; str )
979{ return operator=(str.c_str()); }
980#ifndef QT_NO_CAST_ASCII
981inline QString &amp;QString::operator+=( const std::string&amp; s )
982{ return operator+=(s.c_str()); }
983inline QString &amp;QString::append( const std::string&amp; s )
984{ return operator+=(s); }
985inline QString &amp;QString::prepend( const std::string&amp; s )
986{ return insert(0, s); }
987#endif
988#endif
989
990inline QString &amp;QString::setNum( short n, int base )
991{ return setNum((Q_LLONG)n, base); }
992
993inline QString &amp;QString::setNum( ushort n, int base )
994{ return setNum((Q_ULLONG)n, base); }
995
996inline QString &amp;QString::setNum( int n, int base )
997{ return setNum((Q_LLONG)n, base); }
998
999inline QString &amp;QString::setNum( uint n, int base )
1000{ return setNum((Q_ULLONG)n, base); }
1001
1002inline QString &amp;QString::setNum( float n, char f, int prec )
1003{ return setNum((double)n,f,prec); }
1004
1005inline QString QString::arg( int a, int fieldWidth, int base ) const
1006{ return arg( (Q_LLONG)a, fieldWidth, base ); }
1007
1008inline QString QString::arg( uint a, int fieldWidth, int base ) const
1009{ return arg( (Q_ULLONG)a, fieldWidth, base ); }
1010
1011inline QString QString::arg( short a, int fieldWidth, int base ) const
1012{ return arg( (Q_LLONG)a, fieldWidth, base ); }
1013
1014inline QString QString::arg( ushort a, int fieldWidth, int base ) const
1015{ return arg( (Q_ULLONG)a, fieldWidth, base ); }
1016
1017inline QString QString::arg( const QString&amp; a1, const QString&amp; a2 ) const {
1018 return multiArg( 2, a1, a2 );
1019}
1020
1021inline QString QString::arg( const QString&amp; a1, const QString&amp; a2,
1022 const QString&amp; a3 ) const {
1023 return multiArg( 3, a1, a2, a3 );
1024}
1025
1026inline QString QString::arg( const QString&amp; a1, const QString&amp; a2,
1027 const QString&amp; a3, const QString&amp; a4 ) const {
1028 return multiArg( 4, a1, a2, a3, a4 );
1029}
1030
1031inline int QString::find( char c, int index, bool cs ) const
1032{ return find(QChar(c), index, cs); }
1033
1034inline int QString::findRev( char c, int index, bool cs ) const
1035{ return findRev( QChar(c), index, cs ); }
1036
1037#ifndef QT_NO_CAST_ASCII
1038inline int QString::find( const char* str, int index ) const
1039{ return find(QString::fromAscii(str), index); }
1040
1041inline int QString::findRev( const char* str, int index ) const
1042{ return findRev(QString::fromAscii(str), index); }
1043#endif
1044
1045
1046/*****************************************************************************
1047 QString non-member operators
1048 *****************************************************************************/
1049
1050Q_EXPORT bool operator!=( const QString &amp;s1, const QString &amp;s2 );
1051Q_EXPORT bool operator&lt;( const QString &amp;s1, const QString &amp;s2 );
1052Q_EXPORT bool operator&lt;=( const QString &amp;s1, const QString &amp;s2 );
1053Q_EXPORT bool operator==( const QString &amp;s1, const QString &amp;s2 );
1054Q_EXPORT bool operator&gt;( const QString &amp;s1, const QString &amp;s2 );
1055Q_EXPORT bool operator&gt;=( const QString &amp;s1, const QString &amp;s2 );
1056#ifndef QT_NO_CAST_ASCII
1057Q_EXPORT bool operator!=( const QString &amp;s1, const char *s2 );
1058Q_EXPORT bool operator&lt;( const QString &amp;s1, const char *s2 );
1059Q_EXPORT bool operator&lt;=( const QString &amp;s1, const char *s2 );
1060Q_EXPORT bool operator==( const QString &amp;s1, const char *s2 );
1061Q_EXPORT bool operator&gt;( const QString &amp;s1, const char *s2 );
1062Q_EXPORT bool operator&gt;=( const QString &amp;s1, const char *s2 );
1063Q_EXPORT bool operator!=( const char *s1, const QString &amp;s2 );
1064Q_EXPORT bool operator&lt;( const char *s1, const QString &amp;s2 );
1065Q_EXPORT bool operator&lt;=( const char *s1, const QString &amp;s2 );
1066Q_EXPORT bool operator==( const char *s1, const QString &amp;s2 );
1067//Q_EXPORT bool operator&gt;( const char *s1, const QString &amp;s2 ); // MSVC++
1068Q_EXPORT bool operator&gt;=( const char *s1, const QString &amp;s2 );
1069#endif
1070
1071Q_EXPORT inline const QString operator+( const QString &amp;s1, const QString &amp;s2 )
1072{
1073 QString tmp( s1 );
1074 tmp += s2;
1075 return tmp;
1076}
1077
1078#ifndef QT_NO_CAST_ASCII
1079Q_EXPORT inline const QString operator+( const QString &amp;s1, const char *s2 )
1080{
1081 QString tmp( s1 );
1082 tmp += QString::fromAscii(s2);
1083 return tmp;
1084}
1085
1086Q_EXPORT inline const QString operator+( const char *s1, const QString &amp;s2 )
1087{
1088 QString tmp = QString::fromAscii( s1 );
1089 tmp += s2;
1090 return tmp;
1091}
1092#endif
1093
1094Q_EXPORT inline const QString operator+( const QString &amp;s1, QChar c2 )
1095{
1096 QString tmp( s1 );
1097 tmp += c2;
1098 return tmp;
1099}
1100
1101Q_EXPORT inline const QString operator+( const QString &amp;s1, char c2 )
1102{
1103 QString tmp( s1 );
1104 tmp += c2;
1105 return tmp;
1106}
1107
1108Q_EXPORT inline const QString operator+( QChar c1, const QString &amp;s2 )
1109{
1110 QString tmp;
1111 tmp += c1;
1112 tmp += s2;
1113 return tmp;
1114}
1115
1116Q_EXPORT inline const QString operator+( char c1, const QString &amp;s2 )
1117{
1118 QString tmp;
1119 tmp += c1;
1120 tmp += s2;
1121 return tmp;
1122}
1123
1124#ifndef QT_NO_STL
1125Q_EXPORT inline const QString operator+(const QString&amp; s1, const std::string&amp; s2)
1126{
1127 return s1 + QString(s2);
1128}
1129
1130Q_EXPORT inline const QString operator+(const std::string&amp; s1, const QString&amp; s2)
1131{
1132 QString tmp(s2);
1133 return QString(tmp.prepend(s1));
1134}
1135#endif
1136
1137
1138#if defined(Q_OS_WIN32)
1139extern Q_EXPORT QString qt_winQString(void*);
1140extern Q_EXPORT const void* qt_winTchar(const QString&amp; str, bool addnul);
1141extern Q_EXPORT void* qt_winTchar_new(const QString&amp; str);
1142extern Q_EXPORT QCString qt_winQString2MB( const QString&amp; s, int len=-1 );
1143extern Q_EXPORT QString qt_winMB2QString( const char* mb, int len=-1 );
1144#endif
1145
1146#define Q_DEFINED_QSTRING
1147#include "qwinexport.h"
1148#endif // QSTRING_H
1149</pre>
1150<!-- eof -->
1151<p><address><hr><div align=center>
1152<table width=100% cellspacing=0 border=0><tr>
1153<td>Copyright &copy; 2007
1154<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
1155<td align=right><div align=right>Qt 3.3.8</div>
1156</table></div></address></body>
1157</html>
Note: See TracBrowser for help on using the repository browser.