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