summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstringlist.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qstringlist.h')
-rw-r--r--src/corelib/tools/qstringlist.h152
1 files changed, 85 insertions, 67 deletions
diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h
index b24a261a7c..89785208c8 100644
--- a/src/corelib/tools/qstringlist.h
+++ b/src/corelib/tools/qstringlist.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,41 +23,78 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
+#include <QtCore/qlist.h>
+
#ifndef QSTRINGLIST_H
#define QSTRINGLIST_H
#include <QtCore/qalgorithms.h>
-#include <QtCore/qdatastream.h>
-#include <QtCore/qlist.h>
#include <QtCore/qregexp.h>
#include <QtCore/qstring.h>
#include <QtCore/qstringmatcher.h>
QT_BEGIN_NAMESPACE
-
class QRegExp;
class QRegularExpression;
typedef QListIterator<QString> QStringListIterator;
typedef QMutableListIterator<QString> QMutableStringListIterator;
+class QStringList;
+
+#ifdef Q_QDOC
+class QStringList : public QList<QString>
+#else
+template <> struct QListSpecialMethods<QString>
+#endif
+{
+public:
+ inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive);
+ inline int removeDuplicates();
+
+ inline QString join(const QString &sep) const;
+ inline QString join(QChar sep) const;
+
+ 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);
+
+#ifndef QT_NO_REGEXP
+ inline QStringList filter(const QRegExp &rx) const;
+ inline QStringList &replaceInStrings(const QRegExp &rx, const QString &after);
+#endif
+
+#ifndef QT_BOOTSTRAPPED
+#ifndef QT_NO_REGULAREXPRESSION
+ inline QStringList filter(const QRegularExpression &re) const;
+ inline QStringList &replaceInStrings(const QRegularExpression &re, const QString &after);
+#endif // QT_NO_REGULAREXPRESSION
+#endif // QT_BOOTSTRAPPED
+
+#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:
- inline QStringList() { }
+ inline QStringList() Q_DECL_NOTHROW { }
inline explicit QStringList(const QString &i) { append(i); }
inline QStringList(const QList<QString> &l) : QList<QString>(l) { }
#ifdef Q_COMPILER_RVALUE_REFS
- inline QStringList(QList<QString> &&l) : QList<QString>(std::move(l)) { }
+ inline QStringList(QList<QString> &&l) Q_DECL_NOTHROW : QList<QString>(std::move(l)) { }
#endif
#ifdef Q_COMPILER_INITIALIZER_LISTS
inline QStringList(std::initializer_list<QString> args) : QList<QString>(args) { }
@@ -66,21 +103,12 @@ public:
QStringList &operator=(const QList<QString> &other)
{ QList<QString>::operator=(other); return *this; }
#ifdef Q_COMPILER_RVALUE_REFS
- QStringList &operator=(QList<QString> &&other)
+ QStringList &operator=(QList<QString> &&other) Q_DECL_NOTHROW
{ QList<QString>::operator=(std::move(other)); return *this; }
#endif
- inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive);
- inline int removeDuplicates();
-
- inline QString join(const QString &sep) const;
- inline QString join(QChar sep) const;
-
- inline QStringList filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
inline bool contains(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 operator+(const QStringList &other) const
{ QStringList n = *this; n += other; return n; }
inline QStringList &operator<<(const QString &str)
@@ -91,8 +119,6 @@ public:
{ *this += l; return *this; }
#ifndef QT_NO_REGEXP
- inline QStringList filter(const QRegExp &rx) const;
- inline QStringList &replaceInStrings(const QRegExp &rx, const QString &after);
inline int indexOf(const QRegExp &rx, int from = 0) const;
inline int lastIndexOf(const QRegExp &rx, int from = -1) const;
inline int indexOf(QRegExp &rx, int from = 0) const;
@@ -101,26 +127,22 @@ public:
#ifndef QT_BOOTSTRAPPED
#ifndef QT_NO_REGULAREXPRESSION
- inline QStringList filter(const QRegularExpression &re) const;
- inline QStringList &replaceInStrings(const QRegularExpression &re, const QString &after);
inline int indexOf(const QRegularExpression &re, int from = 0) const;
inline int lastIndexOf(const QRegularExpression &re, int from = -1) const;
#endif // QT_NO_REGULAREXPRESSION
#endif // QT_BOOTSTRAPPED
-#if !defined(Q_NO_USING_KEYWORD)
using QList<QString>::indexOf;
using QList<QString>::lastIndexOf;
-#else
- inline int indexOf(const QString &str, int from = 0) const
- { return QList<QString>::indexOf(str, from); }
- inline int lastIndexOf(const QString &str, int from = -1) const
- { return QList<QString>::lastIndexOf(str, from); }
-#endif
};
Q_DECLARE_TYPEINFO(QStringList, Q_MOVABLE_TYPE);
+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);
int Q_CORE_EXPORT QStringList_removeDuplicates(QStringList *that);
@@ -151,29 +173,29 @@ namespace QtPrivate {
#endif // QT_BOOTSTRAPPED
}
-inline void QStringList::sort(Qt::CaseSensitivity cs)
+inline void QListSpecialMethods<QString>::sort(Qt::CaseSensitivity cs)
{
- QtPrivate::QStringList_sort(this, cs);
+ QtPrivate::QStringList_sort(self(), cs);
}
-inline int QStringList::removeDuplicates()
+inline int QListSpecialMethods<QString>::removeDuplicates()
{
- return QtPrivate::QStringList_removeDuplicates(this);
+ return QtPrivate::QStringList_removeDuplicates(self());
}
-inline QString QStringList::join(const QString &sep) const
+inline QString QListSpecialMethods<QString>::join(const QString &sep) const
{
- return QtPrivate::QStringList_join(this, sep.constData(), sep.length());
+ return QtPrivate::QStringList_join(self(), sep.constData(), sep.length());
}
-inline QString QStringList::join(QChar sep) const
+inline QString QListSpecialMethods<QString>::join(QChar sep) const
{
- return QtPrivate::QStringList_join(this, &sep, 1);
+ return QtPrivate::QStringList_join(self(), &sep, 1);
}
-inline QStringList QStringList::filter(const QString &str, Qt::CaseSensitivity cs) const
+inline QStringList QListSpecialMethods<QString>::filter(const QString &str, Qt::CaseSensitivity cs) const
{
- return QtPrivate::QStringList_filter(this, str, cs);
+ return QtPrivate::QStringList_filter(self(), str, cs);
}
inline bool QStringList::contains(const QString &str, Qt::CaseSensitivity cs) const
@@ -181,22 +203,29 @@ inline bool QStringList::contains(const QString &str, Qt::CaseSensitivity cs) co
return QtPrivate::QStringList_contains(this, str, cs);
}
-inline QStringList &QStringList::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 operator+(const QList<QString> &one, const QStringList &other)
{
- QtPrivate::QStringList_replaceInStrings(this, before, after, cs);
- return *this;
+ QStringList n = one;
+ n += other;
+ return n;
}
#ifndef QT_NO_REGEXP
-inline QStringList &QStringList::replaceInStrings(const QRegExp &rx, const QString &after)
+inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QRegExp &rx, const QString &after)
{
- QtPrivate::QStringList_replaceInStrings(this, rx, after);
- return *this;
+ QtPrivate::QStringList_replaceInStrings(self(), rx, after);
+ return *self();
}
-inline QStringList QStringList::filter(const QRegExp &rx) const
+inline QStringList QListSpecialMethods<QString>::filter(const QRegExp &rx) const
{
- return QtPrivate::QStringList_filter(this, rx);
+ return QtPrivate::QStringList_filter(self(), rx);
}
inline int QStringList::indexOf(const QRegExp &rx, int from) const
@@ -222,15 +251,15 @@ inline int QStringList::lastIndexOf(QRegExp &rx, int from) const
#ifndef QT_BOOTSTRAPPED
#ifndef QT_NO_REGULAREXPRESSION
-inline QStringList &QStringList::replaceInStrings(const QRegularExpression &rx, const QString &after)
+inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QRegularExpression &rx, const QString &after)
{
- QtPrivate::QStringList_replaceInStrings(this, rx, after);
- return *this;
+ QtPrivate::QStringList_replaceInStrings(self(), rx, after);
+ return *self();
}
-inline QStringList QStringList::filter(const QRegularExpression &rx) const
+inline QStringList QListSpecialMethods<QString>::filter(const QRegularExpression &rx) const
{
- return QtPrivate::QStringList_filter(this, rx);
+ return QtPrivate::QStringList_filter(self(), rx);
}
inline int QStringList::indexOf(const QRegularExpression &rx, int from) const
@@ -245,17 +274,6 @@ inline int QStringList::lastIndexOf(const QRegularExpression &rx, int from) cons
#endif // QT_NO_REGULAREXPRESSION
#endif // QT_BOOTSTRAPPED
-#ifndef QT_NO_DATASTREAM
-inline QDataStream &operator>>(QDataStream &in, QStringList &list)
-{
- return operator>>(in, static_cast<QList<QString> &>(list));
-}
-inline QDataStream &operator<<(QDataStream &out, const QStringList &list)
-{
- return operator<<(out, static_cast<const QList<QString> &>(list));
-}
-#endif // QT_NO_DATASTREAM
-
QT_END_NAMESPACE
#endif // QSTRINGLIST_H