Make QStringList an alias to QList<QString>
Fix our API, so that QStringList and QList<QString> are the same thing. This required a bit of refactoring in QList and moving the indexOf(), lastIndexOf() and contains() method into QListSpecialMethods. In addition, we need to ensure that the QStringList(const QString&) constructor is still available for compatibility with Qt 5. Once those two are done, all methods in QStringList can be moved into QListSpecialMethods<QString>. Change-Id: Ib8afbf5b6d9df4d0d47051252233506f62335fa3 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
ead02871cc
commit
652bd1efca
@ -61,7 +61,6 @@ class QPainterPath;
|
||||
class QPoint;
|
||||
class QRect;
|
||||
class QString;
|
||||
class QStringList;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
//! [0]
|
||||
|
@ -57,7 +57,6 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
class QStringList;
|
||||
class QTreeWidget;
|
||||
class QTreeWidgetItem;
|
||||
QT_END_NAMESPACE
|
||||
|
@ -55,7 +55,6 @@
|
||||
|
||||
class QSignalMapper;
|
||||
class QString;
|
||||
class QStringList;
|
||||
|
||||
//! [0]
|
||||
class ButtonWidget : public QWidget
|
||||
|
@ -46,8 +46,6 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QStringList;
|
||||
|
||||
class Q_CORE_EXPORT QLibraryInfo
|
||||
{
|
||||
public:
|
||||
|
@ -62,7 +62,6 @@ QT_BEGIN_NAMESPACE
|
||||
class QCoreApplicationPrivate;
|
||||
class QTranslator;
|
||||
class QPostEventList;
|
||||
class QStringList;
|
||||
class QAbstractEventDispatcher;
|
||||
class QAbstractNativeEventFilter;
|
||||
|
||||
|
@ -60,7 +60,6 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QRunnable;
|
||||
class QStringList;
|
||||
|
||||
namespace QtAndroidPrivate
|
||||
{
|
||||
|
@ -125,7 +125,6 @@ inline constexpr int qMetaTypeId();
|
||||
#define QT_FOR_EACH_STATIC_CORE_CLASS(F)\
|
||||
F(QChar, 7, QChar) \
|
||||
F(QString, 10, QString) \
|
||||
F(QStringList, 11, QStringList) \
|
||||
F(QByteArray, 12, QByteArray) \
|
||||
F(QBitArray, 13, QBitArray) \
|
||||
F(QDate, 14, QDate) \
|
||||
@ -163,6 +162,7 @@ inline constexpr int qMetaTypeId();
|
||||
F(QVariantHash, 28, QVariantHash) \
|
||||
F(QVariantPair, 58, QVariantPair) \
|
||||
F(QByteArrayList, 49, QByteArrayList) \
|
||||
F(QStringList, 11, QStringList) \
|
||||
|
||||
#if QT_CONFIG(shortcut)
|
||||
#define QT_FOR_EACH_STATIC_KEYSEQUENCE_CLASS(F)\
|
||||
@ -221,6 +221,7 @@ inline constexpr int qMetaTypeId();
|
||||
F(QVariantHash, -1, QVariantHash, "QHash<QString,QVariant>") \
|
||||
F(QVariantPair, -1, QVariantPair, "QPair<QVariant,QVariant>") \
|
||||
F(QByteArrayList, -1, QByteArrayList, "QList<QByteArray>") \
|
||||
F(QStringList, -1, QStringList, "QList<QString>") \
|
||||
|
||||
#define QT_FOR_EACH_STATIC_TYPE(F)\
|
||||
QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(F)\
|
||||
|
@ -74,7 +74,6 @@ class QLine;
|
||||
class QLineF;
|
||||
class QLocale;
|
||||
class QTransform;
|
||||
class QStringList;
|
||||
class QTime;
|
||||
class QPoint;
|
||||
class QPointF;
|
||||
|
@ -48,7 +48,6 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDebug;
|
||||
class QStringList;
|
||||
typedef QList<QVariant> QVariantList;
|
||||
|
||||
class Q_CORE_EXPORT QJsonArray
|
||||
|
@ -54,7 +54,6 @@ typedef QMutableListIterator<QByteArray> QMutableByteArrayListIterator;
|
||||
#endif
|
||||
|
||||
#ifndef Q_CLANG_QDOC
|
||||
typedef QList<QByteArray> QByteArrayList;
|
||||
|
||||
namespace QtPrivate {
|
||||
QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *separator, int separatorLength);
|
||||
@ -73,6 +72,13 @@ protected:
|
||||
~QListSpecialMethods() = default;
|
||||
#endif
|
||||
public:
|
||||
qsizetype indexOf(const QByteArray &ba, qsizetype from = 0) const noexcept
|
||||
{ return QtPrivate::indexOf(*self(), ba, from); }
|
||||
qsizetype lastIndexOf(const QByteArray &ba, qsizetype from = -1) const noexcept
|
||||
{ return QtPrivate::lastIndexOf(*self(), ba, from); }
|
||||
bool contains(const QByteArray &ba) const noexcept
|
||||
{ return indexOf(ba) != -1; }
|
||||
|
||||
inline QByteArray join() const
|
||||
{ return QtPrivate::QByteArrayList_join(self(), nullptr, 0); }
|
||||
inline QByteArray join(const QByteArray &sep) const
|
||||
|
@ -51,7 +51,6 @@ QT_REQUIRE_CONFIG(regularexpression);
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QStringList;
|
||||
class QLatin1String;
|
||||
|
||||
class QRegularExpressionMatch;
|
||||
|
@ -75,7 +75,6 @@ QT_BEGIN_NAMESPACE
|
||||
class QRegularExpression;
|
||||
class QRegularExpressionMatch;
|
||||
class QString;
|
||||
class QStringList;
|
||||
|
||||
namespace QtPrivate {
|
||||
template <bool...B> class BoolList;
|
||||
|
@ -57,101 +57,6 @@ using QStringListIterator = QListIterator<QString>;
|
||||
using QMutableStringListIterator = QMutableListIterator<QString>;
|
||||
#endif
|
||||
|
||||
class QStringList;
|
||||
|
||||
#ifdef Q_QDOC
|
||||
class QStringList : public QList<QString>
|
||||
#else
|
||||
template <> struct QListSpecialMethods<QString>
|
||||
#endif
|
||||
{
|
||||
#ifndef Q_QDOC
|
||||
protected:
|
||||
~QListSpecialMethods() = default;
|
||||
#endif
|
||||
public:
|
||||
inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive);
|
||||
inline qsizetype removeDuplicates();
|
||||
|
||||
#if QT_STRINGVIEW_LEVEL < 2
|
||||
inline QString join(const QString &sep) const;
|
||||
#endif
|
||||
inline QString join(QStringView sep) const;
|
||||
inline QString join(QLatin1String sep) const;
|
||||
inline QString join(QChar sep) const;
|
||||
|
||||
inline QStringList filter(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
||||
inline QStringList &replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
|
||||
#if QT_STRINGVIEW_LEVEL < 2
|
||||
inline QStringList filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
||||
inline QStringList &replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
|
||||
inline QStringList &replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
|
||||
inline QStringList &replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
|
||||
#endif
|
||||
|
||||
#if QT_CONFIG(regularexpression)
|
||||
inline QStringList filter(const QRegularExpression &re) const;
|
||||
inline QStringList &replaceInStrings(const QRegularExpression &re, const QString &after);
|
||||
#endif // QT_CONFIG(regularexpression)
|
||||
|
||||
#ifndef Q_QDOC
|
||||
private:
|
||||
inline QStringList *self();
|
||||
inline const QStringList *self() const;
|
||||
};
|
||||
|
||||
// ### Qt6: check if there's a better way
|
||||
class QStringList : public QList<QString>
|
||||
{
|
||||
#endif
|
||||
public:
|
||||
using QList<QString>::QList;
|
||||
inline explicit QStringList(const QString &i) { append(i); }
|
||||
inline QStringList(const QList<QString> &l) : QList<QString>(l) { }
|
||||
inline QStringList(QList<QString> &&l) noexcept : QList<QString>(std::move(l)) { }
|
||||
|
||||
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;
|
||||
#endif
|
||||
inline bool contains(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
||||
inline bool contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
|
||||
|
||||
inline QStringList operator+(const QStringList &other) const
|
||||
{ QStringList n = *this; n += other; return n; }
|
||||
inline QStringList &operator<<(const QString &str)
|
||||
{ append(str); return *this; }
|
||||
inline QStringList &operator<<(const QStringList &l)
|
||||
{ *this += l; return *this; }
|
||||
inline QStringList &operator<<(const QList<QString> &l)
|
||||
{ *this += l; return *this; }
|
||||
|
||||
inline qsizetype indexOf(QStringView str, qsizetype from = 0) const;
|
||||
inline qsizetype indexOf(QLatin1String str, qsizetype from = 0) const;
|
||||
|
||||
inline qsizetype lastIndexOf(QStringView str, qsizetype from = -1) const;
|
||||
inline qsizetype lastIndexOf(QLatin1String str, qsizetype from = -1) const;
|
||||
|
||||
#if QT_CONFIG(regularexpression)
|
||||
inline qsizetype indexOf(const QRegularExpression &re, qsizetype from = 0) const;
|
||||
inline qsizetype lastIndexOf(const QRegularExpression &re, qsizetype from = -1) const;
|
||||
#endif // QT_CONFIG(regularexpression)
|
||||
|
||||
using QList<QString>::indexOf;
|
||||
using QList<QString>::lastIndexOf;
|
||||
};
|
||||
|
||||
Q_DECLARE_TYPEINFO(QStringList, Q_MOVABLE_TYPE);
|
||||
|
||||
#ifndef Q_QDOC
|
||||
inline QStringList *QListSpecialMethods<QString>::self()
|
||||
{ return static_cast<QStringList *>(this); }
|
||||
inline const QStringList *QListSpecialMethods<QString>::self() const
|
||||
{ return static_cast<const QStringList *>(this); }
|
||||
|
||||
namespace QtPrivate {
|
||||
void Q_CORE_EXPORT QStringList_sort(QStringList *that, Qt::CaseSensitivity cs);
|
||||
@ -174,143 +79,98 @@ namespace QtPrivate {
|
||||
#endif // QT_CONFIG(regularexpression)
|
||||
}
|
||||
|
||||
inline void QListSpecialMethods<QString>::sort(Qt::CaseSensitivity cs)
|
||||
#ifdef Q_QDOC
|
||||
class QStringList : public QList<QString>
|
||||
#else
|
||||
template <> struct QListSpecialMethods<QString>
|
||||
#endif
|
||||
{
|
||||
QtPrivate::QStringList_sort(self(), cs);
|
||||
}
|
||||
inline QStringList *self()
|
||||
{ return static_cast<QStringList *>(this); }
|
||||
inline const QStringList *self() const
|
||||
{ return static_cast<const QStringList *>(this); }
|
||||
|
||||
inline qsizetype QListSpecialMethods<QString>::removeDuplicates()
|
||||
{
|
||||
return QtPrivate::QStringList_removeDuplicates(self());
|
||||
}
|
||||
public:
|
||||
inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive)
|
||||
{ QtPrivate::QStringList_sort(self(), cs); }
|
||||
inline qsizetype removeDuplicates()
|
||||
{ return QtPrivate::QStringList_removeDuplicates(self()); }
|
||||
|
||||
inline QString join(QStringView sep) const
|
||||
{ return QtPrivate::QStringList_join(self(), sep); }
|
||||
inline QString join(QLatin1String sep) const
|
||||
{ return QtPrivate::QStringList_join(*self(), sep); }
|
||||
inline QString join(QChar sep) const
|
||||
{ return QtPrivate::QStringList_join(self(), &sep, 1); }
|
||||
|
||||
inline QStringList filter(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
|
||||
{ return QtPrivate::QStringList_filter(self(), str, cs); }
|
||||
inline QStringList &replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
|
||||
{
|
||||
QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
|
||||
return *self();
|
||||
}
|
||||
|
||||
#if QT_STRINGVIEW_LEVEL < 2
|
||||
inline QString QListSpecialMethods<QString>::join(const QString &sep) const
|
||||
{
|
||||
return QtPrivate::QStringList_join(self(), sep.constData(), sep.length());
|
||||
}
|
||||
inline QString join(const QString &sep) const
|
||||
{ return QtPrivate::QStringList_join(self(), sep.constData(), sep.length()); }
|
||||
inline QStringList filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
|
||||
{ return QtPrivate::QStringList_filter(self(), str, cs); }
|
||||
inline QStringList &replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
|
||||
{
|
||||
QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
|
||||
return *self();
|
||||
}
|
||||
inline QStringList &replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
|
||||
{
|
||||
QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
|
||||
return *self();
|
||||
}
|
||||
inline QStringList &replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
|
||||
{
|
||||
QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
|
||||
return *self();
|
||||
}
|
||||
#endif
|
||||
|
||||
inline QString QListSpecialMethods<QString>::join(QStringView sep) const
|
||||
{
|
||||
return QtPrivate::QStringList_join(self(), sep);
|
||||
}
|
||||
inline bool contains(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
|
||||
{ return QtPrivate::QStringList_contains(self(), str, cs); }
|
||||
inline bool contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
|
||||
{ return QtPrivate::QStringList_contains(self(), str, cs); }
|
||||
|
||||
QString QListSpecialMethods<QString>::join(QLatin1String sep) const
|
||||
{
|
||||
return QtPrivate::QStringList_join(*self(), sep);
|
||||
}
|
||||
inline qsizetype indexOf(QStringView str, qsizetype from = 0) const noexcept
|
||||
{ return QtPrivate::indexOf<QString, QStringView>(*self(), str, from); }
|
||||
inline qsizetype indexOf(QLatin1String str, qsizetype from = 0) const noexcept
|
||||
{ return QtPrivate::indexOf<QString, QLatin1String>(*self(), str, from); }
|
||||
|
||||
inline QString QListSpecialMethods<QString>::join(QChar sep) const
|
||||
{
|
||||
return QtPrivate::QStringList_join(self(), &sep, 1);
|
||||
}
|
||||
|
||||
inline QStringList QListSpecialMethods<QString>::filter(QStringView str, Qt::CaseSensitivity cs) const
|
||||
{
|
||||
return QtPrivate::QStringList_filter(self(), str, cs);
|
||||
}
|
||||
inline qsizetype lastIndexOf(QStringView str, qsizetype from = -1) const noexcept
|
||||
{ return QtPrivate::lastIndexOf<QString, QStringView>(*self(), str, from); }
|
||||
inline qsizetype lastIndexOf(QLatin1String str, qsizetype from = -1) const noexcept
|
||||
{ return QtPrivate::lastIndexOf<QString, QLatin1String>(*self(), str, from); }
|
||||
|
||||
#if QT_STRINGVIEW_LEVEL < 2
|
||||
inline QStringList QListSpecialMethods<QString>::filter(const QString &str, Qt::CaseSensitivity cs) const
|
||||
{
|
||||
return QtPrivate::QStringList_filter(self(), str, cs);
|
||||
}
|
||||
inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
|
||||
{ return QtPrivate::QStringList_contains(self(), str, cs); }
|
||||
qsizetype indexOf(const QString &str, qsizetype from = 0) const noexcept
|
||||
{ return indexOf(QStringView(str), from); }
|
||||
qsizetype lastIndexOf(const QString &str, qsizetype from = -1) const noexcept
|
||||
{ return lastIndexOf(QStringView(str), from); }
|
||||
#endif
|
||||
|
||||
#if QT_STRINGVIEW_LEVEL < 2
|
||||
inline bool QStringList::contains(const QString &str, Qt::CaseSensitivity cs) const
|
||||
{
|
||||
return QtPrivate::QStringList_contains(this, str, cs);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline bool QStringList::contains(QLatin1String str, Qt::CaseSensitivity cs) const
|
||||
{
|
||||
return QtPrivate::QStringList_contains(this, str, cs);
|
||||
}
|
||||
|
||||
inline bool QStringList::contains(QStringView str, Qt::CaseSensitivity cs) const
|
||||
{
|
||||
return QtPrivate::QStringList_contains(this, str, 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 &QListSpecialMethods<QString>::replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs)
|
||||
{
|
||||
QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
|
||||
return *self();
|
||||
}
|
||||
|
||||
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 &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 QList<QString> &one, const QStringList &other)
|
||||
{
|
||||
QStringList n = one;
|
||||
n += other;
|
||||
return n;
|
||||
}
|
||||
|
||||
inline qsizetype QStringList::indexOf(QStringView string, qsizetype from) const
|
||||
{
|
||||
return QtPrivate::indexOf<QString, QStringView>(*this, string, from);
|
||||
}
|
||||
|
||||
inline qsizetype QStringList::indexOf(QLatin1String string, qsizetype from) const
|
||||
{
|
||||
return QtPrivate::indexOf<QString, QLatin1String>(*this, string, from);
|
||||
}
|
||||
|
||||
inline qsizetype QStringList::lastIndexOf(QStringView string, qsizetype from) const
|
||||
{
|
||||
return QtPrivate::lastIndexOf<QString, QStringView>(*this, string, from);
|
||||
}
|
||||
|
||||
inline qsizetype QStringList::lastIndexOf(QLatin1String string, qsizetype from) const
|
||||
{
|
||||
return QtPrivate::lastIndexOf<QString, QLatin1String>(*this, string, from);
|
||||
}
|
||||
|
||||
#if QT_CONFIG(regularexpression)
|
||||
inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QRegularExpression &rx, const QString &after)
|
||||
{
|
||||
QtPrivate::QStringList_replaceInStrings(self(), rx, after);
|
||||
return *self();
|
||||
}
|
||||
|
||||
inline QStringList QListSpecialMethods<QString>::filter(const QRegularExpression &rx) const
|
||||
{
|
||||
return QtPrivate::QStringList_filter(self(), rx);
|
||||
}
|
||||
|
||||
inline qsizetype QStringList::indexOf(const QRegularExpression &rx, qsizetype from) const
|
||||
{
|
||||
return QtPrivate::QStringList_indexOf(this, rx, from);
|
||||
}
|
||||
|
||||
inline qsizetype QStringList::lastIndexOf(const QRegularExpression &rx, qsizetype from) const
|
||||
{
|
||||
return QtPrivate::QStringList_lastIndexOf(this, rx, from);
|
||||
}
|
||||
inline QStringList filter(const QRegularExpression &re) const
|
||||
{ return QtPrivate::QStringList_filter(self(), re); }
|
||||
inline QStringList &replaceInStrings(const QRegularExpression &re, const QString &after)
|
||||
{
|
||||
QtPrivate::QStringList_replaceInStrings(self(), re, after);
|
||||
return *self();
|
||||
}
|
||||
inline qsizetype indexOf(const QRegularExpression &re, qsizetype from = 0) const
|
||||
{ return QtPrivate::QStringList_indexOf(self(), re, from); }
|
||||
inline qsizetype lastIndexOf(const QRegularExpression &re, qsizetype from = -1) const
|
||||
{ return QtPrivate::QStringList_lastIndexOf(self(), re, from); }
|
||||
#endif // QT_CONFIG(regularexpression)
|
||||
#endif // Q_QDOC
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
@ -61,7 +61,7 @@ template <class T> class QStack;
|
||||
template<class T, qsizetype Prealloc = 256> class QVarLengthArray;
|
||||
template <class T> class QList;
|
||||
template<typename T> using QVector = QList<T>;
|
||||
class QStringList;
|
||||
using QStringList = QList<QString>;
|
||||
using QByteArrayList = QList<QByteArray>;
|
||||
class QMetaType;
|
||||
class QVariant;
|
||||
|
@ -54,14 +54,22 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtPrivate {
|
||||
template <typename V, typename U> qsizetype indexOf(const QList<V> &list, const U &u, qsizetype from);
|
||||
template <typename V, typename U> qsizetype lastIndexOf(const QList<V> &list, const U &u, qsizetype from);
|
||||
template <typename V, typename U> qsizetype indexOf(const QList<V> &list, const U &u, qsizetype from) noexcept;
|
||||
template <typename V, typename U> qsizetype lastIndexOf(const QList<V> &list, const U &u, qsizetype from) noexcept;
|
||||
}
|
||||
|
||||
template <typename T> struct QListSpecialMethods
|
||||
{
|
||||
protected:
|
||||
~QListSpecialMethods() = default;
|
||||
public:
|
||||
qsizetype indexOf(const T &t, qsizetype from = 0) const noexcept;
|
||||
qsizetype lastIndexOf(const T &t, qsizetype from = -1) const noexcept;
|
||||
|
||||
bool contains(const T &t) const noexcept
|
||||
{
|
||||
return indexOf(t) != -1;
|
||||
}
|
||||
};
|
||||
template <> struct QListSpecialMethods<QByteArray>;
|
||||
template <> struct QListSpecialMethods<QString>;
|
||||
@ -79,8 +87,8 @@ class QList
|
||||
|
||||
DataPointer d;
|
||||
|
||||
template <typename V, typename U> friend qsizetype QtPrivate::indexOf(const QList<V> &list, const U &u, qsizetype from);
|
||||
template <typename V, typename U> friend qsizetype QtPrivate::lastIndexOf(const QList<V> &list, const U &u, qsizetype from);
|
||||
template <typename V, typename U> friend qsizetype QtPrivate::indexOf(const QList<V> &list, const U &u, qsizetype from) noexcept;
|
||||
template <typename V, typename U> friend qsizetype QtPrivate::lastIndexOf(const QList<V> &list, const U &u, qsizetype from) noexcept;
|
||||
|
||||
public:
|
||||
typedef T Type;
|
||||
@ -158,6 +166,11 @@ public:
|
||||
std::copy(i1, i2, std::back_inserter(*this));
|
||||
}
|
||||
|
||||
// This constructor is here for compatibility with QStringList in Qt 5, that has a QStringList(const QString &) constructor
|
||||
template<typename String, typename = std::enable_if_t<std::is_same_v<T, QString> && std::is_convertible_v<String, QString>>>
|
||||
inline explicit QList(const String &str)
|
||||
{ append(str); }
|
||||
|
||||
// compiler-generated special member functions are fine!
|
||||
|
||||
void swap(QList<T> &other) noexcept { qSwap(d, other.d); }
|
||||
@ -289,12 +302,10 @@ public:
|
||||
|
||||
QList<T> &fill(parameter_type t, qsizetype size = -1);
|
||||
|
||||
qsizetype indexOf(const T &t, qsizetype from = 0) const noexcept;
|
||||
qsizetype lastIndexOf(const T &t, qsizetype from = -1) const noexcept;
|
||||
bool contains(const T &t) const noexcept
|
||||
{
|
||||
return indexOf(t) != -1;
|
||||
}
|
||||
using QListSpecialMethods<T>::contains;
|
||||
using QListSpecialMethods<T>::indexOf;
|
||||
using QListSpecialMethods<T>::lastIndexOf;
|
||||
|
||||
qsizetype count(const T &t) const noexcept
|
||||
{
|
||||
return qsizetype(std::count(&*cbegin(), &*cend(), t));
|
||||
@ -705,7 +716,7 @@ inline QList<T> &QList<T>::fill(parameter_type t, qsizetype newSize)
|
||||
|
||||
namespace QtPrivate {
|
||||
template <typename T, typename U>
|
||||
qsizetype indexOf(const QList<T> &vector, const U &u, qsizetype from)
|
||||
qsizetype indexOf(const QList<T> &vector, const U &u, qsizetype from) noexcept
|
||||
{
|
||||
if (from < 0)
|
||||
from = qMax(from + vector.size(), qsizetype(0));
|
||||
@ -720,7 +731,7 @@ qsizetype indexOf(const QList<T> &vector, const U &u, qsizetype from)
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
qsizetype lastIndexOf(const QList<T> &vector, const U &u, qsizetype from)
|
||||
qsizetype lastIndexOf(const QList<T> &vector, const U &u, qsizetype from) noexcept
|
||||
{
|
||||
if (from < 0)
|
||||
from += vector.d->size;
|
||||
@ -739,15 +750,15 @@ qsizetype lastIndexOf(const QList<T> &vector, const U &u, qsizetype from)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
qsizetype QList<T>::indexOf(const T &t, qsizetype from) const noexcept
|
||||
qsizetype QListSpecialMethods<T>::indexOf(const T &t, qsizetype from) const noexcept
|
||||
{
|
||||
return QtPrivate::indexOf<T, T>(*this, t, from);
|
||||
return QtPrivate::indexOf(*static_cast<const QList<T> *>(this), t, from);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
qsizetype QList<T>::lastIndexOf(const T &t, qsizetype from) const noexcept
|
||||
qsizetype QListSpecialMethods<T>::lastIndexOf(const T &t, qsizetype from) const noexcept
|
||||
{
|
||||
return QtPrivate::lastIndexOf(*this, t, from);
|
||||
return QtPrivate::lastIndexOf(*static_cast<const QList<T> *>(this), t, from);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -49,7 +49,6 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_ACCESSIBILITY
|
||||
|
||||
class QStringList;
|
||||
class QAccessibleInterface;
|
||||
|
||||
#define QAccessibleFactoryInterface_iid "org.qt-project.Qt.QAccessibleFactoryInterface"
|
||||
|
@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
|
||||
class QColorSpace;
|
||||
class QColorTransform;
|
||||
class QIODevice;
|
||||
class QStringList;
|
||||
class QTransform;
|
||||
class QVariant;
|
||||
|
||||
|
@ -53,7 +53,6 @@ class QColor;
|
||||
class QIODevice;
|
||||
class QRect;
|
||||
class QSize;
|
||||
class QStringList;
|
||||
|
||||
class QImageReaderPrivate;
|
||||
class Q_GUI_EXPORT QImageReader
|
||||
|
@ -50,7 +50,6 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
class QFontPrivate; /* don't touch */
|
||||
class QStringList;
|
||||
class QVariant;
|
||||
|
||||
class Q_GUI_EXPORT QFont
|
||||
|
@ -48,7 +48,6 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
class QStringList;
|
||||
struct QFontDef;
|
||||
class QFontEngine;
|
||||
|
||||
|
@ -48,7 +48,6 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_DESKTOPSERVICES
|
||||
|
||||
class QStringList;
|
||||
class QUrl;
|
||||
class QObject;
|
||||
|
||||
|
@ -61,7 +61,6 @@ class QIODevice;
|
||||
class QSslError;
|
||||
class QSslKey;
|
||||
class QSslCertificateExtension;
|
||||
class QStringList;
|
||||
|
||||
class QSslCertificate;
|
||||
// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
|
||||
|
@ -68,8 +68,6 @@
|
||||
|
||||
#include <CoreFoundation/CFNumber.h>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QString)
|
||||
QT_FORWARD_DECLARE_CLASS(QStringList)
|
||||
QT_FORWARD_DECLARE_CLASS(QFileInfo)
|
||||
QT_FORWARD_DECLARE_CLASS(QWindow)
|
||||
QT_USE_NAMESPACE
|
||||
|
@ -47,7 +47,6 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
class QSqlField;
|
||||
class QStringList;
|
||||
class QVariant;
|
||||
class QSqlRecordPrivate;
|
||||
|
||||
|
@ -56,8 +56,6 @@
|
||||
#include <QtCore/qmap.h>
|
||||
#include <QtCore/qstring.h>
|
||||
|
||||
class QStringList;
|
||||
|
||||
QT_REQUIRE_CONFIG(valgrind);
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -499,13 +499,6 @@ bool qCompare(QList<T> const &t1, const T (& t2)[N],
|
||||
actual, expected, file, line);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline bool qCompare(QStringList const &t1, QStringList const &t2, const char *actual, const char *expected,
|
||||
const char *file, int line)
|
||||
{
|
||||
return qCompare<QString>(t1, t2, actual, expected, file, line);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool qCompare(QFlags<T> const &t1, T const &t2, const char *actual, const char *expected,
|
||||
const char *file, int line)
|
||||
|
@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
class QStringList;
|
||||
class QTextOption;
|
||||
|
||||
// Private class
|
||||
|
Loading…
Reference in New Issue
Block a user