-rw-r--r-- | qmake/include/qstring.h | 91 |
1 files changed, 66 insertions, 25 deletions
diff --git a/qmake/include/qstring.h b/qmake/include/qstring.h index 2a87a5a..c1d6740 100644 --- a/qmake/include/qstring.h +++ b/qmake/include/qstring.h | |||
@@ -1,93 +1,99 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Definition of the QString class, and related Unicode | 4 | ** Definition of the QString class, and related Unicode functions. |
5 | ** functions. | ||
6 | ** | 5 | ** |
7 | ** Created : 920609 | 6 | ** Created : 920609 |
8 | ** | 7 | ** |
9 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 8 | ** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. |
10 | ** | 9 | ** |
11 | ** This file is part of the tools module of the Qt GUI Toolkit. | 10 | ** This file is part of the tools module of the Qt GUI Toolkit. |
12 | ** | 11 | ** |
13 | ** This file may be distributed under the terms of the Q Public License | 12 | ** This file may be distributed under the terms of the Q Public License |
14 | ** as defined by Trolltech AS of Norway and appearing in the file | 13 | ** as defined by Trolltech AS of Norway and appearing in the file |
15 | ** LICENSE.QPL included in the packaging of this file. | 14 | ** LICENSE.QPL included in the packaging of this file. |
16 | ** | 15 | ** |
17 | ** This file may be distributed and/or modified under the terms of the | 16 | ** This file may be distributed and/or modified under the terms of the |
18 | ** GNU General Public License version 2 as published by the Free Software | 17 | ** GNU General Public License version 2 as published by the Free Software |
19 | ** Foundation and appearing in the file LICENSE.GPL included in the | 18 | ** Foundation and appearing in the file LICENSE.GPL included in the |
20 | ** packaging of this file. | 19 | ** packaging of this file. |
21 | ** | 20 | ** |
22 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition |
23 | ** licenses may use this file in accordance with the Qt Commercial License | 22 | ** licenses may use this file in accordance with the Qt Commercial License |
24 | ** Agreement provided with the Software. | 23 | ** Agreement provided with the Software. |
25 | ** | 24 | ** |
26 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
27 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
28 | ** | 27 | ** |
29 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
30 | ** information about Qt Commercial License Agreements. | 29 | ** information about Qt Commercial License Agreements. |
31 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
32 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
33 | ** | 32 | ** |
34 | ** Contact info@trolltech.com if any conditions of this licensing are | 33 | ** Contact info@trolltech.com if any conditions of this licensing are |
35 | ** not clear to you. | 34 | ** not clear to you. |
36 | ** | 35 | ** |
37 | **********************************************************************/ | 36 | **********************************************************************/ |
38 | 37 | ||
39 | #ifndef QSTRING_H | 38 | #ifndef QSTRING_H |
40 | #define QSTRING_H | 39 | #define QSTRING_H |
41 | 40 | ||
42 | #ifndef QT_H | 41 | #ifndef QT_H |
43 | #include "qcstring.h" | 42 | #include "qcstring.h" |
44 | #endif // QT_H | 43 | #endif // QT_H |
45 | 44 | ||
45 | #ifndef QT_NO_STL | ||
46 | #include <string> | ||
47 | #if defined(Q_WRONG_SB_CTYPE_MACROS) && defined(_SB_CTYPE_MACROS) | ||
48 | #undef _SB_CTYPE_MACROS | ||
49 | #endif | ||
50 | #endif | ||
51 | |||
46 | 52 | ||
47 | /***************************************************************************** | 53 | /***************************************************************************** |
48 | QString class | 54 | QString class |
49 | *****************************************************************************/ | 55 | *****************************************************************************/ |
50 | 56 | ||
51 | class QRegExp; | 57 | class QRegExp; |
52 | class QString; | 58 | class QString; |
53 | class QCharRef; | 59 | class QCharRef; |
54 | template <class T> class QDeepCopy; | 60 | template <class T> class QDeepCopy; |
55 | 61 | ||
56 | class Q_EXPORT QChar { | 62 | class Q_EXPORT QChar { |
57 | public: | 63 | public: |
58 | QChar(); | 64 | QChar(); |
59 | QChar( char c ); | 65 | QChar( char c ); |
60 | QChar( uchar c ); | 66 | QChar( uchar c ); |
61 | QChar( uchar c, uchar r ); | 67 | QChar( uchar c, uchar r ); |
62 | QChar( const QChar& c ); | 68 | QChar( const QChar& c ); |
63 | QChar( ushort rc ); | 69 | QChar( ushort rc ); |
64 | QChar( short rc ); | 70 | QChar( short rc ); |
65 | QChar( uint rc ); | 71 | QChar( uint rc ); |
66 | QChar( int rc ); | 72 | QChar( int rc ); |
67 | 73 | ||
68 | QT_STATIC_CONST QChar null; // 0000 | 74 | QT_STATIC_CONST QChar null; // 0000 |
69 | QT_STATIC_CONST QChar replacement; // FFFD | 75 | QT_STATIC_CONST QChar replacement; // FFFD |
70 | QT_STATIC_CONST QChar byteOrderMark; // FEFF | 76 | QT_STATIC_CONST QChar byteOrderMark; // FEFF |
71 | QT_STATIC_CONST QChar byteOrderSwapped; // FFFE | 77 | QT_STATIC_CONST QChar byteOrderSwapped; // FFFE |
72 | QT_STATIC_CONST QChar nbsp; // 00A0 | 78 | QT_STATIC_CONST QChar nbsp; // 00A0 |
73 | 79 | ||
74 | // Unicode information | 80 | // Unicode information |
75 | 81 | ||
76 | enum Category | 82 | enum Category |
77 | { | 83 | { |
78 | NoCategory, | 84 | NoCategory, |
79 | 85 | ||
80 | Mark_NonSpacing, // Mn | 86 | Mark_NonSpacing, // Mn |
81 | Mark_SpacingCombining, // Mc | 87 | Mark_SpacingCombining, // Mc |
82 | Mark_Enclosing, // Me | 88 | Mark_Enclosing, // Me |
83 | 89 | ||
84 | Number_DecimalDigit, // Nd | 90 | Number_DecimalDigit, // Nd |
85 | Number_Letter, // Nl | 91 | Number_Letter, // Nl |
86 | Number_Other, // No | 92 | Number_Other, // No |
87 | 93 | ||
88 | Separator_Space, // Zs | 94 | Separator_Space, // Zs |
89 | Separator_Line, // Zl | 95 | Separator_Line, // Zl |
90 | Separator_Paragraph, // Zp | 96 | Separator_Paragraph, // Zp |
91 | 97 | ||
92 | Other_Control, // Cc | 98 | Other_Control, // Cc |
93 | Other_Format, // Cf | 99 | Other_Format, // Cf |
@@ -291,149 +297,153 @@ inline bool operator==( QChar c, char ch ) | |||
291 | inline bool operator==( QChar c1, QChar c2 ) | 297 | inline bool operator==( QChar c1, QChar c2 ) |
292 | { | 298 | { |
293 | return c1.ucs == c2.ucs; | 299 | return c1.ucs == c2.ucs; |
294 | } | 300 | } |
295 | 301 | ||
296 | inline bool operator!=( QChar c1, QChar c2 ) | 302 | inline bool operator!=( QChar c1, QChar c2 ) |
297 | { | 303 | { |
298 | return c1.ucs != c2.ucs; | 304 | return c1.ucs != c2.ucs; |
299 | } | 305 | } |
300 | 306 | ||
301 | inline bool operator!=( char ch, QChar c ) | 307 | inline bool operator!=( char ch, QChar c ) |
302 | { | 308 | { |
303 | return ((uchar)ch) != c.ucs; | 309 | return ((uchar)ch) != c.ucs; |
304 | } | 310 | } |
305 | 311 | ||
306 | inline bool operator!=( QChar c, char ch ) | 312 | inline bool operator!=( QChar c, char ch ) |
307 | { | 313 | { |
308 | return ((uchar) ch) != c.ucs; | 314 | return ((uchar) ch) != c.ucs; |
309 | } | 315 | } |
310 | 316 | ||
311 | inline bool operator<=( QChar c, char ch ) | 317 | inline bool operator<=( QChar c, char ch ) |
312 | { | 318 | { |
313 | return c.ucs <= ((uchar) ch); | 319 | return c.ucs <= ((uchar) ch); |
314 | } | 320 | } |
315 | 321 | ||
316 | inline bool operator<=( char ch, QChar c ) | 322 | inline bool operator<=( char ch, QChar c ) |
317 | { | 323 | { |
318 | return ((uchar) ch) <= c.ucs; | 324 | return ((uchar) ch) <= c.ucs; |
319 | } | 325 | } |
320 | 326 | ||
321 | inline bool operator<=( QChar c1, QChar c2 ) | 327 | inline bool operator<=( QChar c1, QChar c2 ) |
322 | { | 328 | { |
323 | return c1.ucs <= c2.ucs; | 329 | return c1.ucs <= c2.ucs; |
324 | } | 330 | } |
325 | 331 | ||
326 | inline bool operator>=( QChar c, char ch ) { return ch <= c; } | 332 | inline bool operator>=( QChar c, char ch ) { return ch <= c; } |
327 | inline bool operator>=( char ch, QChar c ) { return c <= ch; } | 333 | inline bool operator>=( char ch, QChar c ) { return c <= ch; } |
328 | inline bool operator>=( QChar c1, QChar c2 ) { return c2 <= c1; } | 334 | inline bool operator>=( QChar c1, QChar c2 ) { return c2 <= c1; } |
329 | inline bool operator<( QChar c, char ch ) { return !(ch<=c); } | 335 | inline bool operator<( QChar c, char ch ) { return !(ch<=c); } |
330 | inline bool operator<( char ch, QChar c ) { return !(c<=ch); } | 336 | inline bool operator<( char ch, QChar c ) { return !(c<=ch); } |
331 | inline bool operator<( QChar c1, QChar c2 ) { return !(c2<=c1); } | 337 | inline bool operator<( QChar c1, QChar c2 ) { return !(c2<=c1); } |
332 | inline bool operator>( QChar c, char ch ) { return !(ch>=c); } | 338 | inline bool operator>( QChar c, char ch ) { return !(ch>=c); } |
333 | inline bool operator>( char ch, QChar c ) { return !(c>=ch); } | 339 | inline bool operator>( char ch, QChar c ) { return !(c>=ch); } |
334 | inline bool operator>( QChar c1, QChar c2 ) { return !(c2>=c1); } | 340 | inline bool operator>( QChar c1, QChar c2 ) { return !(c2>=c1); } |
335 | 341 | ||
336 | // internal | 342 | // internal |
337 | struct Q_EXPORT QStringData : public QShared { | 343 | struct Q_EXPORT QStringData : public QShared { |
338 | QStringData() : | 344 | QStringData() : |
339 | QShared(), unicode(0), ascii(0), len(0), simpletext(1), maxl(0), dirty(0) { ref(); } | 345 | QShared(), unicode(0), ascii(0), len(0), issimpletext(TRUE), maxl(0), islatin1(FALSE) { ref(); } |
340 | QStringData(QChar *u, uint l, uint m) : | 346 | QStringData(QChar *u, uint l, uint m) : |
341 | QShared(), unicode(u), ascii(0), len(l), simpletext(1), maxl(m), dirty(1) { } | 347 | QShared(), unicode(u), ascii(0), len(l), issimpletext(FALSE), maxl(m), islatin1(FALSE) { } |
342 | ~QStringData() { if ( unicode ) delete[] ((char*)unicode); | 348 | ~QStringData() { if ( unicode ) delete[] ((char*)unicode); |
343 | if ( ascii ) delete[] ascii; } | 349 | if ( ascii ) delete[] ascii; } |
344 | 350 | ||
345 | void deleteSelf(); | 351 | void deleteSelf(); |
346 | QChar *unicode; | 352 | QChar *unicode; |
347 | char *ascii; | 353 | char *ascii; |
348 | void setDirty() { | 354 | void setDirty() { |
349 | if ( ascii ) { | 355 | if ( ascii ) { |
350 | delete [] ascii; | 356 | delete [] ascii; |
351 | ascii = 0; | 357 | ascii = 0; |
352 | } | 358 | } |
353 | dirty = 1; | 359 | issimpletext = FALSE; |
354 | } | 360 | } |
355 | #ifdef Q_OS_MAC9 | 361 | #ifdef Q_OS_MAC9 |
356 | uint len; | 362 | uint len; |
357 | #else | 363 | #else |
358 | uint len : 30; | 364 | uint len : 30; |
359 | #endif | 365 | #endif |
360 | uint simpletext : 1; | 366 | uint issimpletext : 1; |
361 | #ifdef Q_OS_MAC9 | 367 | #ifdef Q_OS_MAC9 |
362 | uint maxl; | 368 | uint maxl; |
363 | #else | 369 | #else |
364 | uint maxl : 30; | 370 | uint maxl : 30; |
365 | #endif | 371 | #endif |
366 | uint dirty : 1; | 372 | uint islatin1 : 1; |
367 | 373 | ||
368 | private: | 374 | private: |
369 | #if defined(Q_DISABLE_COPY) | 375 | #if defined(Q_DISABLE_COPY) |
370 | QStringData( const QStringData& ); | 376 | QStringData( const QStringData& ); |
371 | QStringData& operator=( const QStringData& ); | 377 | QStringData& operator=( const QStringData& ); |
372 | #endif | 378 | #endif |
373 | }; | 379 | }; |
374 | 380 | ||
375 | 381 | ||
376 | class Q_EXPORT QString | 382 | class Q_EXPORT QString |
377 | { | 383 | { |
378 | public: | 384 | public: |
379 | QString(); // make null string | 385 | QString(); // make null string |
380 | QString( QChar ); // one-char string | 386 | QString( QChar ); // one-char string |
381 | QString( const QString & ); // impl-shared copy | 387 | QString( const QString & ); // impl-shared copy |
382 | QString( const QByteArray& ); // deep copy | 388 | QString( const QByteArray& ); // deep copy |
383 | QString( const QChar* unicode, uint length ); // deep copy | 389 | QString( const QChar* unicode, uint length ); // deep copy |
384 | #ifndef QT_NO_CAST_ASCII | 390 | #ifndef QT_NO_CAST_ASCII |
385 | QString( const char *str ); // deep copy | 391 | QString( const char *str ); // deep copy |
386 | #endif | 392 | #endif |
393 | #ifndef QT_NO_STL | ||
394 | QString( const std::string& ); // deep copy | ||
395 | #endif | ||
387 | ~QString(); | 396 | ~QString(); |
388 | 397 | ||
389 | QString &operator=( const QString & ); // impl-shared copy | 398 | QString &operator=( const QString & ); // impl-shared copy |
390 | #ifndef QT_NO_CAST_ASCII | ||
391 | QString &operator=( const char * ); // deep copy | 399 | QString &operator=( const char * ); // deep copy |
400 | #ifndef QT_NO_STL | ||
401 | QString &operator=( const std::string& ); // deep copy | ||
392 | #endif | 402 | #endif |
393 | QString &operator=( const QCString& ); // deep copy | 403 | QString &operator=( const QCString& ); // deep copy |
394 | QString &operator=( QChar c ); | 404 | QString &operator=( QChar c ); |
395 | QString &operator=( char c ); | 405 | QString &operator=( char c ); |
396 | 406 | ||
397 | QT_STATIC_CONST QString null; | 407 | QT_STATIC_CONST QString null; |
398 | 408 | ||
399 | bool isNull() const; | 409 | bool isNull() const; |
400 | bool isEmpty() const; | 410 | bool isEmpty() const; |
401 | uint length() const; | 411 | uint length() const; |
402 | void truncate( uint pos ); | 412 | void truncate( uint pos ); |
403 | 413 | ||
404 | QString & fill( QChar c, int len = -1 ); | 414 | QString & fill( QChar c, int len = -1 ); |
405 | 415 | ||
406 | QString copy() const; | 416 | QString copy() const; |
407 | 417 | ||
408 | QString arg( long a, int fieldwidth=0, int base=10 ) const; | 418 | QString arg( long a, int fieldwidth=0, int base=10 ) const; |
409 | QString arg( ulong a, int fieldwidth=0, int base=10 ) const; | 419 | QString arg( ulong a, int fieldwidth=0, int base=10 ) const; |
410 | QString arg( int a, int fieldwidth=0, int base=10 ) const; | 420 | QString arg( int a, int fieldwidth=0, int base=10 ) const; |
411 | QString arg( uint a, int fieldwidth=0, int base=10 ) const; | 421 | QString arg( uint a, int fieldwidth=0, int base=10 ) const; |
412 | QString arg( short a, int fieldwidth=0, int base=10 ) const; | 422 | QString arg( short a, int fieldwidth=0, int base=10 ) const; |
413 | QString arg( ushort a, int fieldwidth=0, int base=10 ) const; | 423 | QString arg( ushort a, int fieldwidth=0, int base=10 ) const; |
414 | QString arg( char a, int fieldwidth=0 ) const; | 424 | QString arg( char a, int fieldwidth=0 ) const; |
415 | QString arg( QChar a, int fieldwidth=0 ) const; | 425 | QString arg( QChar a, int fieldwidth=0 ) const; |
416 | QString arg( const QString& a, int fieldwidth=0 ) const; | 426 | QString arg( const QString& a, int fieldwidth=0 ) const; |
417 | QString arg( double a, int fieldwidth=0, char fmt='g', int prec=-1 ) const; | 427 | QString arg( double a, int fieldwidth=0, char fmt='g', int prec=-1 ) const; |
418 | 428 | ||
419 | #ifndef QT_NO_SPRINTF | 429 | #ifndef QT_NO_SPRINTF |
420 | QString &sprintf( const char* format, ... ) | 430 | QString &sprintf( const char* format, ... ) |
421 | #if defined(Q_CC_GNU) && !defined(__INSURE__) | 431 | #if defined(Q_CC_GNU) && !defined(__INSURE__) |
422 | __attribute__ ((format (printf, 2, 3))) | 432 | __attribute__ ((format (printf, 2, 3))) |
423 | #endif | 433 | #endif |
424 | ; | 434 | ; |
425 | #endif | 435 | #endif |
426 | 436 | ||
427 | int find( QChar c, int index=0, bool cs=TRUE ) const; | 437 | int find( QChar c, int index=0, bool cs=TRUE ) const; |
428 | int find( char c, int index=0, bool cs=TRUE ) const; | 438 | int find( char c, int index=0, bool cs=TRUE ) const; |
429 | int find( const QString &str, int index=0, bool cs=TRUE ) const; | 439 | int find( const QString &str, int index=0, bool cs=TRUE ) const; |
430 | #ifndef QT_NO_REGEXP | 440 | #ifndef QT_NO_REGEXP |
431 | int find( const QRegExp &, int index=0 ) const; | 441 | int find( const QRegExp &, int index=0 ) const; |
432 | #endif | 442 | #endif |
433 | #ifndef QT_NO_CAST_ASCII | 443 | #ifndef QT_NO_CAST_ASCII |
434 | int find( const char* str, int index=0 ) const; | 444 | int find( const char* str, int index=0 ) const; |
435 | #endif | 445 | #endif |
436 | int findRev( QChar c, int index=-1, bool cs=TRUE) const; | 446 | int findRev( QChar c, int index=-1, bool cs=TRUE) const; |
437 | int findRev( char c, int index=-1, bool cs=TRUE) const; | 447 | int findRev( char c, int index=-1, bool cs=TRUE) const; |
438 | int findRev( const QString &str, int index=-1, bool cs=TRUE) const; | 448 | int findRev( const QString &str, int index=-1, bool cs=TRUE) const; |
439 | #ifndef QT_NO_REGEXP | 449 | #ifndef QT_NO_REGEXP |
@@ -449,236 +459,251 @@ public: | |||
449 | int contains( const char* str, bool cs=TRUE ) const; | 459 | int contains( const char* str, bool cs=TRUE ) const; |
450 | #endif | 460 | #endif |
451 | int contains( const QString &str, bool cs=TRUE ) const; | 461 | int contains( const QString &str, bool cs=TRUE ) const; |
452 | #ifndef QT_NO_REGEXP | 462 | #ifndef QT_NO_REGEXP |
453 | int contains( const QRegExp & ) const; | 463 | int contains( const QRegExp & ) const; |
454 | #endif | 464 | #endif |
455 | 465 | ||
456 | enum SectionFlags { | 466 | enum SectionFlags { |
457 | SectionDefault = 0x00, | 467 | SectionDefault = 0x00, |
458 | SectionSkipEmpty = 0x01, | 468 | SectionSkipEmpty = 0x01, |
459 | SectionIncludeLeadingSep = 0x02, | 469 | SectionIncludeLeadingSep = 0x02, |
460 | SectionIncludeTrailingSep = 0x04, | 470 | SectionIncludeTrailingSep = 0x04, |
461 | SectionCaseInsensitiveSeps = 0x08 | 471 | SectionCaseInsensitiveSeps = 0x08 |
462 | }; | 472 | }; |
463 | QString section( QChar sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const; | 473 | QString section( QChar sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const; |
464 | QString section( char sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const; | 474 | QString section( char sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const; |
465 | #ifndef QT_NO_CAST_ASCII | 475 | #ifndef QT_NO_CAST_ASCII |
466 | QString section( const char *in_sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const; | 476 | QString section( const char *in_sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const; |
467 | #endif | 477 | #endif |
468 | QString section( const QString &in_sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const; | 478 | QString section( const QString &in_sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const; |
469 | #ifndef QT_NO_REGEXP | 479 | #ifndef QT_NO_REGEXP |
470 | QString section( const QRegExp ®, int start, int end = 0xffffffff, int flags = SectionDefault ) const; | 480 | QString section( const QRegExp ®, int start, int end = 0xffffffff, int flags = SectionDefault ) const; |
471 | #endif | 481 | #endif |
472 | 482 | ||
473 | QString left( uint len ) const; | 483 | QString left( uint len ) const; |
474 | QString right( uint len ) const; | 484 | QString right( uint len ) const; |
475 | QString mid( uint index, uint len=0xffffffff) const; | 485 | QString mid( uint index, uint len=0xffffffff) const; |
476 | 486 | ||
477 | QString leftJustify( uint width, QChar fill=' ', bool trunc=FALSE)const; | 487 | QString leftJustify( uint width, QChar fill=' ', bool trunc=FALSE)const; |
478 | QString rightJustify( uint width, QChar fill=' ',bool trunc=FALSE)const; | 488 | QString rightJustify( uint width, QChar fill=' ',bool trunc=FALSE)const; |
479 | 489 | ||
480 | QString lower() const; | 490 | QString lower() const; |
481 | QString upper() const; | 491 | QString upper() const; |
482 | 492 | ||
483 | QString stripWhiteSpace() const; | 493 | QString stripWhiteSpace() const; |
484 | QString simplifyWhiteSpace() const; | 494 | QString simplifyWhiteSpace() const; |
485 | 495 | ||
486 | QString &insert( uint index, const QString & ); | 496 | QString &insert( uint index, const QString & ); |
487 | QString &insert( uint index, const QChar*, uint len ); | 497 | QString &insert( uint index, const QChar*, uint len ); |
488 | QString &insert( uint index, QChar ); | 498 | QString &insert( uint index, QChar ); |
489 | QString &insert( uint index, char c ) { return insert(index,QChar(c)); } | 499 | QString &insert( uint index, char c ) { return insert(index,QChar(c)); } |
490 | QString &append( char ); | 500 | QString &append( char ); |
491 | QString &append( QChar ); | 501 | QString &append( QChar ); |
492 | QString &append( const QString & ); | 502 | QString &append( const QString & ); |
493 | #ifndef QT_NO_CAST_ASCII | 503 | #ifndef QT_NO_CAST_ASCII |
494 | QString &append( const QByteArray & ); | 504 | QString &append( const QByteArray & ); |
495 | QString &append( const char * ); | 505 | QString &append( const char * ); |
496 | #endif | 506 | #endif |
507 | #ifndef QT_NO_STL | ||
508 | QString &append( const std::string& ); | ||
509 | #endif | ||
497 | QString &prepend( char ); | 510 | QString &prepend( char ); |
498 | QString &prepend( QChar ); | 511 | QString &prepend( QChar ); |
499 | QString &prepend( const QString & ); | 512 | QString &prepend( const QString & ); |
500 | #ifndef QT_NO_CAST_ASCII | 513 | #ifndef QT_NO_CAST_ASCII |
501 | QString &prepend( const QByteArray & ); | 514 | QString &prepend( const QByteArray & ); |
502 | QString &prepend( const char * ); | 515 | QString &prepend( const char * ); |
503 | #endif | 516 | #endif |
517 | #ifndef QT_NO_STL | ||
518 | QString &prepend( const std::string& ); | ||
519 | #endif | ||
504 | QString &remove( uint index, uint len ); | 520 | QString &remove( uint index, uint len ); |
505 | QString &remove( QChar c ); | 521 | QString &remove( QChar c ); |
506 | QString &remove( char c ) { return remove( QChar(c) ); } | 522 | QString &remove( char c ) { return remove( QChar(c) ); } |
507 | QString &remove( const QString & ); | 523 | QString &remove( const QString & ); |
508 | #ifndef QT_NO_REGEXP | 524 | #ifndef QT_NO_REGEXP |
509 | QString &remove( const QRegExp & ); | 525 | QString &remove( const QRegExp & ); |
510 | #endif | 526 | #endif |
511 | #ifndef QT_NO_CAST_ASCII | 527 | #ifndef QT_NO_CAST_ASCII |
512 | QString &remove( const char * ); | 528 | QString &remove( const char * ); |
513 | #endif | 529 | #endif |
514 | QString &replace( uint index, uint len, const QString & ); | 530 | QString &replace( uint index, uint len, const QString & ); |
515 | QString &replace( uint index, uint len, const QChar*, uint clen ); | 531 | QString &replace( uint index, uint len, const QChar*, uint clen ); |
516 | QString &replace( uint index, uint len, QChar ); | 532 | QString &replace( uint index, uint len, QChar ); |
517 | QString &replace( uint index, uint len, char c ) | 533 | QString &replace( uint index, uint len, char c ) |
518 | { return replace( index, len, QChar(c) ); } | 534 | { return replace( index, len, QChar(c) ); } |
519 | QString &replace( QChar c, const QString & ); | 535 | QString &replace( QChar c, const QString & ); |
520 | QString &replace( char c, const QString & after ) | 536 | QString &replace( char c, const QString & after ) |
521 | { return replace( QChar(c), after ); } | 537 | { return replace( QChar(c), after ); } |
522 | QString &replace( const QString &, const QString & ); | 538 | QString &replace( const QString &, const QString & ); |
523 | #ifndef QT_NO_REGEXP_CAPTURE | 539 | #ifndef QT_NO_REGEXP_CAPTURE |
524 | QString &replace( const QRegExp &, const QString & ); | 540 | QString &replace( const QRegExp &, const QString & ); |
525 | #endif | 541 | #endif |
526 | QString &replace( QChar, QChar ); | 542 | QString &replace( QChar, QChar ); |
527 | 543 | ||
528 | short toShort( bool *ok=0, int base=10 ) const; | 544 | short toShort( bool *ok=0, int base=10 ) const; |
529 | ushort toUShort( bool *ok=0, int base=10 ) const; | 545 | ushort toUShort( bool *ok=0, int base=10 ) const; |
530 | int toInt( bool *ok=0, int base=10 ) const; | 546 | int toInt( bool *ok=0, int base=10 ) const; |
531 | uint toUInt( bool *ok=0, int base=10 ) const; | 547 | uint toUInt( bool *ok=0, int base=10 ) const; |
532 | long toLong( bool *ok=0, int base=10 ) const; | 548 | long toLong( bool *ok=0, int base=10 ) const; |
533 | ulong toULong( bool *ok=0, int base=10 ) const; | 549 | ulong toULong( bool *ok=0, int base=10 ) const; |
534 | float toFloat( bool *ok=0 ) const; | 550 | float toFloat( bool *ok=0 ) const; |
535 | double toDouble( bool *ok=0 ) const; | 551 | double toDouble( bool *ok=0 ) const; |
536 | 552 | ||
537 | QString &setNum( short, int base=10 ); | 553 | QString &setNum( short, int base=10 ); |
538 | QString &setNum( ushort, int base=10 ); | 554 | QString &setNum( ushort, int base=10 ); |
539 | QString &setNum( int, int base=10 ); | 555 | QString &setNum( int, int base=10 ); |
540 | QString &setNum( uint, int base=10 ); | 556 | QString &setNum( uint, int base=10 ); |
541 | QString &setNum( long, int base=10 ); | 557 | QString &setNum( long, int base=10 ); |
542 | QString &setNum( ulong, int base=10 ); | 558 | QString &setNum( ulong, int base=10 ); |
543 | QString &setNum( float, char f='g', int prec=6 ); | 559 | QString &setNum( float, char f='g', int prec=6 ); |
544 | QString &setNum( double, char f='g', int prec=6 ); | 560 | QString &setNum( double, char f='g', int prec=6 ); |
545 | 561 | ||
546 | static QString number( long, int base=10 ); | 562 | static QString number( long, int base=10 ); |
547 | static QString number( ulong, int base=10); | 563 | static QString number( ulong, int base=10); |
548 | static QString number( int, int base=10 ); | 564 | static QString number( int, int base=10 ); |
549 | static QString number( uint, int base=10); | 565 | static QString number( uint, int base=10); |
550 | static QString number( double, char f='g', int prec=6 ); | 566 | static QString number( double, char f='g', int prec=6 ); |
551 | 567 | ||
552 | void setExpand( uint index, QChar c ); | 568 | void setExpand( uint index, QChar c ); |
553 | 569 | ||
554 | QString &operator+=( const QString &str ); | 570 | QString &operator+=( const QString &str ); |
555 | #ifndef QT_NO_CAST_ASCII | 571 | #ifndef QT_NO_CAST_ASCII |
556 | QString &operator+=( const QByteArray &str ); | 572 | QString &operator+=( const QByteArray &str ); |
557 | QString &operator+=( const char *str ); | 573 | QString &operator+=( const char *str ); |
558 | #endif | 574 | #endif |
575 | #ifndef QT_NO_STL | ||
576 | QString &operator+=( const std::string& ); | ||
577 | #endif | ||
559 | QString &operator+=( QChar c ); | 578 | QString &operator+=( QChar c ); |
560 | QString &operator+=( char c ); | 579 | QString &operator+=( char c ); |
561 | 580 | ||
562 | QChar at( uint i ) const | 581 | QChar at( uint i ) const |
563 | { return i < d->len ? d->unicode[i] : QChar::null; } | 582 | { return i < d->len ? d->unicode[i] : QChar::null; } |
564 | QChar operator[]( int i ) const { return at((uint)i); } | 583 | QChar operator[]( int i ) const { return at((uint)i); } |
565 | QCharRef at( uint i ); | 584 | QCharRef at( uint i ); |
566 | QCharRef operator[]( int i ); | 585 | QCharRef operator[]( int i ); |
567 | 586 | ||
568 | QChar constref(uint i) const | 587 | QChar constref(uint i) const |
569 | { return at(i); } | 588 | { return at(i); } |
570 | QChar& ref(uint i) | 589 | QChar& ref(uint i) |
571 | { // Optimized for easy-inlining by simple compilers. | 590 | { // Optimized for easy-inlining by simple compilers. |
572 | if ( d->count != 1 || i >= d->len ) | 591 | if ( d->count != 1 || i >= d->len ) |
573 | subat( i ); | 592 | subat( i ); |
574 | d->setDirty(); | 593 | d->setDirty(); |
575 | return d->unicode[i]; | 594 | return d->unicode[i]; |
576 | } | 595 | } |
577 | 596 | ||
578 | const QChar* unicode() const { return d->unicode; } | 597 | const QChar* unicode() const { return d->unicode; } |
579 | const char* ascii() const { return latin1(); } | 598 | const char* ascii() const; |
599 | static QString fromAscii(const char*, int len=-1); | ||
580 | const char* latin1() const; | 600 | const char* latin1() const; |
581 | static QString fromLatin1(const char*, int len=-1); | 601 | static QString fromLatin1(const char*, int len=-1); |
582 | QCString utf8() const; | 602 | QCString utf8() const; |
583 | static QString fromUtf8(const char*, int len=-1); | 603 | static QString fromUtf8(const char*, int len=-1); |
584 | QCString local8Bit() const; | 604 | QCString local8Bit() const; |
585 | static QString fromLocal8Bit(const char*, int len=-1); | 605 | static QString fromLocal8Bit(const char*, int len=-1); |
586 | bool operator!() const; | 606 | bool operator!() const; |
587 | #ifndef QT_NO_ASCII_CAST | 607 | #ifndef QT_NO_ASCII_CAST |
588 | operator const char *() const { return latin1(); } | 608 | operator const char *() const { return ascii(); } |
589 | #endif | 609 | #endif |
610 | #ifndef QT_NO_STL | ||
611 | operator std::string() const { return ascii() ? ascii() : ""; } | ||
612 | #endif | ||
613 | |||
590 | static QString fromUcs2( const unsigned short *ucs2 ); | 614 | static QString fromUcs2( const unsigned short *ucs2 ); |
591 | const unsigned short *ucs2() const; | 615 | const unsigned short *ucs2() const; |
592 | 616 | ||
593 | QString &setUnicode( const QChar* unicode, uint len ); | 617 | QString &setUnicode( const QChar* unicode, uint len ); |
594 | QString &setUnicodeCodes( const ushort* unicode_as_ushorts, uint len ); | 618 | QString &setUnicodeCodes( const ushort* unicode_as_ushorts, uint len ); |
619 | QString &setAscii( const char*, int len=-1 ); | ||
595 | QString &setLatin1( const char*, int len=-1 ); | 620 | QString &setLatin1( const char*, int len=-1 ); |
596 | 621 | ||
597 | int compare( const QString& s ) const; | 622 | int compare( const QString& s ) const; |
598 | static int compare( const QString& s1, const QString& s2 ) | 623 | static int compare( const QString& s1, const QString& s2 ) |
599 | { return s1.compare( s2 ); } | 624 | { return s1.compare( s2 ); } |
600 | 625 | ||
601 | int localeAwareCompare( const QString& s ) const; | 626 | int localeAwareCompare( const QString& s ) const; |
602 | static int localeAwareCompare( const QString& s1, const QString& s2 ) | 627 | static int localeAwareCompare( const QString& s1, const QString& s2 ) |
603 | { return s1.localeAwareCompare( s2 ); } | 628 | { return s1.localeAwareCompare( s2 ); } |
604 | 629 | ||
605 | #ifndef QT_NO_DATASTREAM | 630 | #ifndef QT_NO_DATASTREAM |
606 | friend Q_EXPORT QDataStream &operator>>( QDataStream &, QString & ); | 631 | friend Q_EXPORT QDataStream &operator>>( QDataStream &, QString & ); |
607 | #endif | 632 | #endif |
608 | 633 | ||
609 | void compose(); | 634 | void compose(); |
610 | 635 | ||
611 | #ifndef QT_NO_COMPAT | 636 | #ifndef QT_NO_COMPAT |
612 | const char* data() const { return latin1(); } | 637 | const char* data() const { return ascii(); } |
613 | #endif | 638 | #endif |
614 | 639 | ||
615 | bool startsWith( const QString& ) const; | 640 | bool startsWith( const QString& ) const; |
616 | bool endsWith( const QString& ) const; | 641 | bool endsWith( const QString& ) const; |
617 | 642 | ||
618 | void setLength( uint newLength ); | 643 | void setLength( uint newLength ); |
619 | 644 | ||
620 | bool simpleText() const { if ( d->dirty ) checkSimpleText(); return (bool)d->simpletext; } | 645 | bool simpleText() const { if ( !d->issimpletext ) checkSimpleText(); return (bool)d->issimpletext; } |
621 | bool isRightToLeft() const; | 646 | bool isRightToLeft() const; |
622 | 647 | ||
623 | 648 | ||
624 | private: | 649 | private: |
625 | QString( int size, bool /* dummy */ );// allocate size incl. \0 | 650 | QString( int size, bool /* dummy */ );// allocate size incl. \0 |
626 | 651 | ||
627 | void deref(); | 652 | void deref(); |
628 | void real_detach(); | 653 | void real_detach(); |
629 | void subat( uint ); | 654 | void subat( uint ); |
630 | bool findArg(int& pos, int& len) const; | 655 | bool findArg(int& pos, int& len) const; |
631 | 656 | ||
632 | void checkSimpleText() const; | 657 | void checkSimpleText() const; |
633 | 658 | ||
634 | static QChar* asciiToUnicode( const char*, uint * len, uint maxlen=(uint)-1 ); | 659 | static QChar* latin1ToUnicode( const char*, uint * len, uint maxlen=(uint)-1 ); |
635 | static QChar* asciiToUnicode( const QByteArray&, uint * len ); | 660 | static QChar* latin1ToUnicode( const QByteArray&, uint * len ); |
636 | static char* unicodeToAscii( const QChar*, uint len ); | 661 | static char* unicodeToLatin1( const QChar*, uint len ); |
637 | 662 | ||
638 | QStringData *d; | 663 | QStringData *d; |
639 | static QStringData* shared_null; | 664 | static QStringData* shared_null; |
640 | static QStringData* makeSharedNull(); | 665 | static QStringData* makeSharedNull(); |
641 | 666 | ||
642 | friend class QConstString; | 667 | friend class QConstString; |
643 | friend class QTextStream; | 668 | friend class QTextStream; |
644 | QString( QStringData* dd, bool /* dummy */ ) : d(dd) { } | 669 | QString( QStringData* dd, bool /* dummy */ ) : d(dd) { } |
645 | 670 | ||
646 | // needed for QDeepCopy | 671 | // needed for QDeepCopy |
647 | void detach(); | 672 | void detach(); |
648 | friend class QDeepCopy<QString>; | 673 | friend class QDeepCopy<QString>; |
649 | }; | 674 | }; |
650 | 675 | ||
651 | class Q_EXPORT QCharRef { | 676 | class Q_EXPORT QCharRef { |
652 | friend class QString; | 677 | friend class QString; |
653 | QString& s; | 678 | QString& s; |
654 | uint p; | 679 | uint p; |
655 | QCharRef(QString* str, uint pos) : s(*str), p(pos) { } | 680 | QCharRef(QString* str, uint pos) : s(*str), p(pos) { } |
656 | 681 | ||
657 | public: | 682 | public: |
658 | // most QChar operations repeated here... | 683 | // most QChar operations repeated here... |
659 | 684 | ||
660 | // all this is not documented: We just say "like QChar" and let it be. | 685 | // all this is not documented: We just say "like QChar" and let it be. |
661 | #ifndef Q_QDOC | 686 | #ifndef Q_QDOC |
662 | ushort unicode() const { return s.constref(p).unicode(); } | 687 | ushort unicode() const { return s.constref(p).unicode(); } |
663 | char latin1() const { return s.constref(p).latin1(); } | 688 | char latin1() const { return s.constref(p).latin1(); } |
664 | 689 | ||
665 | // An operator= for each QChar cast constructor... | 690 | // An operator= for each QChar cast constructor... |
666 | QCharRef operator=(char c ) { s.ref(p)=c; return *this; } | 691 | QCharRef operator=(char c ) { s.ref(p)=c; return *this; } |
667 | QCharRef operator=(uchar c ) { s.ref(p)=c; return *this; } | 692 | QCharRef operator=(uchar c ) { s.ref(p)=c; return *this; } |
668 | QCharRef operator=(QChar c ) { s.ref(p)=c; return *this; } | 693 | QCharRef operator=(QChar c ) { s.ref(p)=c; return *this; } |
669 | QCharRef operator=(const QCharRef& c ) { s.ref(p)=c.unicode(); return *this; } | 694 | QCharRef operator=(const QCharRef& c ) { s.ref(p)=c.unicode(); return *this; } |
670 | QCharRef operator=(ushort rc ) { s.ref(p)=rc; return *this; } | 695 | QCharRef operator=(ushort rc ) { s.ref(p)=rc; return *this; } |
671 | QCharRef operator=(short rc ) { s.ref(p)=rc; return *this; } | 696 | QCharRef operator=(short rc ) { s.ref(p)=rc; return *this; } |
672 | QCharRef operator=(uint rc ) { s.ref(p)=rc; return *this; } | 697 | QCharRef operator=(uint rc ) { s.ref(p)=rc; return *this; } |
673 | QCharRef operator=(int rc ) { s.ref(p)=rc; return *this; } | 698 | QCharRef operator=(int rc ) { s.ref(p)=rc; return *this; } |
674 | 699 | ||
675 | operator QChar () const { return s.constref(p); } | 700 | operator QChar () const { return s.constref(p); } |
676 | 701 | ||
677 | // each function... | 702 | // each function... |
678 | bool isNull() const { return unicode()==0; } | 703 | bool isNull() const { return unicode()==0; } |
679 | bool isPrint() const { return s.constref(p).isPrint(); } | 704 | bool isPrint() const { return s.constref(p).isPrint(); } |
680 | bool isPunct() const { return s.constref(p).isPunct(); } | 705 | bool isPunct() const { return s.constref(p).isPunct(); } |
681 | bool isSpace() const { return s.constref(p).isSpace(); } | 706 | bool isSpace() const { return s.constref(p).isSpace(); } |
682 | bool isMark() const { return s.constref(p).isMark(); } | 707 | bool isMark() const { return s.constref(p).isMark(); } |
683 | bool isLetter() const { return s.constref(p).isLetter(); } | 708 | bool isLetter() const { return s.constref(p).isLetter(); } |
684 | bool isNumber() const { return s.constref(p).isNumber(); } | 709 | bool isNumber() const { return s.constref(p).isNumber(); } |
@@ -749,202 +774,218 @@ inline QString::~QString() | |||
749 | 774 | ||
750 | // needed for QDeepCopy | 775 | // needed for QDeepCopy |
751 | inline void QString::detach() | 776 | inline void QString::detach() |
752 | { real_detach(); } | 777 | { real_detach(); } |
753 | 778 | ||
754 | inline QString QString::section( QChar sep, int start, int end, int flags ) const | 779 | inline QString QString::section( QChar sep, int start, int end, int flags ) const |
755 | { return section(QString(sep), start, end, flags); } | 780 | { return section(QString(sep), start, end, flags); } |
756 | 781 | ||
757 | inline QString QString::section( char sep, int start, int end, int flags ) const | 782 | inline QString QString::section( char sep, int start, int end, int flags ) const |
758 | { return section(QChar(sep), start, end, flags); } | 783 | { return section(QChar(sep), start, end, flags); } |
759 | 784 | ||
760 | #ifndef QT_NO_CAST_ASCII | 785 | #ifndef QT_NO_CAST_ASCII |
761 | inline QString QString::section( const char *in_sep, int start, int end, int flags ) const | 786 | inline QString QString::section( const char *in_sep, int start, int end, int flags ) const |
762 | { return section(QString(in_sep), start, end, flags); } | 787 | { return section(QString(in_sep), start, end, flags); } |
763 | #endif | 788 | #endif |
764 | 789 | ||
765 | inline QString &QString::operator=( QChar c ) | 790 | inline QString &QString::operator=( QChar c ) |
766 | { *this = QString(c); return *this; } | 791 | { *this = QString(c); return *this; } |
767 | 792 | ||
768 | inline QString &QString::operator=( char c ) | 793 | inline QString &QString::operator=( char c ) |
769 | { *this = QString(QChar(c)); return *this; } | 794 | { *this = QString(QChar(c)); return *this; } |
770 | 795 | ||
771 | inline bool QString::isNull() const | 796 | inline bool QString::isNull() const |
772 | { return unicode() == 0; } | 797 | { return unicode() == 0; } |
773 | 798 | ||
774 | inline bool QString::operator!() const | 799 | inline bool QString::operator!() const |
775 | { return isNull(); } | 800 | { return isNull(); } |
776 | 801 | ||
777 | inline uint QString::length() const | 802 | inline uint QString::length() const |
778 | { return d->len; } | 803 | { return d->len; } |
779 | 804 | ||
780 | inline bool QString::isEmpty() const | 805 | inline bool QString::isEmpty() const |
781 | { return length() == 0; } | 806 | { return length() == 0; } |
782 | 807 | ||
783 | inline QString QString::copy() const | 808 | inline QString QString::copy() const |
784 | { return QString( *this ); } | 809 | { return QString( *this ); } |
785 | 810 | ||
786 | inline QString &QString::prepend( const QString & s ) | 811 | inline QString &QString::prepend( const QString & s ) |
787 | { return insert(0,s); } | 812 | { return insert(0,s); } |
788 | 813 | ||
789 | inline QString &QString::prepend( QChar c ) | 814 | inline QString &QString::prepend( QChar c ) |
790 | { return insert(0,c); } | 815 | { return insert(0,c); } |
791 | 816 | ||
792 | inline QString &QString::prepend( char c ) | 817 | inline QString &QString::prepend( char c ) |
793 | { return insert(0,c); } | 818 | { return insert(0,c); } |
794 | 819 | ||
795 | #ifndef QT_NO_CAST_ASCII | 820 | #ifndef QT_NO_CAST_ASCII |
796 | inline QString &QString::prepend( const QByteArray & s ) | 821 | inline QString &QString::prepend( const QByteArray & s ) |
797 | { return insert(0,s.data()); } | 822 | { return insert(0,QString(s)); } |
823 | #endif | ||
824 | |||
825 | #ifndef QT_NO_STL | ||
826 | inline QString &QString::prepend( const std::string& s ) | ||
827 | { return insert(0, s); } | ||
828 | #endif | ||
829 | |||
830 | #ifndef QT_NO_CAST_ASCII | ||
831 | inline QString &QString::operator+=( const QByteArray &s ) | ||
832 | { return operator+=(QString(s)); } | ||
798 | #endif | 833 | #endif |
799 | 834 | ||
800 | inline QString &QString::append( const QString & s ) | 835 | inline QString &QString::append( const QString & s ) |
801 | { return operator+=(s); } | 836 | { return operator+=(s); } |
802 | 837 | ||
803 | #ifndef QT_NO_CAST_ASCII | 838 | #ifndef QT_NO_CAST_ASCII |
804 | inline QString &QString::append( const QByteArray &s ) | 839 | inline QString &QString::append( const QByteArray &s ) |
805 | { return operator+=(s.data()); } | 840 | { return operator+=(s); } |
806 | 841 | ||
807 | inline QString &QString::append( const char * s ) | 842 | inline QString &QString::append( const char * s ) |
808 | { return operator+=(s); } | 843 | { return operator+=(s); } |
809 | #endif | 844 | #endif |
810 | 845 | ||
811 | inline QString &QString::append( QChar c ) | 846 | inline QString &QString::append( QChar c ) |
812 | { return operator+=(c); } | 847 | { return operator+=(c); } |
813 | 848 | ||
814 | inline QString &QString::append( char c ) | 849 | inline QString &QString::append( char c ) |
815 | { return operator+=(c); } | 850 | { return operator+=(c); } |
816 | 851 | ||
817 | #ifndef QT_NO_CAST_ASCII | 852 | #ifndef QT_NO_STL |
818 | inline QString &QString::operator+=( const QByteArray &s ) | 853 | inline QString &QString::operator+=( const std::string& s ) |
819 | { return operator+=(s.data()); } | 854 | { return operator+=(s.c_str()); } |
855 | inline QString &QString::append( const std::string& s ) | ||
856 | { return operator+=(s); } | ||
820 | #endif | 857 | #endif |
821 | 858 | ||
822 | inline QString &QString::setNum( short n, int base ) | 859 | inline QString &QString::setNum( short n, int base ) |
823 | { return setNum((long)n, base); } | 860 | { return setNum((long)n, base); } |
824 | 861 | ||
825 | inline QString &QString::setNum( ushort n, int base ) | 862 | inline QString &QString::setNum( ushort n, int base ) |
826 | { return setNum((ulong)n, base); } | 863 | { return setNum((ulong)n, base); } |
827 | 864 | ||
828 | inline QString &QString::setNum( int n, int base ) | 865 | inline QString &QString::setNum( int n, int base ) |
829 | { return setNum((long)n, base); } | 866 | { return setNum((long)n, base); } |
830 | 867 | ||
831 | inline QString &QString::setNum( uint n, int base ) | 868 | inline QString &QString::setNum( uint n, int base ) |
832 | { return setNum((ulong)n, base); } | 869 | { return setNum((ulong)n, base); } |
833 | 870 | ||
834 | inline QString &QString::setNum( float n, char f, int prec ) | 871 | inline QString &QString::setNum( float n, char f, int prec ) |
835 | { return setNum((double)n,f,prec); } | 872 | { return setNum((double)n,f,prec); } |
836 | 873 | ||
837 | inline QString QString::arg(int a, int fieldwidth, int base) const | 874 | inline QString QString::arg(int a, int fieldwidth, int base) const |
838 | { return arg((long)a, fieldwidth, base); } | 875 | { return arg((long)a, fieldwidth, base); } |
839 | 876 | ||
840 | inline QString QString::arg(uint a, int fieldwidth, int base) const | 877 | inline QString QString::arg(uint a, int fieldwidth, int base) const |
841 | { return arg((ulong)a, fieldwidth, base); } | 878 | { return arg((ulong)a, fieldwidth, base); } |
842 | 879 | ||
843 | inline QString QString::arg(short a, int fieldwidth, int base) const | 880 | inline QString QString::arg(short a, int fieldwidth, int base) const |
844 | { return arg((long)a, fieldwidth, base); } | 881 | { return arg((long)a, fieldwidth, base); } |
845 | 882 | ||
846 | inline QString QString::arg(ushort a, int fieldwidth, int base) const | 883 | inline QString QString::arg(ushort a, int fieldwidth, int base) const |
847 | { return arg((ulong)a, fieldwidth, base); } | 884 | { return arg((ulong)a, fieldwidth, base); } |
848 | 885 | ||
849 | inline int QString::find( char c, int index, bool cs ) const | 886 | inline int QString::find( char c, int index, bool cs ) const |
850 | { return find(QChar(c), index, cs); } | 887 | { return find(QChar(c), index, cs); } |
851 | 888 | ||
852 | inline int QString::findRev( char c, int index, bool cs) const | 889 | inline int QString::findRev( char c, int index, bool cs) const |
853 | { return findRev( QChar(c), index, cs ); } | 890 | { return findRev( QChar(c), index, cs ); } |
854 | 891 | ||
855 | #ifndef QT_NO_CAST_ASCII | 892 | #ifndef QT_NO_CAST_ASCII |
856 | inline int QString::find( const char* str, int index ) const | 893 | inline int QString::find( const char* str, int index ) const |
857 | { return find(QString::fromLatin1(str), index); } | 894 | { return find(QString::fromAscii(str), index); } |
858 | 895 | ||
859 | inline int QString::findRev( const char* str, int index ) const | 896 | inline int QString::findRev( const char* str, int index ) const |
860 | { return findRev(QString::fromLatin1(str), index); } | 897 | { return findRev(QString::fromAscii(str), index); } |
861 | #endif | 898 | #endif |
862 | 899 | ||
863 | 900 | ||
864 | /***************************************************************************** | 901 | /***************************************************************************** |
865 | QString non-member operators | 902 | QString non-member operators |
866 | *****************************************************************************/ | 903 | *****************************************************************************/ |
867 | 904 | ||
868 | Q_EXPORT bool operator!=( const QString &s1, const QString &s2 ); | 905 | Q_EXPORT bool operator!=( const QString &s1, const QString &s2 ); |
869 | Q_EXPORT bool operator<( const QString &s1, const QString &s2 ); | 906 | Q_EXPORT bool operator<( const QString &s1, const QString &s2 ); |
870 | Q_EXPORT bool operator<=( const QString &s1, const QString &s2 ); | 907 | Q_EXPORT bool operator<=( const QString &s1, const QString &s2 ); |
871 | Q_EXPORT bool operator==( const QString &s1, const QString &s2 ); | 908 | Q_EXPORT bool operator==( const QString &s1, const QString &s2 ); |
872 | Q_EXPORT bool operator>( const QString &s1, const QString &s2 ); | 909 | Q_EXPORT bool operator>( const QString &s1, const QString &s2 ); |
873 | Q_EXPORT bool operator>=( const QString &s1, const QString &s2 ); | 910 | Q_EXPORT bool operator>=( const QString &s1, const QString &s2 ); |
874 | #ifndef QT_NO_CAST_ASCII | 911 | #ifndef QT_NO_CAST_ASCII |
875 | Q_EXPORT bool operator!=( const QString &s1, const char *s2 ); | 912 | Q_EXPORT bool operator!=( const QString &s1, const char *s2 ); |
876 | Q_EXPORT bool operator<( const QString &s1, const char *s2 ); | 913 | Q_EXPORT bool operator<( const QString &s1, const char *s2 ); |
877 | Q_EXPORT bool operator<=( const QString &s1, const char *s2 ); | 914 | Q_EXPORT bool operator<=( const QString &s1, const char *s2 ); |
878 | Q_EXPORT bool operator==( const QString &s1, const char *s2 ); | 915 | Q_EXPORT bool operator==( const QString &s1, const char *s2 ); |
879 | Q_EXPORT bool operator>( const QString &s1, const char *s2 ); | 916 | Q_EXPORT bool operator>( const QString &s1, const char *s2 ); |
880 | Q_EXPORT bool operator>=( const QString &s1, const char *s2 ); | 917 | Q_EXPORT bool operator>=( const QString &s1, const char *s2 ); |
881 | Q_EXPORT bool operator!=( const char *s1, const QString &s2 ); | 918 | Q_EXPORT bool operator!=( const char *s1, const QString &s2 ); |
882 | Q_EXPORT bool operator<( const char *s1, const QString &s2 ); | 919 | Q_EXPORT bool operator<( const char *s1, const QString &s2 ); |
883 | Q_EXPORT bool operator<=( const char *s1, const QString &s2 ); | 920 | Q_EXPORT bool operator<=( const char *s1, const QString &s2 ); |
884 | Q_EXPORT bool operator==( const char *s1, const QString &s2 ); | 921 | Q_EXPORT bool operator==( const char *s1, const QString &s2 ); |
885 | //Q_EXPORT bool operator>( const char *s1, const QString &s2 ); // MSVC++ | 922 | //Q_EXPORT bool operator>( const char *s1, const QString &s2 ); // MSVC++ |
886 | Q_EXPORT bool operator>=( const char *s1, const QString &s2 ); | 923 | Q_EXPORT bool operator>=( const char *s1, const QString &s2 ); |
887 | #endif | 924 | #endif |
888 | 925 | ||
889 | Q_EXPORT inline const QString operator+( const QString &s1, const QString &s2 ) | 926 | Q_EXPORT inline const QString operator+( const QString &s1, const QString &s2 ) |
890 | { | 927 | { |
891 | QString tmp( s1 ); | 928 | QString tmp( s1 ); |
892 | tmp += s2; | 929 | tmp += s2; |
893 | return tmp; | 930 | return tmp; |
894 | } | 931 | } |
895 | 932 | ||
896 | #ifndef QT_NO_CAST_ASCII | 933 | #ifndef QT_NO_CAST_ASCII |
897 | Q_EXPORT inline const QString operator+( const QString &s1, const char *s2 ) | 934 | Q_EXPORT inline const QString operator+( const QString &s1, const char *s2 ) |
898 | { | 935 | { |
899 | QString tmp( s1 ); | 936 | QString tmp( s1 ); |
900 | tmp += QString::fromLatin1(s2); | 937 | tmp += QString::fromAscii(s2); |
901 | return tmp; | 938 | return tmp; |
902 | } | 939 | } |
903 | 940 | ||
904 | Q_EXPORT inline const QString operator+( const char *s1, const QString &s2 ) | 941 | Q_EXPORT inline const QString operator+( const char *s1, const QString &s2 ) |
905 | { | 942 | { |
906 | QString tmp = QString::fromLatin1( s1 ); | 943 | QString tmp = QString::fromAscii( s1 ); |
907 | tmp += s2; | 944 | tmp += s2; |
908 | return tmp; | 945 | return tmp; |
909 | } | 946 | } |
910 | #endif | 947 | #endif |
911 | 948 | ||
912 | Q_EXPORT inline const QString operator+( const QString &s1, QChar c2 ) | 949 | Q_EXPORT inline const QString operator+( const QString &s1, QChar c2 ) |
913 | { | 950 | { |
914 | QString tmp( s1 ); | 951 | QString tmp( s1 ); |
915 | tmp += c2; | 952 | tmp += c2; |
916 | return tmp; | 953 | return tmp; |
917 | } | 954 | } |
918 | 955 | ||
919 | Q_EXPORT inline const QString operator+( const QString &s1, char c2 ) | 956 | Q_EXPORT inline const QString operator+( const QString &s1, char c2 ) |
920 | { | 957 | { |
921 | QString tmp( s1 ); | 958 | QString tmp( s1 ); |
922 | tmp += c2; | 959 | tmp += c2; |
923 | return tmp; | 960 | return tmp; |
924 | } | 961 | } |
925 | 962 | ||
926 | Q_EXPORT inline const QString operator+( QChar c1, const QString &s2 ) | 963 | Q_EXPORT inline const QString operator+( QChar c1, const QString &s2 ) |
927 | { | 964 | { |
928 | QString tmp; | 965 | QString tmp; |
929 | tmp += c1; | 966 | tmp += c1; |
930 | tmp += s2; | 967 | tmp += s2; |
931 | return tmp; | 968 | return tmp; |
932 | } | 969 | } |
933 | 970 | ||
934 | Q_EXPORT inline const QString operator+( char c1, const QString &s2 ) | 971 | Q_EXPORT inline const QString operator+( char c1, const QString &s2 ) |
935 | { | 972 | { |
936 | QString tmp; | 973 | QString tmp; |
937 | tmp += c1; | 974 | tmp += c1; |
938 | tmp += s2; | 975 | tmp += s2; |
939 | return tmp; | 976 | return tmp; |
940 | } | 977 | } |
941 | 978 | ||
942 | #if defined(Q_OS_WIN32) | 979 | #if defined(Q_OS_WIN32) |
943 | extern Q_EXPORT QString qt_winQString(void*); | 980 | extern Q_EXPORT QString qt_winQString(void*); |
944 | extern Q_EXPORT const void* qt_winTchar(const QString& str, bool addnul); | 981 | extern Q_EXPORT const void* qt_winTchar(const QString& str, bool addnul); |
945 | extern Q_EXPORT void* qt_winTchar_new(const QString& str); | 982 | extern Q_EXPORT void* qt_winTchar_new(const QString& str); |
946 | extern Q_EXPORT QCString qt_winQString2MB( const QString& s, int len=-1 ); | 983 | extern Q_EXPORT QCString qt_winQString2MB( const QString& s, int len=-1 ); |
947 | extern Q_EXPORT QString qt_winMB2QString( const char* mb, int len=-1 ); | 984 | extern Q_EXPORT QString qt_winMB2QString( const char* mb, int len=-1 ); |
948 | #endif | 985 | #endif |
949 | 986 | ||
987 | #ifdef QT_QWINEXPORT | ||
988 | #define Q_DEFINED_QSTRING | ||
989 | #include "qwinexport.h" | ||
990 | #endif /* QT_QWINEXPORT */ | ||
950 | #endif // QSTRING_H | 991 | #endif // QSTRING_H |