diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-05-27 09:58:12 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-06-20 20:01:33 +0200 |
commit | 03326a2fec416405b437089874f6439e937bbada (patch) | |
tree | 48d7137c3cd5e6f537e06e97380d3c1e76a56af9 /src/corelib/text | |
parent | 1a9a4af388477efd9f7008d5c0bb74432c20279d (diff) |
Move implementation of QVector/List back to qlist.h
And name the main class QList. That's also the one we document.
This gives less porting pain for our users, and a lot less churn
in our API, as we use QList in Qt 5 in 95% of our API.
In addition, it gives more consistent naming with QStringList and
QByteArrayList and disambiguates QList vs QVector(2|3|4)D.
Fixes: QTBUG-84468
Change-Id: I3cba9d1d3179969d8bf9320b31be2230d021d1a9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/text')
-rw-r--r-- | src/corelib/text/qbytearraylist.h | 16 | ||||
-rw-r--r-- | src/corelib/text/qstring.h | 1 | ||||
-rw-r--r-- | src/corelib/text/qstringalgorithms.h | 3 | ||||
-rw-r--r-- | src/corelib/text/qstringlist.h | 70 | ||||
-rw-r--r-- | src/corelib/text/qstringtokenizer.h | 2 |
5 files changed, 45 insertions, 47 deletions
diff --git a/src/corelib/text/qbytearraylist.h b/src/corelib/text/qbytearraylist.h index d02fa6d20f..3f85a24329 100644 --- a/src/corelib/text/qbytearraylist.h +++ b/src/corelib/text/qbytearraylist.h @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include <QtCore/qvector.h> +#include <QtCore/qlist.h> #ifndef QBYTEARRAYLIST_H #define QBYTEARRAYLIST_H @@ -49,12 +49,12 @@ QT_BEGIN_NAMESPACE #if !defined(QT_NO_JAVA_STYLE_ITERATORS) -typedef QVectorIterator<QByteArray> QByteArrayListIterator; -typedef QMutableVectorIterator<QByteArray> QMutableByteArrayListIterator; +typedef QListIterator<QByteArray> QByteArrayListIterator; +typedef QMutableListIterator<QByteArray> QMutableByteArrayListIterator; #endif #ifndef Q_CLANG_QDOC -typedef QVector<QByteArray> QByteArrayList; +typedef QList<QByteArray> QByteArrayList; namespace QtPrivate { QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *separator, int separatorLength); @@ -63,14 +63,14 @@ namespace QtPrivate { #endif #ifdef Q_CLANG_QDOC -class QByteArrayList : public QVector<QByteArray> +class QByteArrayList : public QList<QByteArray> #else -template <> struct QVectorSpecialMethods<QByteArray> +template <> struct QListSpecialMethods<QByteArray> #endif { #ifndef Q_CLANG_QDOC protected: - ~QVectorSpecialMethods() = default; + ~QListSpecialMethods() = default; #endif public: inline QByteArray join() const @@ -81,7 +81,7 @@ public: { return QtPrivate::QByteArrayList_join(self(), &sep, 1); } private: - typedef QVector<QByteArray> Self; + typedef QList<QByteArray> Self; Self *self() { return static_cast<Self *>(this); } const Self *self() const { return static_cast<const Self *>(this); } }; diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 77a95c6280..f14644d956 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -77,7 +77,6 @@ class QRegularExpressionMatch; class QString; class QStringList; class QStringRef; -template <typename T> class QVector; namespace QtPrivate { template <bool...B> class BoolList; diff --git a/src/corelib/text/qstringalgorithms.h b/src/corelib/text/qstringalgorithms.h index f1aa052eac..3b67739232 100644 --- a/src/corelib/text/qstringalgorithms.h +++ b/src/corelib/text/qstringalgorithms.h @@ -41,7 +41,7 @@ #define QSTRINGALGORITHMS_H #include <QtCore/qnamespace.h> - +#include <QtCore/qcontainerfwd.h> #if 0 #pragma qt_class(QStringAlgorithms) #endif @@ -52,7 +52,6 @@ class QByteArray; class QLatin1String; class QStringView; class QChar; -template <typename T> class QVector; namespace QtPrivate { diff --git a/src/corelib/text/qstringlist.h b/src/corelib/text/qstringlist.h index b94671746b..9c4daedd4b 100644 --- a/src/corelib/text/qstringlist.h +++ b/src/corelib/text/qstringlist.h @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include <QtCore/qvector.h> +#include <QtCore/qlist.h> #ifndef QSTRINGLIST_H #define QSTRINGLIST_H @@ -53,21 +53,21 @@ QT_BEGIN_NAMESPACE class QRegularExpression; #if !defined(QT_NO_JAVA_STYLE_ITERATORS) -typedef QVectorIterator<QString> QStringListIterator; -typedef QMutableVectorIterator<QString> QMutableStringListIterator; +using QStringListIterator = QListIterator<QString>; +using QMutableStringListIterator = QMutableListIterator<QString>; #endif class QStringList; #ifdef Q_QDOC -class QStringList : public QVector<QString> +class QStringList : public QList<QString> #else -template <> struct QVectorSpecialMethods<QString> +template <> struct QListSpecialMethods<QString> #endif { #ifndef Q_QDOC protected: - ~QVectorSpecialMethods() = default; + ~QListSpecialMethods() = default; #endif public: inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive); @@ -101,23 +101,23 @@ private: }; // ### Qt6: check if there's a better way -class QStringList : public QVector<QString> +class QStringList : public QList<QString> { #endif public: inline QStringList() noexcept { } inline explicit QStringList(const QString &i) { append(i); } - inline QStringList(const QVector<QString> &l) : QVector<QString>(l) { } - inline QStringList(QVector<QString> &&l) noexcept : QVector<QString>(std::move(l)) { } - inline QStringList(std::initializer_list<QString> args) : QVector<QString>(args) { } + inline QStringList(const QList<QString> &l) : QList<QString>(l) { } + inline QStringList(QList<QString> &&l) noexcept : QList<QString>(std::move(l)) { } + inline QStringList(std::initializer_list<QString> args) : QList<QString>(args) { } template <typename InputIterator, QtPrivate::IfIsInputIterator<InputIterator> = true> inline QStringList(InputIterator first, InputIterator last) - : QVector<QString>(first, last) { } + : QList<QString>(first, last) { } - QStringList &operator=(const QVector<QString> &other) - { QVector<QString>::operator=(other); return *this; } - QStringList &operator=(QVector<QString> &&other) noexcept - { QVector<QString>::operator=(std::move(other)); return *this; } + QStringList &operator=(const QList<QString> &other) + { QList<QString>::operator=(other); return *this; } + QStringList &operator=(QList<QString> &&other) noexcept + { QList<QString>::operator=(std::move(other)); return *this; } #if QT_STRINGVIEW_LEVEL < 2 inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; @@ -131,7 +131,7 @@ public: { append(str); return *this; } inline QStringList &operator<<(const QStringList &l) { *this += l; return *this; } - inline QStringList &operator<<(const QVector<QString> &l) + inline QStringList &operator<<(const QList<QString> &l) { *this += l; return *this; } inline int indexOf(QStringView str, int from = 0) const; @@ -145,16 +145,16 @@ public: inline int lastIndexOf(const QRegularExpression &re, int from = -1) const; #endif // QT_CONFIG(regularexpression) - using QVector<QString>::indexOf; - using QVector<QString>::lastIndexOf; + using QList<QString>::indexOf; + using QList<QString>::lastIndexOf; }; Q_DECLARE_TYPEINFO(QStringList, Q_MOVABLE_TYPE); #ifndef Q_QDOC -inline QStringList *QVectorSpecialMethods<QString>::self() +inline QStringList *QListSpecialMethods<QString>::self() { return static_cast<QStringList *>(this); } -inline const QStringList *QVectorSpecialMethods<QString>::self() const +inline const QStringList *QListSpecialMethods<QString>::self() const { return static_cast<const QStringList *>(this); } namespace QtPrivate { @@ -190,45 +190,45 @@ namespace QtPrivate { #endif // QT_CONFIG(regularexpression) } -inline void QVectorSpecialMethods<QString>::sort(Qt::CaseSensitivity cs) +inline void QListSpecialMethods<QString>::sort(Qt::CaseSensitivity cs) { QtPrivate::QStringList_sort(self(), cs); } -inline int QVectorSpecialMethods<QString>::removeDuplicates() +inline int QListSpecialMethods<QString>::removeDuplicates() { return QtPrivate::QStringList_removeDuplicates(self()); } #if QT_STRINGVIEW_LEVEL < 2 -inline QString QVectorSpecialMethods<QString>::join(const QString &sep) const +inline QString QListSpecialMethods<QString>::join(const QString &sep) const { return QtPrivate::QStringList_join(self(), sep.constData(), sep.length()); } #endif -inline QString QVectorSpecialMethods<QString>::join(QStringView sep) const +inline QString QListSpecialMethods<QString>::join(QStringView sep) const { return QtPrivate::QStringList_join(self(), sep); } -QString QVectorSpecialMethods<QString>::join(QLatin1String sep) const +QString QListSpecialMethods<QString>::join(QLatin1String sep) const { return QtPrivate::QStringList_join(*self(), sep); } -inline QString QVectorSpecialMethods<QString>::join(QChar sep) const +inline QString QListSpecialMethods<QString>::join(QChar sep) const { return QtPrivate::QStringList_join(self(), &sep, 1); } -inline QStringList QVectorSpecialMethods<QString>::filter(QStringView str, Qt::CaseSensitivity cs) const +inline QStringList QListSpecialMethods<QString>::filter(QStringView str, Qt::CaseSensitivity cs) const { return QtPrivate::QStringList_filter(self(), str, cs); } #if QT_STRINGVIEW_LEVEL < 2 -inline QStringList QVectorSpecialMethods<QString>::filter(const QString &str, Qt::CaseSensitivity cs) const +inline QStringList QListSpecialMethods<QString>::filter(const QString &str, Qt::CaseSensitivity cs) const { return QtPrivate::QStringList_filter(self(), str, cs); } @@ -251,33 +251,33 @@ inline bool QStringList::contains(QStringView str, Qt::CaseSensitivity cs) const return QtPrivate::QStringList_contains(this, str, cs); } -inline QStringList &QVectorSpecialMethods<QString>::replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs) +inline QStringList &QListSpecialMethods<QString>::replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs) { QtPrivate::QStringList_replaceInStrings(self(), before, after, cs); return *self(); } #if QT_STRINGVIEW_LEVEL < 2 -inline QStringList &QVectorSpecialMethods<QString>::replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs) +inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs) { QtPrivate::QStringList_replaceInStrings(self(), before, after, cs); return *self(); } -inline QStringList &QVectorSpecialMethods<QString>::replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs) +inline QStringList &QListSpecialMethods<QString>::replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs) { QtPrivate::QStringList_replaceInStrings(self(), before, qToStringViewIgnoringNull(after), cs); return *self(); } -inline QStringList &QVectorSpecialMethods<QString>::replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs) +inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs) { QtPrivate::QStringList_replaceInStrings(self(), QStringView(before), after, cs); return *self(); } #endif -inline QStringList operator+(const QVector<QString> &one, const QStringList &other) +inline QStringList operator+(const QList<QString> &one, const QStringList &other) { QStringList n = one; n += other; @@ -305,13 +305,13 @@ inline int QStringList::lastIndexOf(QLatin1String string, int from) const } #if QT_CONFIG(regularexpression) -inline QStringList &QVectorSpecialMethods<QString>::replaceInStrings(const QRegularExpression &rx, const QString &after) +inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QRegularExpression &rx, const QString &after) { QtPrivate::QStringList_replaceInStrings(self(), rx, after); return *self(); } -inline QStringList QVectorSpecialMethods<QString>::filter(const QRegularExpression &rx) const +inline QStringList QListSpecialMethods<QString>::filter(const QRegularExpression &rx) const { return QtPrivate::QStringList_filter(self(), rx); } diff --git a/src/corelib/text/qstringtokenizer.h b/src/corelib/text/qstringtokenizer.h index 31bbbf01c8..d042fbbdab 100644 --- a/src/corelib/text/qstringtokenizer.h +++ b/src/corelib/text/qstringtokenizer.h @@ -40,11 +40,11 @@ #define QSTRINGTOKENIZER_H #include <QtCore/qnamespace.h> +#include <QtCore/qcontainerfwd.h> QT_BEGIN_NAMESPACE template <typename, typename> class QStringBuilder; -template <typename> class QVector; #if defined(Q_QDOC) || 1 || (defined(__cpp_range_based_for) && __cpp_range_based_for >= 201603) # define Q_STRINGTOKENIZER_USE_SENTINEL |