⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qstring.h

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 H
📖 第 1 页 / 共 3 页
字号:
/******************************************************************************** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved.**** This file is part of the QtCore module of the Qt Toolkit.**** This file may be used under the terms of the GNU General Public** License version 2.0 as published by the Free Software Foundation** and appearing in the file LICENSE.GPL included in the packaging of** this file.  Please review the following information to ensure GNU** General Public Licensing requirements will be met:** http://www.trolltech.com/products/qt/opensource.html**** If you are unsure which license is appropriate for your use, please** review the following information:** http://www.trolltech.com/products/qt/licensing.html or contact the** sales department at sales@trolltech.com.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#ifndef QSTRING_H#define QSTRING_H#include <QtCore/qchar.h>#include <QtCore/qbytearray.h>#include <QtCore/qatomic.h>#include <QtCore/qnamespace.h>#ifdef QT_INCLUDE_COMPAT#include <Qt3Support/q3cstring.h>#endif#ifndef QT_NO_STL# if defined (Q_CC_MSVC_NET) && _MSC_VER < 1310 // Avoids nasty warning for xlocale, line 450#  pragma warning (push)#  pragma warning (disable : 4189)#  include <string>#  pragma warning (pop)# else#  include <string># endif#ifndef QT_NO_STL_WCHAR// workaround for some headers not typedef'ing std::wstringtypedef std::basic_string<wchar_t> QStdWString;#endif // QT_NO_STL_WCHAR#endif // QT_NO_STL#include <stdarg.h>#ifdef truncate#error qstring.h must be included before any header file that defines truncate#endifQT_BEGIN_HEADERQT_MODULE(Core)class QCharRef;class QRegExp;class QStringList;class QTextCodec;class QLatin1String;class Q_CORE_EXPORT QString{public:    inline QString();    QString(const QChar *unicode, int size);    QString(QChar c);    QString(int size, QChar c);    inline QString(const QLatin1String &latin1);    inline QString(const QString &);    inline ~QString();    QString &operator=(QChar c);    QString &operator=(const QString &);    inline QString &operator=(const QLatin1String &);    inline int size() const { return d->size; }    inline int count() const { return d->size; }    inline int length() const;    inline bool isEmpty() const;    void resize(int size);    QString &fill(QChar c, int size = -1);    void truncate(int pos);    void chop(int n);    int capacity() const;    inline void reserve(int size);    inline void squeeze() { if (d->size < d->alloc) realloc(); }    inline const QChar *unicode() const;    inline QChar *data();    inline const QChar *data() const;    inline const QChar *constData() const;    inline void detach();    inline bool isDetached() const;    void clear();    inline const QChar at(int i) const;    const QChar operator[](int i) const;    QCharRef operator[](int i);    const QChar operator[](uint i) const;    QCharRef operator[](uint i);    QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar = QLatin1Char(' ')) const;    QString arg(qulonglong a, int fieldwidth=0, int base=10, const QChar &fillChar = QLatin1Char(' ')) const;    QString arg(long a, int fieldwidth=0, int base=10, const QChar &fillChar = QLatin1Char(' ')) const;    QString arg(ulong a, int fieldwidth=0, int base=10, const QChar &fillChar = QLatin1Char(' ')) const;    QString arg(int a, int fieldWidth = 0, int base = 10, const QChar &fillChar = QLatin1Char(' ')) const;    QString arg(uint a, int fieldWidth = 0, int base = 10, const QChar &fillChar = QLatin1Char(' ')) const;    QString arg(short a, int fieldWidth = 0, int base = 10, const QChar &fillChar = QLatin1Char(' ')) const;    QString arg(ushort a, int fieldWidth = 0, int base = 10, const QChar &fillChar = QLatin1Char(' ')) const;    QString arg(double a, int fieldWidth = 0, char fmt = 'g', int prec = -1, const QChar &fillChar = QLatin1Char(' ')) const;    QString arg(char a, int fieldWidth = 0, const QChar &fillChar = QLatin1Char(' ')) const;    QString arg(QChar a, int fieldWidth = 0, const QChar &fillChar = QLatin1Char(' ')) const;    QString arg(const QString &a, int fieldWidth = 0, const QChar &fillChar = QLatin1Char(' ')) const;    QString arg(const QString &a1, const QString &a2) const;    QString arg(const QString &a1, const QString &a2, const QString &a3) const;    QString arg(const QString &a1, const QString &a2, const QString &a3, const QString &a4) const;    QString    &vsprintf(const char *format, va_list ap);    QString    &sprintf(const char *format, ...)#if defined(Q_CC_GNU) && !defined(__INSURE__)        __attribute__ ((format (printf, 2, 3)))#endif        ;    int indexOf(QChar c, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;    int indexOf(const QString &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;    int lastIndexOf(QChar c, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;    int lastIndexOf(const QString &s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;    inline QBool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;    inline QBool contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;    int count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;    int count(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;#ifndef QT_NO_REGEXP    int indexOf(const QRegExp &, int from = 0) const;    int lastIndexOf(const QRegExp &, int from = -1) const;    inline QBool contains(const QRegExp &rx) const { return QBool(indexOf(rx) != -1); }    int count(const QRegExp &) const;#endif    enum SectionFlag {        SectionDefault             = 0x00,        SectionSkipEmpty           = 0x01,        SectionIncludeLeadingSep   = 0x02,        SectionIncludeTrailingSep  = 0x04,        SectionCaseInsensitiveSeps = 0x08    };    Q_DECLARE_FLAGS(SectionFlags, SectionFlag)    QString section(QChar sep, int start, int end = -1, SectionFlags flags = SectionDefault) const;    QString section(const QString &in_sep, int start, int end = -1, SectionFlags flags = SectionDefault) const;#ifndef QT_NO_REGEXP    QString section(const QRegExp &reg, int start, int end = -1, SectionFlags flags = SectionDefault) const;#endif    QString left(int len) const;    QString right(int len) const;    QString mid(int i, int len = -1) const;    bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;    bool startsWith(const QLatin1String &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;    bool startsWith(const QChar &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;    bool endsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;    bool endsWith(const QLatin1String &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;    bool endsWith(const QChar &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;    QString leftJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const;    QString rightJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const;    QString toLower() const;    QString toUpper() const;    QString trimmed() const;    QString simplified() const;    QString &insert(int i, QChar c);    QString &insert(int i, const QChar *uc, int len);    inline QString &insert(int i, const QString &s) { return insert(i, s.constData(), s.length()); }    QString &insert(int i, const QLatin1String &s);    QString &append(QChar c);    QString &append(const QString &s);    QString &append(const QLatin1String &s);    inline QString &prepend(QChar c) { return insert(0, c); }    inline QString &prepend(const QString &s) { return insert(0, s); }    inline QString &prepend(const QLatin1String &s) { return insert(0, s); }    inline QString &operator+=(QChar c) { return append(c); }    inline QString &operator+=(QChar::SpecialCharacter c) { return append(QChar(c)); }    inline QString &operator+=(const QString &s) { return append(s); }    inline QString &operator+=(const QLatin1String &s) { return append(s); }    QString &remove(int i, int len);    QString &remove(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive);    QString &remove(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive);    QString &replace(int i, int len, QChar after);    QString &replace(int i, int len, const QChar *s, int slen);    QString &replace(int i, int len, const QString &after);    QString &replace(QChar before, QChar after, Qt::CaseSensitivity cs = Qt::CaseSensitive);    QString &replace(QChar c, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);    QString &replace(const QString &before, const QString &after,                     Qt::CaseSensitivity cs = Qt::CaseSensitive);#ifndef QT_NO_REGEXP    QString &replace(const QRegExp &rx, const QString &after);    inline QString &remove(const QRegExp &rx)    { return replace(rx, QString()); }#endif    enum SplitBehavior { KeepEmptyParts, SkipEmptyParts };    QStringList split(const QString &sep, SplitBehavior behavior = KeepEmptyParts,                      Qt::CaseSensitivity cs = Qt::CaseSensitive) const;    QStringList split(const QChar &sep, SplitBehavior behavior = KeepEmptyParts,                      Qt::CaseSensitivity cs = Qt::CaseSensitive) const;#ifndef QT_NO_REGEXP    QStringList split(const QRegExp &sep, SplitBehavior behavior = KeepEmptyParts) const;#endif    enum NormalizationForm {        NormalizationForm_D,        NormalizationForm_C,        NormalizationForm_KD,        NormalizationForm_KC    };    QString normalized(NormalizationForm mode) const;    QString normalized(NormalizationForm mode, QChar::UnicodeVersion version) const;    const ushort *utf16() const;    QByteArray toAscii() const;    QByteArray toLatin1() const;    QByteArray toUtf8() const;    QByteArray toLocal8Bit() const;    static QString fromAscii(const char *, int size = -1);    static QString fromLatin1(const char *, int size = -1);    static QString fromUtf8(const char *, int size = -1);    static QString fromLocal8Bit(const char *, int size = -1);    static QString fromUtf16(const ushort *, int size = -1);    static QString fromRawData(const QChar *, int size);    QString &setUnicode(const QChar *unicode, int size);    inline QString &setUtf16(const ushort *utf16, int size);    int compare(const QString &s) const;    static inline int compare(const QString &s1, const QString &s2)    { return s1.compare(s2); }    int localeAwareCompare(const QString& s) const;    static int localeAwareCompare(const QString& s1, const QString& s2)    { return s1.localeAwareCompare(s2); }    short  toShort(bool *ok=0, int base=10) const;    ushort toUShort(bool *ok=0, int base=10) const;    int toInt(bool *ok=0, int base=10) const;    uint toUInt(bool *ok=0, int base=10) const;    long toLong(bool *ok=0, int base=10) const;    ulong toULong(bool *ok=0, int base=10) const;    qlonglong toLongLong(bool *ok=0, int base=10) const;    qulonglong toULongLong(bool *ok=0, int base=10) const;    float toFloat(bool *ok=0) const;    double toDouble(bool *ok=0) const;    QString &setNum(short, int base=10);    QString &setNum(ushort, int base=10);    QString &setNum(int, int base=10);    QString &setNum(uint, int base=10);    QString &setNum(long, int base=10);    QString &setNum(ulong, int base=10);    QString &setNum(qlonglong, int base=10);    QString &setNum(qulonglong, int base=10);    QString &setNum(float, char f='g', int prec=6);    QString &setNum(double, char f='g', int prec=6);    static QString number(int, int base=10);    static QString number(uint, int base=10);    static QString number(long, int base=10);    static QString number(ulong, int base=10);    static QString number(qlonglong, int base=10);    static QString number(qulonglong, int base=10);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -