| 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"><!-- | 
|---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; } | 
|---|
| 9 | a:link { color: #004faf; text-decoration: none } | 
|---|
| 10 | a:visited { color: #672967; text-decoration: none } | 
|---|
| 11 | body { 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 Classes</font></a> | 
|---|
| 23 | | <a href="mainclasses.html"> | 
|---|
| 24 | <font color="#004faf">Main 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 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 <limits.h> | 
|---|
| 83 | #endif | 
|---|
| 84 |  | 
|---|
| 85 | #ifndef QT_NO_STL | 
|---|
| 86 | #if defined ( Q_CC_MSVC_NET ) && _MSC_VER < 1310 // Avoids nasty warning for xlocale, line 450 | 
|---|
| 87 | #  pragma warning ( push ) | 
|---|
| 88 | #  pragma warning ( disable : 4189 ) | 
|---|
| 89 | #  include <string> | 
|---|
| 90 | #  pragma warning ( pop ) | 
|---|
| 91 | #else | 
|---|
| 92 | #  include <string> | 
|---|
| 93 | #endif | 
|---|
| 94 | #if defined(Q_WRONG_SB_CTYPE_MACROS) && defined(_SB_CTYPE_MACROS) | 
|---|
| 95 | #undef _SB_CTYPE_MACROS | 
|---|
| 96 | #endif | 
|---|
| 97 | #endif | 
|---|
| 98 |  | 
|---|
| 99 |  | 
|---|
| 100 | /***************************************************************************** | 
|---|
| 101 | QString class | 
|---|
| 102 | *****************************************************************************/ | 
|---|
| 103 |  | 
|---|
| 104 | class QRegExp; | 
|---|
| 105 | class QString; | 
|---|
| 106 | class QCharRef; | 
|---|
| 107 | template <class T> class QDeepCopy; | 
|---|
| 108 |  | 
|---|
| 109 | class Q_EXPORT QChar { | 
|---|
| 110 | public: | 
|---|
| 111 | QChar(); | 
|---|
| 112 | QChar( char c ); | 
|---|
| 113 | QChar( uchar c ); | 
|---|
| 114 | QChar( uchar c, uchar r ); | 
|---|
| 115 | QChar( const QChar& 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 &decomposition() const; // ### return just QString in 4.0 | 
|---|
| 227 | Decomposition decompositionTag() const; | 
|---|
| 228 | unsigned char combiningClass() const; | 
|---|
| 229 |  | 
|---|
| 230 | char latin1() const { return ucs > 0xff ? 0 : (char) ucs; } | 
|---|
| 231 | ushort unicode() const { return ucs; } | 
|---|
| 232 | #ifdef Q_NO_PACKED_REFERENCE | 
|---|
| 233 | ushort &unicode() { return *(&ucs); } | 
|---|
| 234 | #else | 
|---|
| 235 | ushort &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 & 0xff); } | 
|---|
| 254 | uchar row() const { return ((uchar) (ucs>>8)&0xff); } | 
|---|
| 255 | void setCell( uchar cell ) { ucs = (ucs & 0xff00) + cell; } | 
|---|
| 256 | void setRow( uchar row ) { ucs = (((ushort) row)<<8) + (ucs&0xff); } | 
|---|
| 257 |  | 
|---|
| 258 | static bool networkOrdered() { | 
|---|
| 259 | int wordSize; | 
|---|
| 260 | bool bigEndian = FALSE; | 
|---|
| 261 | qSysInfo( &wordSize, &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<=( QChar c, char ch ); | 
|---|
| 272 | friend inline bool operator<=( char ch, QChar c ); | 
|---|
| 273 | friend inline bool operator<=( QChar c1, QChar c2 ); | 
|---|
| 274 |  | 
|---|
| 275 | private: | 
|---|
| 276 | ushort ucs; | 
|---|
| 277 | #if defined(QT_QSTRING_UCS_4) | 
|---|
| 278 | ushort grp; | 
|---|
| 279 | #endif | 
|---|
| 280 | } Q_PACKED; | 
|---|
| 281 |  | 
|---|
| 282 | inline QChar::QChar() : ucs( 0 ) | 
|---|
| 283 | #ifdef QT_QSTRING_UCS_4 | 
|---|
| 284 | , grp( 0 ) | 
|---|
| 285 | #endif | 
|---|
| 286 | { | 
|---|
| 287 | } | 
|---|
| 288 | inline QChar::QChar( char c ) : ucs( (uchar)c ) | 
|---|
| 289 | #ifdef QT_QSTRING_UCS_4 | 
|---|
| 290 | , grp( 0 ) | 
|---|
| 291 | #endif | 
|---|
| 292 | { | 
|---|
| 293 | } | 
|---|
| 294 | inline QChar::QChar( uchar c ) : ucs( c ) | 
|---|
| 295 | #ifdef QT_QSTRING_UCS_4 | 
|---|
| 296 | , grp( 0 ) | 
|---|
| 297 | #endif | 
|---|
| 298 | { | 
|---|
| 299 | } | 
|---|
| 300 | inline QChar::QChar( uchar c, uchar r ) : ucs( (r << 8) | c ) | 
|---|
| 301 | #ifdef QT_QSTRING_UCS_4 | 
|---|
| 302 | , grp( 0 ) | 
|---|
| 303 | #endif | 
|---|
| 304 | { | 
|---|
| 305 | } | 
|---|
| 306 | inline QChar::QChar( const QChar& c ) : ucs( c.ucs ) | 
|---|
| 307 | #ifdef QT_QSTRING_UCS_4 | 
|---|
| 308 | , grp( c.grp ) | 
|---|
| 309 | #endif | 
|---|
| 310 | { | 
|---|
| 311 | } | 
|---|
| 312 |  | 
|---|
| 313 | inline QChar::QChar( ushort rc ) : ucs( rc ) | 
|---|
| 314 | #ifdef QT_QSTRING_UCS_4 | 
|---|
| 315 | , grp( 0 ) | 
|---|
| 316 | #endif | 
|---|
| 317 | { | 
|---|
| 318 | } | 
|---|
| 319 | inline QChar::QChar( short rc ) : ucs( (ushort) rc ) | 
|---|
| 320 | #ifdef QT_QSTRING_UCS_4 | 
|---|
| 321 | , grp( 0 ) | 
|---|
| 322 | #endif | 
|---|
| 323 | { | 
|---|
| 324 | } | 
|---|
| 325 | inline QChar::QChar( uint rc ) : ucs(  (ushort ) (rc & 0xffff) ) | 
|---|
| 326 | #ifdef QT_QSTRING_UCS_4 | 
|---|
| 327 | , grp( (ushort) ((rc >> 16) & 0xffff) ) | 
|---|
| 328 | #endif | 
|---|
| 329 | { | 
|---|
| 330 | } | 
|---|
| 331 | inline QChar::QChar( int rc ) : ucs( (ushort) (rc & 0xffff) ) | 
|---|
| 332 | #ifdef QT_QSTRING_UCS_4 | 
|---|
| 333 | , grp( (ushort) ((rc >> 16) & 0xffff) ) | 
|---|
| 334 | #endif | 
|---|
| 335 | { | 
|---|
| 336 | } | 
|---|
| 337 |  | 
|---|
| 338 | inline bool operator==( char ch, QChar c ) | 
|---|
| 339 | { | 
|---|
| 340 | return ((uchar) ch) == c.ucs; | 
|---|
| 341 | } | 
|---|
| 342 |  | 
|---|
| 343 | inline bool operator==( QChar c, char ch ) | 
|---|
| 344 | { | 
|---|
| 345 | return ((uchar) ch) == c.ucs; | 
|---|
| 346 | } | 
|---|
| 347 |  | 
|---|
| 348 | inline bool operator==( QChar c1, QChar c2 ) | 
|---|
| 349 | { | 
|---|
| 350 | return c1.ucs == c2.ucs; | 
|---|
| 351 | } | 
|---|
| 352 |  | 
|---|
| 353 | inline bool operator!=( QChar c1, QChar c2 ) | 
|---|
| 354 | { | 
|---|
| 355 | return c1.ucs != c2.ucs; | 
|---|
| 356 | } | 
|---|
| 357 |  | 
|---|
| 358 | inline bool operator!=( char ch, QChar c ) | 
|---|
| 359 | { | 
|---|
| 360 | return ((uchar)ch) != c.ucs; | 
|---|
| 361 | } | 
|---|
| 362 |  | 
|---|
| 363 | inline bool operator!=( QChar c, char ch ) | 
|---|
| 364 | { | 
|---|
| 365 | return ((uchar) ch) != c.ucs; | 
|---|
| 366 | } | 
|---|
| 367 |  | 
|---|
| 368 | inline bool operator<=( QChar c, char ch ) | 
|---|
| 369 | { | 
|---|
| 370 | return c.ucs <= ((uchar) ch); | 
|---|
| 371 | } | 
|---|
| 372 |  | 
|---|
| 373 | inline bool operator<=( char ch, QChar c ) | 
|---|
| 374 | { | 
|---|
| 375 | return ((uchar) ch) <= c.ucs; | 
|---|
| 376 | } | 
|---|
| 377 |  | 
|---|
| 378 | inline bool operator<=( QChar c1, QChar c2 ) | 
|---|
| 379 | { | 
|---|
| 380 | return c1.ucs <= c2.ucs; | 
|---|
| 381 | } | 
|---|
| 382 |  | 
|---|
| 383 | inline bool operator>=( QChar c, char ch ) { return ch <= c; } | 
|---|
| 384 | inline bool operator>=( char ch, QChar c ) { return c <= ch; } | 
|---|
| 385 | inline bool operator>=( QChar c1, QChar c2 ) { return c2 <= c1; } | 
|---|
| 386 | inline bool operator<( QChar c, char ch ) { return !(ch<=c); } | 
|---|
| 387 | inline bool operator<( char ch, QChar c ) { return !(c<=ch); } | 
|---|
| 388 | inline bool operator<( QChar c1, QChar c2 ) { return !(c2<=c1); } | 
|---|
| 389 | inline bool operator>( QChar c, char ch ) { return !(ch>=c); } | 
|---|
| 390 | inline bool operator>( char ch, QChar c ) { return !(c>=ch); } | 
|---|
| 391 | inline bool operator>( QChar c1, QChar c2 ) { return !(c2>=c1); } | 
|---|
| 392 |  | 
|---|
| 393 | // internal | 
|---|
| 394 | struct 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 |  | 
|---|
| 425 | private: | 
|---|
| 426 | #if defined(Q_DISABLE_COPY) | 
|---|
| 427 | QStringData( const QStringData& ); | 
|---|
| 428 | QStringData& operator=( const QStringData& ); | 
|---|
| 429 | #endif | 
|---|
| 430 | }; | 
|---|
| 431 |  | 
|---|
| 432 |  | 
|---|
| 433 | class Q_EXPORT QString | 
|---|
| 434 | { | 
|---|
| 435 | public: | 
|---|
| 436 | QString();                                  // make null string | 
|---|
| 437 | QString( QChar );                           // one-char string | 
|---|
| 438 | QString( const QString & );                 // impl-shared copy | 
|---|
| 439 | QString( const QByteArray& );               // 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& );                   // deep copy | 
|---|
| 446 | #endif | 
|---|
| 447 | ~QString(); | 
|---|
| 448 |  | 
|---|
| 449 | QString    &operator=( const QString & );   // impl-shared copy | 
|---|
| 450 | QString    &operator=( const char * );      // deep copy | 
|---|
| 451 | #ifndef QT_NO_STL | 
|---|
| 452 | QString    &operator=( const std::string& );     // deep copy | 
|---|
| 453 | #endif | 
|---|
| 454 | QString    &operator=( const QCString& );   // deep copy | 
|---|
| 455 | QString    &operator=( QChar c ); | 
|---|
| 456 | QString    &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 &   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& a, int fieldWidth = 0 ) const; | 
|---|
| 482 | QString arg( const QString& a1, const QString& a2 ) const; | 
|---|
| 483 | QString arg( const QString& a1, const QString& a2, | 
|---|
| 484 | const QString& a3 ) const; | 
|---|
| 485 | QString arg( const QString& a1, const QString& a2, const QString& a3, | 
|---|
| 486 | const QString& a4 ) const; | 
|---|
| 487 |  | 
|---|
| 488 | #ifndef QT_NO_SPRINTF | 
|---|
| 489 | QString    &sprintf( const char* format, ... ) | 
|---|
| 490 | #if defined(Q_CC_GNU) && !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 &str, int index=0, bool cs=TRUE ) const; | 
|---|
| 499 | #ifndef QT_NO_REGEXP | 
|---|
| 500 | int         find( const QRegExp &, 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 &str, int index=-1, bool cs=TRUE) const; | 
|---|
| 508 | #ifndef QT_NO_REGEXP | 
|---|
| 509 | int         findRev( const QRegExp &, 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 &str, bool cs=TRUE ) const; | 
|---|
| 521 | #ifndef QT_NO_REGEXP | 
|---|
| 522 | int         contains( const QRegExp & ) 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 &in_sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const; | 
|---|
| 538 | #ifndef QT_NO_REGEXP | 
|---|
| 539 | QString     section( const QRegExp &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    &insert( uint index, const QString & ); | 
|---|
| 556 | #ifndef QT_NO_CAST_ASCII | 
|---|
| 557 | QString    &insert( uint index, const QByteArray & ); | 
|---|
| 558 | QString    &insert( uint index, const char * ); | 
|---|
| 559 | #endif | 
|---|
| 560 | QString    &insert( uint index, const QChar*, uint len ); | 
|---|
| 561 | QString    &insert( uint index, QChar ); | 
|---|
| 562 | QString    &insert( uint index, char c ) { return insert(index,QChar(c)); } | 
|---|
| 563 | QString    &append( char ); | 
|---|
| 564 | QString    &append( QChar ); | 
|---|
| 565 | QString    &append( const QString & ); | 
|---|
| 566 | #ifndef QT_NO_CAST_ASCII | 
|---|
| 567 | QString    &append( const QByteArray & ); | 
|---|
| 568 | QString    &append( const char * ); | 
|---|
| 569 | #endif | 
|---|
| 570 | #if !defined(QT_NO_STL) && !defined(QT_NO_CAST_ASCII) | 
|---|
| 571 | QString    &append( const std::string& ); | 
|---|
| 572 | #endif | 
|---|
| 573 | QString    &prepend( char ); | 
|---|
| 574 | QString    &prepend( QChar ); | 
|---|
| 575 | QString    &prepend( const QString & ); | 
|---|
| 576 | #ifndef QT_NO_CAST_ASCII | 
|---|
| 577 | QString    &prepend( const QByteArray & ); | 
|---|
| 578 | QString    &prepend( const char * ); | 
|---|
| 579 | #endif | 
|---|
| 580 | #if !defined(QT_NO_STL) && !defined(QT_NO_CAST_ASCII) | 
|---|
| 581 | QString    &prepend( const std::string& ); | 
|---|
| 582 | #endif | 
|---|
| 583 | QString    &remove( uint index, uint len ); | 
|---|
| 584 | #if defined(Q_QDOC) | 
|---|
| 585 | QString    &remove( const QString & str, bool cs = TRUE ); | 
|---|
| 586 | #else | 
|---|
| 587 | // ### Qt 4.0: merge these two into one, and remove Q_QDOC hack | 
|---|
| 588 | QString    &remove( const QString & ); | 
|---|
| 589 | QString    &remove( const QString &, bool cs ); | 
|---|
| 590 | #endif | 
|---|
| 591 | QString    &remove( QChar c ); | 
|---|
| 592 | QString    &remove( char c ) | 
|---|
| 593 | { return remove( QChar(c) ); } | 
|---|
| 594 | #ifndef QT_NO_CAST_ASCII | 
|---|
| 595 | QString    &remove( const char * ); | 
|---|
| 596 | #endif | 
|---|
| 597 | #ifndef QT_NO_REGEXP | 
|---|
| 598 | QString    &remove( const QRegExp & ); | 
|---|
| 599 | #endif | 
|---|
| 600 | QString    &replace( uint index, uint len, const QString & ); | 
|---|
| 601 | QString    &replace( uint index, uint len, const QChar*, uint clen ); | 
|---|
| 602 | QString    &replace( uint index, uint len, QChar ); | 
|---|
| 603 | QString    &replace( uint index, uint len, char c ) | 
|---|
| 604 | { return replace( index, len, QChar(c) ); } | 
|---|
| 605 | #if defined(Q_QDOC) | 
|---|
| 606 | QString    &replace( QChar c, const QString & after, bool cs = TRUE ); | 
|---|
| 607 | QString    &replace( char c, const QString & after, bool cs = TRUE ); | 
|---|
| 608 | QString    &replace( const QString & before, const QString & after, | 
|---|
| 609 | bool cs = TRUE ); | 
|---|
| 610 | #else | 
|---|
| 611 | // ### Qt 4.0: merge these two into one, and remove Q_QDOC hack | 
|---|
| 612 | QString    &replace( QChar c, const QString & ); | 
|---|
| 613 | QString    &replace( QChar c, const QString &, bool ); | 
|---|
| 614 |  | 
|---|
| 615 | // ### Qt 4.0: merge these two into one, and remove Q_QDOC hack | 
|---|
| 616 | QString    &replace( char c, const QString & after ) | 
|---|
| 617 | { return replace( QChar(c), after, TRUE ); } | 
|---|
| 618 | QString    &replace( char c, const QString & 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    &replace( const QString &, const QString & ); | 
|---|
| 623 | QString    &replace( const QString &, const QString &, bool ); | 
|---|
| 624 | #endif | 
|---|
| 625 | #ifndef QT_NO_REGEXP_CAPTURE | 
|---|
| 626 | QString    &replace( const QRegExp &, const QString & ); | 
|---|
| 627 | #endif | 
|---|
| 628 | QString    &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    &setNum( short, int base=10 ); | 
|---|
| 642 | QString    &setNum( ushort, int base=10 ); | 
|---|
| 643 | QString    &setNum( int, int base=10 ); | 
|---|
| 644 | QString    &setNum( uint, int base=10 ); | 
|---|
| 645 | QString    &setNum( long, int base=10 ); | 
|---|
| 646 | QString    &setNum( ulong, int base=10 ); | 
|---|
| 647 | QString    &setNum( Q_LLONG, int base=10 ); | 
|---|
| 648 | QString    &setNum( Q_ULLONG, int base=10 ); | 
|---|
| 649 | QString    &setNum( float, char f='g', int prec=6 ); | 
|---|
| 650 | QString    &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    &operator+=( const QString &str ); | 
|---|
| 663 | #ifndef QT_NO_CAST_ASCII | 
|---|
| 664 | QString    &operator+=( const QByteArray &str ); | 
|---|
| 665 | QString    &operator+=( const char *str ); | 
|---|
| 666 | #endif | 
|---|
| 667 | #if !defined(QT_NO_STL) && !defined(QT_NO_CAST_ASCII) | 
|---|
| 668 | QString    &operator+=( const std::string& ); | 
|---|
| 669 | #endif | 
|---|
| 670 | QString    &operator+=( QChar c ); | 
|---|
| 671 | QString    &operator+=( char c ); | 
|---|
| 672 |  | 
|---|
| 673 | QChar at( uint i ) const | 
|---|
| 674 | { return i < d->len ? d->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& ref(uint i) | 
|---|
| 682 | { // Optimized for easy-inlining by simple compilers. | 
|---|
| 683 | if ( d->count != 1 || i >= d->len ) | 
|---|
| 684 | subat( i ); | 
|---|
| 685 | d->setDirty(); | 
|---|
| 686 | return d->unicode[i]; | 
|---|
| 687 | } | 
|---|
| 688 |  | 
|---|
| 689 | const QChar* unicode() const { return d->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 &setUnicode( const QChar* unicode, uint len ); | 
|---|
| 710 | QString &setUnicodeCodes( const ushort* unicode_as_ushorts, uint len ); | 
|---|
| 711 | QString &setAscii( const char*, int len=-1 ); | 
|---|
| 712 | QString &setLatin1( const char*, int len=-1 ); | 
|---|
| 713 |  | 
|---|
| 714 | int compare( const QString& s ) const; | 
|---|
| 715 | static int compare( const QString& s1, const QString& s2 ) | 
|---|
| 716 | { return s1.compare( s2 ); } | 
|---|
| 717 |  | 
|---|
| 718 | int localeAwareCompare( const QString& s ) const; | 
|---|
| 719 | static int localeAwareCompare( const QString& s1, const QString& s2 ) | 
|---|
| 720 | { return s1.localeAwareCompare( s2 ); } | 
|---|
| 721 |  | 
|---|
| 722 | #ifndef QT_NO_DATASTREAM | 
|---|
| 723 | friend Q_EXPORT QDataStream &operator>>( QDataStream &, QString & ); | 
|---|
| 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& str, bool cs = TRUE ) const; | 
|---|
| 734 | bool endsWith( const QString& 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& str ) const; | 
|---|
| 738 | bool startsWith( const QString& str, bool cs ) const; | 
|---|
| 739 |  | 
|---|
| 740 | // ### Qt 4.0: merge these two into one, and remove Q_QDOC hack | 
|---|
| 741 | bool endsWith( const QString& str ) const; | 
|---|
| 742 | bool endsWith( const QString& 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->issimpletext ) checkSimpleText(); return (bool)d->issimpletext; } | 
|---|
| 752 | bool isRightToLeft() const; | 
|---|
| 753 |  | 
|---|
| 754 |  | 
|---|
| 755 | private: | 
|---|
| 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& a1, const QString& a2, | 
|---|
| 762 | const QString& a3 = QString::null, | 
|---|
| 763 | const QString& a4 = QString::null ) const; | 
|---|
| 764 |  | 
|---|
| 765 | void checkSimpleText() const; | 
|---|
| 766 | void grow( uint newLength ); | 
|---|
| 767 | #ifndef QT_NO_CAST_ASCII | 
|---|
| 768 | QString &insertHelper( uint index, const char *s, uint len=UINT_MAX ); | 
|---|
| 769 | QString &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&, 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<QString>; | 
|---|
| 787 | }; | 
|---|
| 788 |  | 
|---|
| 789 | class Q_EXPORT QCharRef { | 
|---|
| 790 | friend class QString; | 
|---|
| 791 | QString& s; | 
|---|
| 792 | uint p; | 
|---|
| 793 | QCharRef(QString* str, uint pos) : s(*str), p(pos) { } | 
|---|
| 794 |  | 
|---|
| 795 | public: | 
|---|
| 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& 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 &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 |  | 
|---|
| 845 | inline QCharRef QString::at( uint i ) { return QCharRef(this,i); } | 
|---|
| 846 | inline QCharRef QString::operator[]( int i ) { return at((uint)i); } | 
|---|
| 847 |  | 
|---|
| 848 |  | 
|---|
| 849 | class Q_EXPORT QConstString : private QString { | 
|---|
| 850 | public: | 
|---|
| 851 | QConstString( const QChar* unicode, uint length ); | 
|---|
| 852 | ~QConstString(); | 
|---|
| 853 | const QString& string() const { return *this; } | 
|---|
| 854 | }; | 
|---|
| 855 |  | 
|---|
| 856 |  | 
|---|
| 857 | /***************************************************************************** | 
|---|
| 858 | QString stream functions | 
|---|
| 859 | *****************************************************************************/ | 
|---|
| 860 | #ifndef QT_NO_DATASTREAM | 
|---|
| 861 | Q_EXPORT QDataStream &operator<<( QDataStream &, const QString & ); | 
|---|
| 862 | Q_EXPORT QDataStream &operator>>( QDataStream &, QString & ); | 
|---|
| 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. | 
|---|
| 874 | inline QString::QString() : | 
|---|
| 875 | d(shared_null ? shared_null : makeSharedNull()) | 
|---|
| 876 | { | 
|---|
| 877 | d->ref(); | 
|---|
| 878 | } | 
|---|
| 879 | // | 
|---|
| 880 | inline QString::~QString() | 
|---|
| 881 | { | 
|---|
| 882 | if ( d->deref() ) { | 
|---|
| 883 | if ( d != shared_null ) | 
|---|
| 884 | d->deleteSelf(); | 
|---|
| 885 | } | 
|---|
| 886 | } | 
|---|
| 887 |  | 
|---|
| 888 | // needed for QDeepCopy | 
|---|
| 889 | inline void QString::detach() | 
|---|
| 890 | { real_detach(); } | 
|---|
| 891 |  | 
|---|
| 892 | inline QString QString::section( QChar sep, int start, int end, int flags ) const | 
|---|
| 893 | { return section(QString(sep), start, end, flags); } | 
|---|
| 894 |  | 
|---|
| 895 | inline 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 | 
|---|
| 899 | inline 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 |  | 
|---|
| 903 | inline QString &QString::operator=( QChar c ) | 
|---|
| 904 | { *this = QString(c); return *this; } | 
|---|
| 905 |  | 
|---|
| 906 | inline QString &QString::operator=( char c ) | 
|---|
| 907 | { *this = QString(QChar(c)); return *this; } | 
|---|
| 908 |  | 
|---|
| 909 | inline bool QString::isNull() const | 
|---|
| 910 | { return unicode() == 0; } | 
|---|
| 911 |  | 
|---|
| 912 | inline bool QString::operator!() const | 
|---|
| 913 | { return isNull(); } | 
|---|
| 914 |  | 
|---|
| 915 | inline uint QString::length() const | 
|---|
| 916 | { return d->len; } | 
|---|
| 917 |  | 
|---|
| 918 | inline uint QString::capacity() const | 
|---|
| 919 | { return d->maxl; } | 
|---|
| 920 |  | 
|---|
| 921 | inline bool QString::isEmpty() const | 
|---|
| 922 | { return length() == 0; } | 
|---|
| 923 |  | 
|---|
| 924 | inline QString QString::copy() const | 
|---|
| 925 | { return QString( *this ); } | 
|---|
| 926 |  | 
|---|
| 927 | #ifndef QT_NO_CAST_ASCII | 
|---|
| 928 | inline QString &QString::insert( uint index, const char *s ) | 
|---|
| 929 | { return insertHelper( index, s ); } | 
|---|
| 930 |  | 
|---|
| 931 | inline QString &QString::insert( uint index, const QByteArray &s ) | 
|---|
| 932 | { | 
|---|
| 933 | int pos = s.find( 0 ); | 
|---|
| 934 | return insertHelper( index, s, pos==-1 ? s.size() : pos ); | 
|---|
| 935 | } | 
|---|
| 936 | #endif | 
|---|
| 937 |  | 
|---|
| 938 | inline QString &QString::prepend( const QString & s ) | 
|---|
| 939 | { return insert(0,s); } | 
|---|
| 940 |  | 
|---|
| 941 | inline QString &QString::prepend( QChar c ) | 
|---|
| 942 | { return insert(0,c); } | 
|---|
| 943 |  | 
|---|
| 944 | inline QString &QString::prepend( char c ) | 
|---|
| 945 | { return insert(0,c); } | 
|---|
| 946 |  | 
|---|
| 947 | #ifndef QT_NO_CAST_ASCII | 
|---|
| 948 | inline QString &QString::prepend( const QByteArray & s ) | 
|---|
| 949 | { return insert(0,s); } | 
|---|
| 950 | #endif | 
|---|
| 951 |  | 
|---|
| 952 | #ifndef QT_NO_CAST_ASCII | 
|---|
| 953 | inline QString &QString::operator+=( const QByteArray &s ) | 
|---|
| 954 | { | 
|---|
| 955 | int pos = s.find( 0 ); | 
|---|
| 956 | return operatorPlusEqHelper( s, pos==-1 ? s.size() : pos ); | 
|---|
| 957 | } | 
|---|
| 958 | #endif | 
|---|
| 959 |  | 
|---|
| 960 | inline QString &QString::append( const QString & s ) | 
|---|
| 961 | { return operator+=(s); } | 
|---|
| 962 |  | 
|---|
| 963 | #ifndef QT_NO_CAST_ASCII | 
|---|
| 964 | inline QString &QString::append( const QByteArray &s ) | 
|---|
| 965 | { return operator+=(s); } | 
|---|
| 966 |  | 
|---|
| 967 | inline QString &QString::append( const char * s ) | 
|---|
| 968 | { return operator+=(s); } | 
|---|
| 969 | #endif | 
|---|
| 970 |  | 
|---|
| 971 | inline QString &QString::append( QChar c ) | 
|---|
| 972 | { return operator+=(c); } | 
|---|
| 973 |  | 
|---|
| 974 | inline QString &QString::append( char c ) | 
|---|
| 975 | { return operator+=(c); } | 
|---|
| 976 |  | 
|---|
| 977 | #ifndef QT_NO_STL | 
|---|
| 978 | inline QString &QString::operator=( const std::string& str ) | 
|---|
| 979 | { return operator=(str.c_str()); } | 
|---|
| 980 | #ifndef QT_NO_CAST_ASCII | 
|---|
| 981 | inline QString &QString::operator+=( const std::string& s ) | 
|---|
| 982 | { return operator+=(s.c_str()); } | 
|---|
| 983 | inline QString &QString::append( const std::string& s ) | 
|---|
| 984 | { return operator+=(s); } | 
|---|
| 985 | inline QString &QString::prepend( const std::string& s ) | 
|---|
| 986 | { return insert(0, s); } | 
|---|
| 987 | #endif | 
|---|
| 988 | #endif | 
|---|
| 989 |  | 
|---|
| 990 | inline QString &QString::setNum( short n, int base ) | 
|---|
| 991 | { return setNum((Q_LLONG)n, base); } | 
|---|
| 992 |  | 
|---|
| 993 | inline QString &QString::setNum( ushort n, int base ) | 
|---|
| 994 | { return setNum((Q_ULLONG)n, base); } | 
|---|
| 995 |  | 
|---|
| 996 | inline QString &QString::setNum( int n, int base ) | 
|---|
| 997 | { return setNum((Q_LLONG)n, base); } | 
|---|
| 998 |  | 
|---|
| 999 | inline QString &QString::setNum( uint n, int base ) | 
|---|
| 1000 | { return setNum((Q_ULLONG)n, base); } | 
|---|
| 1001 |  | 
|---|
| 1002 | inline QString &QString::setNum( float n, char f, int prec ) | 
|---|
| 1003 | { return setNum((double)n,f,prec); } | 
|---|
| 1004 |  | 
|---|
| 1005 | inline QString QString::arg( int a, int fieldWidth, int base ) const | 
|---|
| 1006 | { return arg( (Q_LLONG)a, fieldWidth, base ); } | 
|---|
| 1007 |  | 
|---|
| 1008 | inline QString QString::arg( uint a, int fieldWidth, int base ) const | 
|---|
| 1009 | { return arg( (Q_ULLONG)a, fieldWidth, base ); } | 
|---|
| 1010 |  | 
|---|
| 1011 | inline QString QString::arg( short a, int fieldWidth, int base ) const | 
|---|
| 1012 | { return arg( (Q_LLONG)a, fieldWidth, base ); } | 
|---|
| 1013 |  | 
|---|
| 1014 | inline QString QString::arg( ushort a, int fieldWidth, int base ) const | 
|---|
| 1015 | { return arg( (Q_ULLONG)a, fieldWidth, base ); } | 
|---|
| 1016 |  | 
|---|
| 1017 | inline QString QString::arg( const QString& a1, const QString& a2 ) const { | 
|---|
| 1018 | return multiArg( 2, a1, a2 ); | 
|---|
| 1019 | } | 
|---|
| 1020 |  | 
|---|
| 1021 | inline QString QString::arg( const QString& a1, const QString& a2, | 
|---|
| 1022 | const QString& a3 ) const { | 
|---|
| 1023 | return multiArg( 3, a1, a2, a3 ); | 
|---|
| 1024 | } | 
|---|
| 1025 |  | 
|---|
| 1026 | inline QString QString::arg( const QString& a1, const QString& a2, | 
|---|
| 1027 | const QString& a3, const QString& a4 ) const { | 
|---|
| 1028 | return multiArg( 4, a1, a2, a3, a4 ); | 
|---|
| 1029 | } | 
|---|
| 1030 |  | 
|---|
| 1031 | inline int QString::find( char c, int index, bool cs ) const | 
|---|
| 1032 | { return find(QChar(c), index, cs); } | 
|---|
| 1033 |  | 
|---|
| 1034 | inline int QString::findRev( char c, int index, bool cs ) const | 
|---|
| 1035 | { return findRev( QChar(c), index, cs ); } | 
|---|
| 1036 |  | 
|---|
| 1037 | #ifndef QT_NO_CAST_ASCII | 
|---|
| 1038 | inline int QString::find( const char* str, int index ) const | 
|---|
| 1039 | { return find(QString::fromAscii(str), index); } | 
|---|
| 1040 |  | 
|---|
| 1041 | inline 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 |  | 
|---|
| 1050 | Q_EXPORT bool operator!=( const QString &s1, const QString &s2 ); | 
|---|
| 1051 | Q_EXPORT bool operator<( const QString &s1, const QString &s2 ); | 
|---|
| 1052 | Q_EXPORT bool operator<=( const QString &s1, const QString &s2 ); | 
|---|
| 1053 | Q_EXPORT bool operator==( const QString &s1, const QString &s2 ); | 
|---|
| 1054 | Q_EXPORT bool operator>( const QString &s1, const QString &s2 ); | 
|---|
| 1055 | Q_EXPORT bool operator>=( const QString &s1, const QString &s2 ); | 
|---|
| 1056 | #ifndef QT_NO_CAST_ASCII | 
|---|
| 1057 | Q_EXPORT bool operator!=( const QString &s1, const char *s2 ); | 
|---|
| 1058 | Q_EXPORT bool operator<( const QString &s1, const char *s2 ); | 
|---|
| 1059 | Q_EXPORT bool operator<=( const QString &s1, const char *s2 ); | 
|---|
| 1060 | Q_EXPORT bool operator==( const QString &s1, const char *s2 ); | 
|---|
| 1061 | Q_EXPORT bool operator>( const QString &s1, const char *s2 ); | 
|---|
| 1062 | Q_EXPORT bool operator>=( const QString &s1, const char *s2 ); | 
|---|
| 1063 | Q_EXPORT bool operator!=( const char *s1, const QString &s2 ); | 
|---|
| 1064 | Q_EXPORT bool operator<( const char *s1, const QString &s2 ); | 
|---|
| 1065 | Q_EXPORT bool operator<=( const char *s1, const QString &s2 ); | 
|---|
| 1066 | Q_EXPORT bool operator==( const char *s1, const QString &s2 ); | 
|---|
| 1067 | //Q_EXPORT bool operator>( const char *s1, const QString &s2 ); // MSVC++ | 
|---|
| 1068 | Q_EXPORT bool operator>=( const char *s1, const QString &s2 ); | 
|---|
| 1069 | #endif | 
|---|
| 1070 |  | 
|---|
| 1071 | Q_EXPORT inline const QString operator+( const QString &s1, const QString &s2 ) | 
|---|
| 1072 | { | 
|---|
| 1073 | QString tmp( s1 ); | 
|---|
| 1074 | tmp += s2; | 
|---|
| 1075 | return tmp; | 
|---|
| 1076 | } | 
|---|
| 1077 |  | 
|---|
| 1078 | #ifndef QT_NO_CAST_ASCII | 
|---|
| 1079 | Q_EXPORT inline const QString operator+( const QString &s1, const char *s2 ) | 
|---|
| 1080 | { | 
|---|
| 1081 | QString tmp( s1 ); | 
|---|
| 1082 | tmp += QString::fromAscii(s2); | 
|---|
| 1083 | return tmp; | 
|---|
| 1084 | } | 
|---|
| 1085 |  | 
|---|
| 1086 | Q_EXPORT inline const QString operator+( const char *s1, const QString &s2 ) | 
|---|
| 1087 | { | 
|---|
| 1088 | QString tmp = QString::fromAscii( s1 ); | 
|---|
| 1089 | tmp += s2; | 
|---|
| 1090 | return tmp; | 
|---|
| 1091 | } | 
|---|
| 1092 | #endif | 
|---|
| 1093 |  | 
|---|
| 1094 | Q_EXPORT inline const QString operator+( const QString &s1, QChar c2 ) | 
|---|
| 1095 | { | 
|---|
| 1096 | QString tmp( s1 ); | 
|---|
| 1097 | tmp += c2; | 
|---|
| 1098 | return tmp; | 
|---|
| 1099 | } | 
|---|
| 1100 |  | 
|---|
| 1101 | Q_EXPORT inline const QString operator+( const QString &s1, char c2 ) | 
|---|
| 1102 | { | 
|---|
| 1103 | QString tmp( s1 ); | 
|---|
| 1104 | tmp += c2; | 
|---|
| 1105 | return tmp; | 
|---|
| 1106 | } | 
|---|
| 1107 |  | 
|---|
| 1108 | Q_EXPORT inline const QString operator+( QChar c1, const QString &s2 ) | 
|---|
| 1109 | { | 
|---|
| 1110 | QString tmp; | 
|---|
| 1111 | tmp += c1; | 
|---|
| 1112 | tmp += s2; | 
|---|
| 1113 | return tmp; | 
|---|
| 1114 | } | 
|---|
| 1115 |  | 
|---|
| 1116 | Q_EXPORT inline const QString operator+( char c1, const QString &s2 ) | 
|---|
| 1117 | { | 
|---|
| 1118 | QString tmp; | 
|---|
| 1119 | tmp += c1; | 
|---|
| 1120 | tmp += s2; | 
|---|
| 1121 | return tmp; | 
|---|
| 1122 | } | 
|---|
| 1123 |  | 
|---|
| 1124 | #ifndef QT_NO_STL | 
|---|
| 1125 | Q_EXPORT inline const QString operator+(const QString& s1, const std::string& s2) | 
|---|
| 1126 | { | 
|---|
| 1127 | return s1 + QString(s2); | 
|---|
| 1128 | } | 
|---|
| 1129 |  | 
|---|
| 1130 | Q_EXPORT inline const QString operator+(const std::string& s1, const QString& s2) | 
|---|
| 1131 | { | 
|---|
| 1132 | QString tmp(s2); | 
|---|
| 1133 | return QString(tmp.prepend(s1)); | 
|---|
| 1134 | } | 
|---|
| 1135 | #endif | 
|---|
| 1136 |  | 
|---|
| 1137 |  | 
|---|
| 1138 | #if defined(Q_OS_WIN32) | 
|---|
| 1139 | extern Q_EXPORT QString qt_winQString(void*); | 
|---|
| 1140 | extern Q_EXPORT const void* qt_winTchar(const QString& str, bool addnul); | 
|---|
| 1141 | extern Q_EXPORT void* qt_winTchar_new(const QString& str); | 
|---|
| 1142 | extern Q_EXPORT QCString qt_winQString2MB( const QString& s, int len=-1 ); | 
|---|
| 1143 | extern 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 © 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> | 
|---|