author | llornkcor <llornkcor> | 2003-07-10 02:40:10 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-07-10 02:40:10 (UTC) |
commit | 155d68c1e7d7dc0fed2534ac43d6d77ce2781f55 (patch) (unidiff) | |
tree | e6edaa5a7040fe6c224c3943d1094dcf02e4f74c /qmake/include/qstring.h | |
parent | 86703e8a5527ef114facd02c005b6b3a7e62e263 (diff) | |
download | opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.zip opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.gz opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.bz2 |
update qmake to 1.05a
-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,12 +1,11 @@ | |||
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 | ** |
@@ -43,6 +42,13 @@ | |||
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 |
@@ -336,9 +342,9 @@ inline bool operator>( QChar c1, QChar c2 ) { return !(c2>=c1); } | |||
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 | ||
@@ -350,20 +356,20 @@ struct Q_EXPORT QStringData : public QShared { | |||
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) |
@@ -384,11 +390,15 @@ public: | |||
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 ); |
@@ -494,6 +504,9 @@ public: | |||
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 & ); |
@@ -501,6 +514,9 @@ public: | |||
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) ); } |
@@ -556,6 +572,9 @@ public: | |||
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 | ||
@@ -576,7 +595,8 @@ public: | |||
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; |
@@ -585,13 +605,18 @@ public: | |||
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(); } |
609 | #endif | ||
610 | #ifndef QT_NO_STL | ||
611 | operator std::string() const { return ascii() ? ascii() : ""; } | ||
589 | #endif | 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; |
@@ -609,7 +634,7 @@ public: | |||
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; |
@@ -617,7 +642,7 @@ public: | |||
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 | ||
@@ -631,9 +656,9 @@ private: | |||
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; |
@@ -794,7 +819,17 @@ inline QString &QString::prepend( char 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 ) |
@@ -802,7 +837,7 @@ inline QString &QString::append( const QString & 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); } |
@@ -814,9 +849,11 @@ inline QString &QString::append( QChar c ) | |||
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 ) |
@@ -854,10 +891,10 @@ inline int QString::findRev( char c, int index, bool cs) const | |||
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 | ||
@@ -897,13 +934,13 @@ Q_EXPORT inline const QString operator+( const QString &s1, const QString &s2 ) | |||
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 | } |
@@ -947,4 +984,8 @@ 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 |