src/corelib/tools/qstring.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.
00004 **
00005 ** This file is part of the QtCore module of the Qt Toolkit.
00006 **
00007 ** This file may be used under the terms of the GNU General Public
00008 ** License version 2.0 as published by the Free Software Foundation
00009 ** and appearing in the file LICENSE.GPL included in the packaging of
00010 ** this file.  Please review the following information to ensure GNU
00011 ** General Public Licensing requirements will be met:
00012 ** http://www.trolltech.com/products/qt/opensource.html
00013 **
00014 ** If you are unsure which license is appropriate for your use, please
00015 ** review the following information:
00016 ** http://www.trolltech.com/products/qt/licensing.html or contact the
00017 ** sales department at sales@trolltech.com.
00018 **
00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021 **
00022 ****************************************************************************/
00023 
00024 #ifndef QSTRING_H
00025 #define QSTRING_H
00026 
00027 #include <QtCore/qchar.h>
00028 #include <QtCore/qbytearray.h>
00029 #include <QtCore/qatomic.h>
00030 #include <QtCore/qnamespace.h>
00031 #ifdef QT_INCLUDE_COMPAT
00032 #include <Qt3Support/q3cstring.h>
00033 #endif
00034 
00035 #ifndef QT_NO_STL
00036 #  if defined (Q_CC_MSVC_NET) && _MSC_VER < 1310 // Avoids nasty warning for xlocale, line 450
00037 #    pragma warning (push)
00038 #    pragma warning (disable : 4189)
00039 #    include <string>
00040 #    pragma warning (pop)
00041 #  else
00042 #    include <string>
00043 #  endif
00044 
00045 #  ifndef QT_NO_STL_WCHAR
00046 // workaround for some headers not typedef'ing std::wstring
00047 typedef std::basic_string<wchar_t> QStdWString;
00048 #  endif // QT_NO_STL_WCHAR
00049 
00050 #endif // QT_NO_STL
00051 
00052 #include <stdarg.h>
00053 
00054 #ifdef truncate
00055 #error qstring.h must be included before any header file that defines truncate
00056 #endif
00057 
00058 QT_BEGIN_HEADER
00059 
00060 QT_MODULE(Core)
00061 
00062 class QCharRef;
00063 class QRegExp;
00064 class QStringList;
00065 class QTextCodec;
00066 class QLatin1String;
00067 template <typename T> class QVector;
00068 
00069 class Q_CORE_EXPORT QString
00070 {
00071 public:
00072     inline QString();
00073     QString(const QChar *unicode, int size);
00074     QString(QChar c);
00075     QString(int size, QChar c);
00076     inline QString(const QLatin1String &latin1);
00077     inline QString(const QString &);
00078     inline ~QString();
00079     QString &operator=(QChar c);
00080     QString &operator=(const QString &);
00081     inline QString &operator=(const QLatin1String &);
00082 
00083     inline int size() const { return d->size; }
00084     inline int count() const { return d->size; }
00085     inline int length() const;
00086     inline bool isEmpty() const;
00087     void resize(int size);
00088 
00089     QString &fill(QChar c, int size = -1);
00090     void truncate(int pos);
00091     void chop(int n);
00092 
00093     int capacity() const;
00094     inline void reserve(int size);
00095     inline void squeeze() { if (d->size < d->alloc) realloc(); }
00096 
00097     inline const QChar *unicode() const;
00098     inline QChar *data();
00099     inline const QChar *data() const;
00100     inline const QChar *constData() const;
00101 
00102     inline void detach();
00103     inline bool isDetached() const;
00104     void clear();
00105 
00106     inline const QChar at(int i) const;
00107     const QChar operator[](int i) const;
00108     QCharRef operator[](int i);
00109     const QChar operator[](uint i) const;
00110     QCharRef operator[](uint i);
00111 
00112     QString arg(qlonglong a, int fieldwidth=0, int base=10,
00113                 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
00114     QString arg(qulonglong a, int fieldwidth=0, int base=10,
00115                 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
00116     QString arg(long a, int fieldwidth=0, int base=10,
00117                 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
00118     QString arg(ulong a, int fieldwidth=0, int base=10,
00119                 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
00120     QString arg(int a, int fieldWidth = 0, int base = 10,
00121                 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
00122     QString arg(uint a, int fieldWidth = 0, int base = 10,
00123                 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
00124     QString arg(short a, int fieldWidth = 0, int base = 10,
00125                 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
00126     QString arg(ushort a, int fieldWidth = 0, int base = 10,
00127                 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
00128     QString arg(double a, int fieldWidth = 0, char fmt = 'g', int prec = -1,
00129                 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
00130     QString arg(char a, int fieldWidth = 0,
00131                 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
00132     QString arg(QChar a, int fieldWidth = 0,
00133                 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
00134     QString arg(const QString &a, int fieldWidth = 0,
00135                 const QChar &fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
00136     QString arg(const QString &a1, const QString &a2) const Q_REQUIRED_RESULT;
00137     QString arg(const QString &a1, const QString &a2, const QString &a3) const Q_REQUIRED_RESULT;
00138     QString arg(const QString &a1, const QString &a2, const QString &a3,
00139                 const QString &a4) const Q_REQUIRED_RESULT;
00140 
00141     QString    &vsprintf(const char *format, va_list ap);
00142     QString    &sprintf(const char *format, ...)
00143 #if defined(Q_CC_GNU) && !defined(__INSURE__)
00144         __attribute__ ((format (printf, 2, 3)))
00145 #endif
00146         ;
00147 
00148     int indexOf(QChar c, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
00149     int indexOf(const QString &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
00150     int lastIndexOf(QChar c, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
00151     int lastIndexOf(const QString &s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
00152 
00153     inline QBool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
00154     inline QBool contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
00155     int count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
00156     int count(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
00157 
00158 #ifndef QT_NO_REGEXP
00159     int indexOf(const QRegExp &, int from = 0) const;
00160     int lastIndexOf(const QRegExp &, int from = -1) const;
00161     inline QBool contains(const QRegExp &rx) const { return QBool(indexOf(rx) != -1); }
00162     int count(const QRegExp &) const;
00163 #endif
00164 
00165     enum SectionFlag {
00166         SectionDefault             = 0x00,
00167         SectionSkipEmpty           = 0x01,
00168         SectionIncludeLeadingSep   = 0x02,
00169         SectionIncludeTrailingSep  = 0x04,
00170         SectionCaseInsensitiveSeps = 0x08
00171     };
00172     Q_DECLARE_FLAGS(SectionFlags, SectionFlag)
00173 
00174     QString section(QChar sep, int start, int end = -1, SectionFlags flags = SectionDefault) const;
00175     QString section(const QString &in_sep, int start, int end = -1, SectionFlags flags = SectionDefault) const;
00176 #ifndef QT_NO_REGEXP
00177     QString section(const QRegExp &reg, int start, int end = -1, SectionFlags flags = SectionDefault) const;
00178 #endif
00179 
00180     QString left(int len) const Q_REQUIRED_RESULT;
00181     QString right(int len) const Q_REQUIRED_RESULT;
00182     QString mid(int i, int len = -1) const Q_REQUIRED_RESULT;
00183 
00184     bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
00185     bool startsWith(const QLatin1String &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
00186     bool startsWith(const QChar &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
00187     bool endsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
00188     bool endsWith(const QLatin1String &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
00189     bool endsWith(const QChar &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
00190 
00191     QString leftJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const Q_REQUIRED_RESULT;
00192     QString rightJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const Q_REQUIRED_RESULT;
00193 
00194     QString toLower() const Q_REQUIRED_RESULT;
00195     QString toUpper() const Q_REQUIRED_RESULT;
00196 
00197     QString trimmed() const Q_REQUIRED_RESULT;
00198     QString simplified() const Q_REQUIRED_RESULT;
00199 
00200     QString &insert(int i, QChar c);
00201     QString &insert(int i, const QChar *uc, int len);
00202     inline QString &insert(int i, const QString &s) { return insert(i, s.constData(), s.length()); }
00203     QString &insert(int i, const QLatin1String &s);
00204     QString &append(QChar c);
00205     QString &append(const QString &s);
00206     QString &append(const QLatin1String &s);
00207     inline QString &prepend(QChar c) { return insert(0, c); }
00208     inline QString &prepend(const QString &s) { return insert(0, s); }
00209     inline QString &prepend(const QLatin1String &s) { return insert(0, s); }
00210     inline QString &operator+=(QChar c) { return append(c); }
00211     inline QString &operator+=(QChar::SpecialCharacter c) { return append(QChar(c)); }
00212     inline QString &operator+=(const QString &s) { return append(s); }
00213     inline QString &operator+=(const QLatin1String &s) { return append(s); }
00214 
00215     QString &remove(int i, int len);
00216     QString &remove(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive);
00217     QString &remove(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive);
00218     QString &replace(int i, int len, QChar after);
00219     QString &replace(int i, int len, const QChar *s, int slen);
00220     QString &replace(int i, int len, const QString &after);
00221     QString &replace(QChar before, QChar after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
00222     QString &replace(QChar c, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
00223     QString &replace(const QString &before, const QString &after,
00224                      Qt::CaseSensitivity cs = Qt::CaseSensitive);
00225 #ifndef QT_NO_REGEXP
00226     QString &replace(const QRegExp &rx, const QString &after);
00227     inline QString &remove(const QRegExp &rx)
00228     { return replace(rx, QString()); }
00229 #endif
00230 
00231     enum SplitBehavior { KeepEmptyParts, SkipEmptyParts };
00232 
00233     QStringList split(const QString &sep, SplitBehavior behavior = KeepEmptyParts,
00234                       Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_REQUIRED_RESULT;
00235     QStringList split(const QChar &sep, SplitBehavior behavior = KeepEmptyParts,
00236                       Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_REQUIRED_RESULT;
00237 #ifndef QT_NO_REGEXP
00238     QStringList split(const QRegExp &sep, SplitBehavior behavior = KeepEmptyParts) const Q_REQUIRED_RESULT;
00239 #endif
00240 
00241     enum NormalizationForm {
00242         NormalizationForm_D,
00243         NormalizationForm_C,
00244         NormalizationForm_KD,
00245         NormalizationForm_KC
00246     };
00247     QString normalized(NormalizationForm mode) const Q_REQUIRED_RESULT;
00248     QString normalized(NormalizationForm mode, QChar::UnicodeVersion version) const Q_REQUIRED_RESULT;
00249 
00250     const ushort *utf16() const;
00251 
00252     QByteArray toAscii() const Q_REQUIRED_RESULT;
00253     QByteArray toLatin1() const Q_REQUIRED_RESULT;
00254     QByteArray toUtf8() const Q_REQUIRED_RESULT;
00255     QByteArray toLocal8Bit() const Q_REQUIRED_RESULT;
00256     QVector<uint> toUcs4() const Q_REQUIRED_RESULT;
00257 
00258     static QString fromAscii(const char *, int size = -1);
00259     static QString fromLatin1(const char *, int size = -1);
00260     static QString fromUtf8(const char *, int size = -1);
00261     static QString fromLocal8Bit(const char *, int size = -1);
00262     static QString fromUtf16(const ushort *, int size = -1);
00263     static QString fromUcs4(const uint *, int size = -1);
00264     static QString fromRawData(const QChar *, int size);
00265 
00266     int toWCharArray(wchar_t *array) const;
00267     static QString fromWCharArray(const wchar_t *, int size = -1);
00268 
00269     QString &setUnicode(const QChar *unicode, int size);
00270     inline QString &setUtf16(const ushort *utf16, int size);
00271 
00272     // ### Qt 5: merge these two functions
00273     int compare(const QString &s) const;
00274     int compare(const QString &s, Qt::CaseSensitivity cs) const;
00275 
00276     int compare(const QLatin1String &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
00277 
00278     // ### Qt 5: merge these two functions
00279     static inline int compare(const QString &s1, const QString &s2)
00280     { return s1.compare(s2); }
00281     static inline int compare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs)
00282     { return s1.compare(s2, cs); }
00283 
00284     static inline int compare(const QString& s1, const QLatin1String &s2,
00285                               Qt::CaseSensitivity cs = Qt::CaseSensitive)
00286     { return s1.compare(s2, cs); }
00287     static inline int compare(const QLatin1String& s1, const QString &s2,
00288                               Qt::CaseSensitivity cs = Qt::CaseSensitive)
00289     { return -s2.compare(s1, cs); }
00290 
00291     int localeAwareCompare(const QString& s) const;
00292     static int localeAwareCompare(const QString& s1, const QString& s2)
00293     { return s1.localeAwareCompare(s2); }
00294 
00295     short  toShort(bool *ok=0, int base=10) const;
00296     ushort toUShort(bool *ok=0, int base=10) const;
00297     int toInt(bool *ok=0, int base=10) const;
00298     uint toUInt(bool *ok=0, int base=10) const;
00299     long toLong(bool *ok=0, int base=10) const;
00300     ulong toULong(bool *ok=0, int base=10) const;
00301     qlonglong toLongLong(bool *ok=0, int base=10) const;
00302     qulonglong toULongLong(bool *ok=0, int base=10) const;
00303     float toFloat(bool *ok=0) const;
00304     double toDouble(bool *ok=0) const;
00305 
00306     QString &setNum(short, int base=10);
00307     QString &setNum(ushort, int base=10);
00308     QString &setNum(int, int base=10);
00309     QString &setNum(uint, int base=10);
00310     QString &setNum(long, int base=10);
00311     QString &setNum(ulong, int base=10);
00312     QString &setNum(qlonglong, int base=10);
00313     QString &setNum(qulonglong, int base=10);
00314     QString &setNum(float, char f='g', int prec=6);
00315     QString &setNum(double, char f='g', int prec=6);
00316 
00317     static QString number(int, int base=10);
00318     static QString number(uint, int base=10);
00319     static QString number(long, int base=10);
00320     static QString number(ulong, int base=10);
00321     static QString number(qlonglong, int base=10);
00322     static QString number(qulonglong, int base=10);
00323     static QString number(double, char f='g', int prec=6);
00324 
00325     bool operator==(const QString &s) const;
00326     bool operator<(const QString &s) const;
00327     inline bool operator>(const QString &s) const { return s < *this; }
00328     inline bool operator!=(const QString &s) const { return !operator==(s); }
00329     inline bool operator<=(const QString &s) const { return !operator>(s); }
00330     inline bool operator>=(const QString &s) const { return !operator<(s); }
00331 
00332     bool operator==(const QLatin1String &s) const;
00333     bool operator<(const QLatin1String &s) const;
00334     bool operator>(const QLatin1String &s) const;
00335     inline bool operator!=(const QLatin1String &s) const { return !operator==(s); }
00336     inline bool operator<=(const QLatin1String &s) const { return !operator>(s); }
00337     inline bool operator>=(const QLatin1String &s) const { return !operator<(s); }
00338 
00339     // ASCII compatibility
00340 #ifndef QT_NO_CAST_FROM_ASCII
00341     inline QT_ASCII_CAST_WARN_CONSTRUCTOR QString(const char *ch) : d(fromAscii_helper(ch))
00342     {}
00343     inline QT_ASCII_CAST_WARN_CONSTRUCTOR QString(const QByteArray &a)
00344         : d(fromAscii_helper(a.constData(), qstrnlen(a.constData(), a.size())))
00345     {}
00346     inline QT_ASCII_CAST_WARN QString &operator=(const char *ch)
00347     { return (*this = fromAscii(ch)); }
00348     inline QT_ASCII_CAST_WARN QString &operator=(const QByteArray &a)
00349     { return (*this = fromAscii(a.constData(), qstrnlen(a.constData(), a.size()))); }
00350     inline QT_ASCII_CAST_WARN QString &operator=(char c)
00351     { return (*this = QChar::fromAscii(c)); }
00352 
00353     // these are needed, so it compiles with STL support enabled
00354     inline QT_ASCII_CAST_WARN QString &prepend(const char *s)
00355     { return prepend(QString::fromAscii(s)); }
00356     inline QT_ASCII_CAST_WARN QString &prepend(const QByteArray &s)
00357     { return prepend(QString::fromAscii(s.constData(), qstrnlen(s.constData(), s.size()))); }
00358     inline QT_ASCII_CAST_WARN QString &append(const char *s)
00359     { return append(QString::fromAscii(s)); }
00360     inline QT_ASCII_CAST_WARN QString &append(const QByteArray &s)
00361     { return append(QString::fromAscii(s.constData(), qstrnlen(s.constData(), s.size()))); }
00362     inline QT_ASCII_CAST_WARN QString &operator+=(const char *s)
00363     { return append(QString::fromAscii(s)); }
00364     inline QT_ASCII_CAST_WARN QString &operator+=(const QByteArray &s)
00365     { return append(QString::fromAscii(s.constData(), qstrnlen(s.constData(), s.size()))); }
00366     inline QT_ASCII_CAST_WARN QString &operator+=(char c)
00367     { return append(QChar::fromAscii(c)); }
00368 
00369     inline QT_ASCII_CAST_WARN bool operator==(const char *s) const;
00370     inline QT_ASCII_CAST_WARN bool operator!=(const char *s) const;
00371     inline QT_ASCII_CAST_WARN bool operator<(const char *s) const;
00372     inline QT_ASCII_CAST_WARN bool operator<=(const char *s2) const;
00373     inline QT_ASCII_CAST_WARN bool operator>(const char *s2) const;
00374     inline QT_ASCII_CAST_WARN bool operator>=(const char *s2) const;
00375 
00376     inline QT_ASCII_CAST_WARN bool operator==(const QByteArray &s) const;
00377     inline QT_ASCII_CAST_WARN bool operator!=(const QByteArray &s) const;
00378     inline QT_ASCII_CAST_WARN bool operator<(const QByteArray &s) const
00379     { return *this < QString::fromAscii(s.constData(), s.size()); }
00380     inline QT_ASCII_CAST_WARN bool operator>(const QByteArray &s) const
00381     { return *this > QString::fromAscii(s.constData(), s.size()); }
00382     inline QT_ASCII_CAST_WARN bool operator<=(const QByteArray &s) const
00383     { return *this <= QString::fromAscii(s.constData(), s.size()); }
00384     inline QT_ASCII_CAST_WARN bool operator>=(const QByteArray &s) const
00385     { return *this >= QString::fromAscii(s.constData(), s.size()); }
00386 #endif
00387 
00388     typedef QChar *iterator;
00389     typedef const QChar *const_iterator;
00390     typedef iterator Iterator;
00391     typedef const_iterator ConstIterator;
00392     iterator begin();
00393     const_iterator begin() const;
00394     const_iterator constBegin() const;
00395     iterator end();
00396     const_iterator end() const;
00397     const_iterator constEnd() const;
00398 
00399     // STL compatibility
00400     inline void push_back(QChar c) { append(c); }
00401     inline void push_back(const QString &s) { append(s); }
00402     inline void push_front(QChar c) { prepend(c); }
00403     inline void push_front(const QString &s) { prepend(s); }
00404 
00405 #ifndef QT_NO_STL
00406     static inline QString fromStdString(const std::string &s);
00407     inline std::string toStdString() const;
00408 # ifdef qdoc
00409     static inline QString fromStdWString(const std::wstring &s);
00410     inline std::wstring toStdWString() const;
00411 # else
00412 #  ifndef QT_NO_STL_WCHAR
00413     static inline QString fromStdWString(const QStdWString &s);
00414     inline QStdWString toStdWString() const;
00415 #  endif // QT_NO_STL_WCHAR
00416 # endif // qdoc
00417 #endif
00418 
00419     // compatibility
00420     struct Null { };
00421     static const Null null;
00422     inline QString(const Null &): d(&shared_null) { d->ref.ref(); }
00423     inline QString &operator=(const Null &) { *this = QString(); return *this; }
00424     inline bool isNull() const { return d == &shared_null; }
00425 
00426 #ifdef QT3_SUPPORT
00427     inline QT3_SUPPORT const char *ascii() const { return ascii_helper(); }
00428     inline QT3_SUPPORT const char *latin1() const { return latin1_helper(); }
00429     inline QT3_SUPPORT QByteArray utf8() const { return toUtf8(); }
00430     inline QT3_SUPPORT QByteArray local8Bit() const{ return toLocal8Bit(); }
00431     inline QT3_SUPPORT void setLength(int nl) { resize(nl); }
00432     inline QT3_SUPPORT QString copy() const { return *this; }
00433     inline QT3_SUPPORT QString &remove(QChar c, bool cs)
00434     { return remove(c, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
00435     inline QT3_SUPPORT QString &remove(const QString  &s, bool cs)
00436     { return remove(s, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
00437     inline QT3_SUPPORT QString &replace(QChar c, const QString  &after, bool cs)
00438     { return replace(c, after, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
00439     inline QT3_SUPPORT QString &replace(const QString &before, const QString &after, bool cs)
00440     { return replace(before, after, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
00441 #ifndef QT_NO_CAST_FROM_ASCII
00442     inline QT3_SUPPORT QString &replace(char c, const QString &after, bool cs)
00443     { return replace(QChar::fromAscii(c), after, cs ? Qt::CaseSensitive : Qt::CaseInsensitive); }
00444     // strange overload, required to avoid GCC 3.3 error
00445     inline QT3_SUPPORT QString &replace(char c, const QString &after, Qt::CaseSensitivity cs)
00446     { return replace(QChar::fromAscii(c), after, cs ? Qt::CaseSensitive : Qt::CaseInsensitive); }
00447 #endif
00448     inline QT3_SUPPORT int find(QChar c, int i = 0, bool cs = true) const
00449     { return indexOf(c, i, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
00450     inline QT3_SUPPORT int find(const QString &s, int i = 0, bool cs = true) const
00451     { return indexOf(s, i, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
00452     inline QT3_SUPPORT int findRev(QChar c, int i = -1, bool cs = true) const
00453     { return lastIndexOf(c, i, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
00454     inline QT3_SUPPORT int findRev(const QString &s, int i = -1, bool cs = true) const
00455     { return lastIndexOf(s, i, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
00456 #ifndef QT_NO_REGEXP
00457     inline QT3_SUPPORT int find(const QRegExp &rx, int i=0) const
00458     { return indexOf(rx, i); }
00459     inline QT3_SUPPORT int findRev(const QRegExp &rx, int i=-1) const
00460     { return lastIndexOf(rx, i); }
00461 #endif
00462     inline QT3_SUPPORT QBool contains(QChar c, bool cs) const
00463     { return contains(c, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
00464     inline QT3_SUPPORT QBool contains(const QString &s, bool cs) const
00465     { return contains(s, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
00466     inline QT3_SUPPORT bool startsWith(const QString &s, bool cs) const
00467     { return startsWith(s, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
00468     inline QT3_SUPPORT bool endsWith(const QString &s, bool cs) const
00469     { return endsWith(s, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
00470     inline QT3_SUPPORT QChar constref(uint i) const
00471     { return at(i); }
00472     QT3_SUPPORT QChar &ref(uint i);
00473     inline QT3_SUPPORT QString leftJustify(int width, QChar fill = QLatin1Char(' '), bool trunc=false) const
00474     { return leftJustified(width, fill, trunc); }
00475     inline QT3_SUPPORT QString rightJustify(int width, QChar fill = QLatin1Char(' '), bool trunc=false) const
00476     { return rightJustified(width, fill, trunc); }
00477     inline QT3_SUPPORT QString lower() const { return toLower(); }
00478     inline QT3_SUPPORT QString upper() const { return toUpper(); }
00479     inline QT3_SUPPORT QString stripWhiteSpace() const { return trimmed(); }
00480     inline QT3_SUPPORT QString simplifyWhiteSpace() const { return simplified(); }
00481     inline QT3_SUPPORT QString &setUnicodeCodes(const ushort *unicode_as_ushorts, int size)
00482     { return setUtf16(unicode_as_ushorts, size); }
00483     inline QT3_SUPPORT const ushort *ucs2() const { return utf16(); }
00484     inline static QT3_SUPPORT QString fromUcs2(const ushort *unicode, int size = -1)
00485     { return fromUtf16(unicode, size); }
00486     inline QT3_SUPPORT QString &setAscii(const char *str, int len = -1)
00487     { *this = fromAscii(str, len); return *this; }
00488     inline QT3_SUPPORT QString &setLatin1(const char *str, int len = -1)
00489     { *this = fromLatin1(str, len); return *this; }
00490 protected:
00491     friend class QObject;
00492     const char *ascii_helper() const;
00493     const char *latin1_helper() const;
00494 public:
00495 #ifndef QT_NO_CAST_TO_ASCII
00496     inline QT3_SUPPORT operator const char *() const { return ascii_helper(); }
00497 private:
00498     QT3_SUPPORT operator QNoImplicitBoolCast() const;
00499 public:
00500 #endif
00501 #endif
00502 
00503     bool isSimpleText() const { if (!d->clean) updateProperties(); return d->simpletext; }
00504     bool isRightToLeft() const { if (!d->clean) updateProperties(); return d->righttoleft; }
00505 
00506 private:
00507 #if defined(QT_NO_CAST_FROM_ASCII) && !defined(Q_NO_DECLARED_NOT_DEFINED)
00508     QString &operator+=(const char *s);
00509     QString &operator+=(const QByteArray &s);
00510     QString(const char *ch);
00511     QString(const QByteArray &a);
00512     QString &operator=(const char  *ch);
00513     QString &operator=(const QByteArray &a);
00514 #endif
00515 
00516     struct Data {
00517         QBasicAtomic ref;
00518         int alloc, size;
00519         ushort *data;
00520         ushort clean : 1;
00521         ushort simpletext : 1;
00522         ushort righttoleft : 1;
00523         ushort asciiCache : 1;
00524         ushort reserved : 12;
00525         ushort array[1];
00526     };
00527     static Data shared_null;
00528     static Data shared_empty;
00529     Data *d;
00530     QString(Data *dd, int /*dummy*/) : d(dd) {}
00531 #ifndef QT_NO_TEXTCODEC
00532     static QTextCodec *codecForCStrings;
00533 #endif
00534     static int grow(int);
00535     static void free(Data *);
00536     void realloc();
00537     void realloc(int alloc);
00538     void expand(int i);
00539     void updateProperties() const;
00540     QString multiArg(int numArgs, const QString **args) const;
00541     static Data *fromLatin1_helper(const char *str, int size = -1);
00542     static Data *fromAscii_helper(const char *str, int size = -1);
00543     friend class QCharRef;
00544     friend class QTextCodec;
00545     friend inline bool qStringComparisonHelper(const QString &s1, const char *s2);
00546 };
00547 
00548 
00549 class Q_CORE_EXPORT QLatin1String
00550 {
00551 public:
00552     inline explicit QLatin1String(const char *s) : chars(s) {}
00553     inline QLatin1String &operator=(const QLatin1String &other)
00554     { chars = other.chars; return *this; }
00555 
00556     inline const char *latin1() const { return chars; }
00557 
00558     inline bool operator==(const QString &s) const
00559     { return s == *this; }
00560     inline bool operator!=(const QString &s) const
00561     { return s != *this; }
00562     inline bool operator>(const QString &s) const
00563     { return s < *this; }
00564     inline bool operator<(const QString &s) const
00565     { return s > *this; }
00566     inline bool operator>=(const QString &s) const
00567     { return s <= *this; }
00568     inline bool operator<=(const QString &s) const
00569     { return s >= *this; }
00570 
00571 private:
00572     const char *chars;
00573 };
00574 
00575 
00576 inline QString::QString(const QLatin1String &latin1) : d(fromLatin1_helper(latin1.latin1()))
00577 { }
00578 inline int QString::length() const
00579 { return d->size; }
00580 inline const QChar QString::at(int i) const
00581 { Q_ASSERT(i >= 0 && i < size()); return d->data[i]; }
00582 inline const QChar QString::operator[](int i) const
00583 { Q_ASSERT(i >= 0 && i < size()); return d->data[i]; }
00584 inline const QChar QString::operator[](uint i) const
00585 { Q_ASSERT(i < uint(size())); return d->data[i]; }
00586 inline bool QString::isEmpty() const
00587 { return d->size == 0; }
00588 inline const QChar *QString::unicode() const
00589 { return reinterpret_cast<const QChar*>(d->data); }
00590 inline const QChar *QString::data() const
00591 { return reinterpret_cast<const QChar*>(d->data); }
00592 inline QChar *QString::data()
00593 { detach(); return reinterpret_cast<QChar*>(d->data); }
00594 inline const QChar *QString::constData() const
00595 { return reinterpret_cast<const QChar*>(d->data); }
00596 inline void QString::detach()
00597 { if (d->ref != 1 || d->data != d->array) realloc(); }
00598 inline bool QString::isDetached() const
00599 { return d->ref == 1; }
00600 inline QString &QString::operator=(const QLatin1String &s)
00601 {
00602     *this = fromLatin1(s.latin1());
00603     return *this;
00604 }
00605 inline void QString::clear()
00606 { if (!isNull()) *this = QString(); }
00607 inline QString::QString(const QString &s) : d(s.d)
00608 { Q_ASSERT(&s != this); d->ref.ref(); }
00609 inline int QString::capacity() const
00610 { return d->alloc; }
00611 inline QString &QString::setNum(short n, int base)
00612 { return setNum(qlonglong(n), base); }
00613 inline QString &QString::setNum(ushort n, int base)
00614 { return setNum(qulonglong(n), base); }
00615 inline QString &QString::setNum(int n, int base)
00616 { return setNum(qlonglong(n), base); }
00617 inline QString &QString::setNum(uint n, int base)
00618 { return setNum(qulonglong(n), base); }
00619 inline QString &QString::setNum(long n, int base)
00620 { return setNum(qlonglong(n), base); }
00621 inline QString &QString::setNum(ulong n, int base)
00622 { return setNum(qulonglong(n), base); }
00623 inline QString &QString::setNum(float n, char f, int prec)
00624 { return setNum(double(n),f,prec); }
00625 inline QString QString::arg(int a, int fieldWidth, int base, const QChar &fillChar) const
00626 { return arg(qlonglong(a), fieldWidth, base, fillChar); }
00627 inline QString QString::arg(uint a, int fieldWidth, int base, const QChar &fillChar) const
00628 { return arg(qulonglong(a), fieldWidth, base, fillChar); }
00629 inline QString QString::arg(long a, int fieldWidth, int base, const QChar &fillChar) const
00630 { return arg(qlonglong(a), fieldWidth, base, fillChar); }
00631 inline QString QString::arg(ulong a, int fieldWidth, int base, const QChar &fillChar) const
00632 { return arg(qulonglong(a), fieldWidth, base, fillChar); }
00633 inline QString QString::arg(short a, int fieldWidth, int base, const QChar &fillChar) const
00634 { return arg(qlonglong(a), fieldWidth, base, fillChar); }
00635 inline QString QString::arg(ushort a, int fieldWidth, int base, const QChar &fillChar) const
00636 { return arg(qulonglong(a), fieldWidth, base, fillChar); }
00637 inline QString QString::arg(const QString &a1, const QString &a2) const
00638 { const QString *args[2] = { &a1, &a2 }; return multiArg(2, args); }
00639 inline QString QString::arg(const QString &a1, const QString &a2, const QString &a3) const
00640 { const QString *args[3] = { &a1, &a2, &a3 }; return multiArg(3, args); }
00641 inline QString QString::arg(const QString &a1, const QString &a2, const QString &a3, const QString &a4) const
00642 { const QString *args[4] = { &a1, &a2, &a3, &a4 }; return multiArg(4, args); }
00643 inline QString QString::section(QChar asep, int astart, int aend, SectionFlags aflags) const
00644 { return section(QString(asep), astart, aend, aflags); }
00645 
00646 
00647 class Q_CORE_EXPORT QCharRef {
00648     QString &s;
00649     int i;
00650     inline QCharRef(QString &str, int idx)
00651         : s(str),i(idx) {}
00652     friend class QString;
00653 public:
00654 
00655     // most QChar operations repeated here
00656 
00657     // all this is not documented: We just say "like QChar" and let it be.
00658     inline operator QChar() const
00659         { return i < s.d->size ? s.d->data[i] : 0; }
00660     inline QCharRef &operator=(const QChar &c)
00661         { if (s.d->ref != 1 || i >= s.d->size) s.expand(i);
00662           s.d->data[i] = c.unicode();  return *this; }
00663 
00664     // An operator= for each QChar cast constructors
00665 #ifndef QT_NO_CAST_FROM_ASCII
00666     inline QT_ASCII_CAST_WARN QCharRef &operator=(char c)
00667     { return operator=(QChar::fromAscii(c)); }
00668     inline QT_ASCII_CAST_WARN QCharRef &operator=(uchar c)
00669     { return operator=(QChar::fromAscii(c)); }
00670 #endif
00671     inline QCharRef &operator=(const QCharRef &c) { return operator=(QChar(c)); }
00672     inline QCharRef &operator=(ushort rc) { return operator=(QChar(rc)); }
00673     inline QCharRef &operator=(short rc) { return operator=(QChar(rc)); }
00674     inline QCharRef &operator=(uint rc) { return operator=(QChar(rc)); }
00675     inline QCharRef &operator=(int rc) { return operator=(QChar(rc)); }
00676 
00677     // each function...
00678     inline bool isNull() const { return QChar(*this).isNull(); }
00679     inline bool isPrint() const { return QChar(*this).isPrint(); }
00680     inline bool isPunct() const { return QChar(*this).isPunct(); }
00681     inline bool isSpace() const { return QChar(*this).isSpace(); }
00682     inline bool isMark() const { return QChar(*this).isMark(); }
00683     inline bool isLetter() const { return QChar(*this).isLetter(); }
00684     inline bool isNumber() const { return QChar(*this).isNumber(); }
00685     inline bool isLetterOrNumber() { return QChar(*this).isLetterOrNumber(); }
00686     inline bool isDigit() const { return QChar(*this).isDigit(); }
00687 
00688     inline int digitValue() const { return QChar(*this).digitValue(); }
00689     QChar toLower() const { return QChar(*this).toLower(); }
00690     QChar toUpper() const { return QChar(*this).toUpper(); }
00691 #ifdef QT3_SUPPORT
00692     inline QT3_SUPPORT QChar lower() const { return QChar(*this).toLower(); }
00693     inline QT3_SUPPORT QChar upper() const { return QChar(*this).toUpper(); }
00694 #endif
00695 
00696     QChar::Category category() const { return QChar(*this).category(); }
00697     QChar::Direction direction() const { return QChar(*this).direction(); }
00698     QChar::Joining joining() const { return QChar(*this).joining(); }
00699     bool hasMirrored() const { return QChar(*this).hasMirrored(); }
00700 #ifdef QT3_SUPPORT
00701     inline bool QT3_SUPPORT mirrored() const { return hasMirrored(); }
00702 #endif
00703     QChar mirroredChar() const { return QChar(*this).mirroredChar(); }
00704     QString decomposition() const { return QChar(*this).decomposition(); }
00705     QChar::Decomposition decompositionTag() const { return QChar(*this).decompositionTag(); }
00706     uchar combiningClass() const { return QChar(*this).combiningClass(); }
00707 
00708     QChar::UnicodeVersion unicodeVersion() const { return QChar(*this).unicodeVersion(); }
00709 
00710     inline uchar cell() const { return QChar(*this).cell(); }
00711     inline uchar row() const { return QChar(*this).row(); }
00712     inline void setCell(uchar cell);
00713     inline void setRow(uchar row);
00714 
00715     const char toAscii() const { return QChar(*this).toAscii(); }
00716     const char toLatin1() const { return QChar(*this).toLatin1(); }
00717 #ifdef QT3_SUPPORT
00718     const char latin1() const { return QChar(*this).toLatin1(); }
00719     const char ascii() const { return QChar(*this).toAscii(); }
00720 #endif
00721     const ushort unicode() const { return QChar(*this).unicode(); }
00722 };
00723 
00724 inline void QCharRef::setRow(uchar arow) { QChar(*this).setRow(arow); }
00725 inline void QCharRef::setCell(uchar acell) { QChar(*this).setCell(acell); }
00726 
00727 
00728 inline QString::QString() : d(&shared_null) { d->ref.ref(); }
00729 inline QString::~QString() { if (!d->ref.deref()) free(d); }
00730 inline void QString::reserve(int asize) { if (d->ref != 1 || asize > d->alloc) realloc(asize); }
00731 inline QString &QString::setUtf16(const ushort *autf16, int asize)
00732 { return setUnicode(reinterpret_cast<const QChar *>(autf16), asize); }
00733 inline QCharRef QString::operator[](int i)
00734 { Q_ASSERT(i >= 0); return QCharRef(*this, i); }
00735 inline QCharRef QString::operator[](uint i)
00736 { return QCharRef(*this, i); }
00737 inline QString::iterator QString::begin()
00738 { detach(); return reinterpret_cast<QChar*>(d->data); }
00739 inline QString::const_iterator QString::begin() const
00740 { return reinterpret_cast<const QChar*>(d->data); }
00741 inline QString::const_iterator QString::constBegin() const
00742 { return reinterpret_cast<const QChar*>(d->data); }
00743 inline QString::iterator QString::end()
00744 { detach(); return reinterpret_cast<QChar*>(d->data + d->size); }
00745 inline QString::const_iterator QString::end() const
00746 { return reinterpret_cast<const QChar*>(d->data + d->size); }
00747 inline QString::const_iterator QString::constEnd() const
00748 { return reinterpret_cast<const QChar*>(d->data + d->size); }
00749 inline QBool QString::contains(const QString &s, Qt::CaseSensitivity cs) const
00750 { return QBool(indexOf(s, 0, cs) != -1); }
00751 inline QBool QString::contains(QChar c, Qt::CaseSensitivity cs) const
00752 { return QBool(indexOf(c, 0, cs) != -1); }
00753 
00754 
00755 inline bool operator==(QString::Null, QString::Null) { return true; }
00756 inline bool operator==(QString::Null, const QString &s) { return s.isNull(); }
00757 inline bool operator==(const QString &s, QString::Null) { return s.isNull(); }
00758 inline bool operator!=(QString::Null, QString::Null) { return false; }
00759 inline bool operator!=(QString::Null, const QString &s) { return !s.isNull(); }
00760 inline bool operator!=(const QString &s, QString::Null) { return !s.isNull(); }
00761 
00762 #ifndef QT_NO_CAST_FROM_ASCII
00763 inline bool qStringComparisonHelper(const QString &s1, const char *s2)
00764 {
00765 #  ifndef QT_NO_TEXTCODEC
00766     if (QString::codecForCStrings) return (s1 == QString::fromAscii(s2));
00767 #  endif
00768     return (s1 == QLatin1String(s2));
00769 }
00770 
00771 inline bool QString::operator==(const char *s) const
00772 { return qStringComparisonHelper(*this, s); }
00773 inline bool QString::operator!=(const char *s) const
00774 { return !qStringComparisonHelper(*this, s); }
00775 inline bool QString::operator<(const char *s) const
00776 { return *this < QString::fromAscii(s); }
00777 inline bool QString::operator>(const char *s) const
00778 { return *this > QString::fromAscii(s); }
00779 inline bool QString::operator<=(const char *s) const
00780 { return *this <= QString::fromAscii(s); }
00781 inline bool QString::operator>=(const char *s) const
00782 { return *this >= QString::fromAscii(s); }
00783 
00784 inline QT_ASCII_CAST_WARN bool operator==(const char *s1, const QString &s2)
00785 { return qStringComparisonHelper(s2, s1); }
00786 inline QT_ASCII_CAST_WARN bool operator!=(const char *s1, const QString &s2)
00787 { return !qStringComparisonHelper(s2, s1); }
00788 inline QT_ASCII_CAST_WARN bool operator<(const char *s1, const QString &s2)
00789 { return (QString::fromAscii(s1) < s2); }
00790 inline QT_ASCII_CAST_WARN bool operator>(const char *s1, const QString &s2)
00791 { return (QString::fromAscii(s1) > s2); }
00792 inline QT_ASCII_CAST_WARN bool operator<=(const char *s1, const QString &s2)
00793 { return (QString::fromAscii(s1) <= s2); }
00794 inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QString &s2)
00795 { return (QString::fromAscii(s1) >= s2); }
00796 
00797 inline bool QString::operator==(const QByteArray &s) const
00798 { return qStringComparisonHelper(*this, s.constData()); }
00799 inline bool QString::operator!=(const QByteArray &s) const
00800 { return !qStringComparisonHelper(*this, s.constData()); }
00801 
00802 inline bool QByteArray::operator==(const QString &s) const
00803 { return qStringComparisonHelper(s, constData()); }
00804 inline bool QByteArray::operator!=(const QString &s) const
00805 { return !qStringComparisonHelper(s, constData()); }
00806 inline bool QByteArray::operator<(const QString &s) const
00807 { return QString::fromAscii(constData(), size()) < s; }
00808 inline bool QByteArray::operator>(const QString &s) const
00809 { return QString::fromAscii(constData(), size()) > s; }
00810 inline bool QByteArray::operator<=(const QString &s) const
00811 { return QString::fromAscii(constData(), size()) <= s; }
00812 inline bool QByteArray::operator>=(const QString &s) const
00813 { return QString::fromAscii(constData(), size()) >= s; }
00814 #endif   // QT_NO_CAST_FROM_ASCII
00815 
00816 #ifndef QT_NO_CAST_TO_ASCII
00817 inline QByteArray &QByteArray::append(const QString &s)
00818 { return append(s.toAscii()); }
00819 inline QByteArray &QByteArray::insert(int i, const QString &s)
00820 { return insert(i, s.toAscii()); }
00821 inline QByteArray &QByteArray::replace(char c, const QString &after)
00822 { return replace(c, after.toAscii()); }
00823 inline QByteArray &QByteArray::replace(const QString &before, const char *after)
00824 { return replace(before.toAscii(), after); }
00825 inline QByteArray &QByteArray::replace(const QString &before, const QByteArray &after)
00826 { return replace(before.toAscii(), after); }
00827 inline QByteArray &QByteArray::operator+=(const QString &s)
00828 { return operator+=(s.toAscii()); }
00829 inline int QByteArray::indexOf(const QString &s, int from) const
00830 { return indexOf(s.toAscii(), from); }
00831 inline int QByteArray::lastIndexOf(const QString &s, int from) const
00832 { return lastIndexOf(s.toAscii(), from); }
00833 #  ifdef QT3_SUPPORT
00834 inline int QByteArray::find(const QString &s, int from) const
00835 { return indexOf(s.toAscii(), from); }
00836 inline int QByteArray::findRev(const QString &s, int from) const
00837 { return lastIndexOf(s.toAscii(), from); }
00838 #  endif // QT3_SUPPORT
00839 #endif // QT_NO_CAST_TO_ASCII
00840 
00841 inline const QString operator+(const QString &s1, const QString &s2)
00842 { QString t(s1); t += s2; return t; }
00843 inline const QString operator+(const QString &s1, QChar s2)
00844 { QString t(s1); t += s2; return t; }
00845 inline const QString operator+(QChar s1, const QString &s2)
00846 { QString t(s1); t += s2; return t; }
00847 #ifndef QT_NO_CAST_FROM_ASCII
00848 inline QT_ASCII_CAST_WARN const QString operator+(const QString &s1, const char *s2)
00849 { QString t(s1); t += QString::fromAscii(s2); return t; }
00850 inline QT_ASCII_CAST_WARN const QString operator+(const char *s1, const QString &s2)
00851 { QString t = QString::fromAscii(s1); t += s2; return t; }
00852 inline QT_ASCII_CAST_WARN const QString operator+(char c, const QString &s)
00853 { QString t = s; t.prepend(QChar::fromAscii(c)); return t; }
00854 inline QT_ASCII_CAST_WARN const QString operator+(const QString &s, char c)
00855 { QString t = s; t += QChar::fromAscii(c); return t; }
00856 inline QT_ASCII_CAST_WARN const QString operator+(const QByteArray &ba, const QString &s)
00857 { QString t = QString::fromAscii(ba.constData(), qstrnlen(ba.constData(), ba.size())); t += s; return t; }
00858 inline QT_ASCII_CAST_WARN const QString operator+(const QString &s, const QByteArray &ba)
00859 { QString t(s); t += QString::fromAscii(ba.constData(), qstrnlen(ba.constData(), ba.size())); return t; }
00860 #endif
00861 
00862 #ifndef QT_NO_STL
00863 inline std::string QString::toStdString() const
00864 { const QByteArray asc = toAscii(); return std::string(asc.constData(), asc.length()); }
00865 
00866 inline QString QString::fromStdString(const std::string &s)
00867 { return fromAscii(s.data(), int(s.size())); }
00868 
00869 # ifndef QT_NO_STL_WCHAR
00870 inline QStdWString QString::toStdWString() const
00871 {
00872     QStdWString str;
00873     str.resize(length());
00874 
00875 #if defined(_MSC_VER) && _MSC_VER >= 1400
00876     // VS2005 crashes if the string is empty
00877     if (!length())
00878         return str;
00879 #endif
00880 
00881     str.resize(toWCharArray(&(*str.begin())));
00882     return str;
00883 }
00884 inline QString QString::fromStdWString(const QStdWString &s)
00885 { return fromWCharArray(s.data(), int(s.size())); }
00886 # endif
00887 #endif
00888 
00889 #ifdef QT3_SUPPORT
00890 inline QChar &QString::ref(uint i)
00891 {
00892     if (int(i) > d->size || d->ref != 1)
00893         resize(qMax(int(i), d->size));
00894     return reinterpret_cast<QChar&>(d->data[i]);
00895 }
00896 #endif
00897 
00898 #ifndef QT_NO_DATASTREAM
00899 Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QString &);
00900 Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QString &);
00901 #endif
00902 
00903 #ifdef QT3_SUPPORT
00904 class QConstString : public QString
00905 {
00906 public:
00907     inline QT3_SUPPORT_CONSTRUCTOR QConstString(const QChar *unicode, int size)
00908         :QString(unicode, size){} // cannot use fromRawData() due to changed semantics
00909     inline QT3_SUPPORT const QString &string() const { return *this; }
00910 };
00911 #endif
00912 
00913 Q_DECLARE_TYPEINFO(QString, Q_MOVABLE_TYPE);
00914 Q_DECLARE_SHARED(QString)
00915 Q_DECLARE_OPERATORS_FOR_FLAGS(QString::SectionFlags)
00916 
00917 #if defined(Q_OS_WIN32)
00918 extern Q_CORE_EXPORT QByteArray qt_winQString2MB(const QString& s, int len=-1);
00919 extern Q_CORE_EXPORT QByteArray qt_winQString2MB(const QChar *ch, int len);
00920 extern Q_CORE_EXPORT QString qt_winMB2QString(const char* mb, int len=-1);
00921 #endif
00922 
00923 QT_END_HEADER
00924 
00925 #endif // QSTRING_H

Generated on Thu Mar 15 11:54:14 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1