Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qstringlist.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// Copyright (C) 2016 Intel Corporation.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#include <QtCore/qlist.h>
6
7#ifndef QSTRINGLIST_H
8#define QSTRINGLIST_H
9
10#include <QtCore/qalgorithms.h>
11#include <QtCore/qcontainertools_impl.h>
12#include <QtCore/qstring.h>
13#include <QtCore/qstringmatcher.h>
14
16
18class QRegularExpression;
19
20#if !defined(QT_NO_JAVA_STYLE_ITERATORS)
21using QStringListIterator = QListIterator<QString>;
22using QMutableStringListIterator = QMutableListIterator<QString>;
23#endif
24
25
26namespace QtPrivate {
28 qsizetype Q_CORE_EXPORT QStringList_removeDuplicates(QStringList *that);
29 QString Q_CORE_EXPORT QStringList_join(const QStringList *that, QStringView sep);
30 QString Q_CORE_EXPORT QStringList_join(const QStringList *that, const QChar *sep, qsizetype seplen);
31 Q_CORE_EXPORT QString QStringList_join(const QStringList &list, QLatin1StringView sep);
32 QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, QStringView str,
34 Q_CORE_EXPORT QStringList QStringList_filter(const QStringList &that, QLatin1StringView needle,
36 Q_CORE_EXPORT QStringList QStringList_filter(const QStringList &that,
37 const QStringMatcher &matcher);
38 Q_CORE_EXPORT QStringList QStringList_filter(const QStringList &that,
40
45
46 qsizetype Q_CORE_EXPORT QStringList_indexOf(const QStringList &that, QStringView str,
48 qsizetype Q_CORE_EXPORT QStringList_indexOf(const QStringList &that, QLatin1StringView str,
50
51 Q_CORE_EXPORT qsizetype QStringList_lastIndexOf(const QStringList &that, QStringView str,
53 Q_CORE_EXPORT qsizetype QStringList_lastIndexOf(const QStringList &that, QLatin1StringView str,
55
56#if QT_CONFIG(regularexpression)
61#endif // QT_CONFIG(regularexpression)
62}
63
64#ifdef Q_QDOC
65class QStringList : public QList<QString>
66#else
67template <> struct QListSpecialMethods<QString> : QListSpecialMethodsBase<QString>
68#endif
69{
70#ifdef Q_QDOC
71public:
72 using QList<QString>::QList;
73 QStringList(const QString &str);
74 QStringList(const QList<QString> &other);
75 QStringList(QList<QString> &&other);
76
77 QStringList &operator=(const QList<QString> &other);
78 QStringList &operator=(QList<QString> &&other);
79 QStringList operator+(const QStringList &other) const;
80 QStringList &operator<<(const QString &str);
81 QStringList &operator<<(const QStringList &other);
82 QStringList &operator<<(const QList<QString> &other);
83private:
84#endif
85
86public:
87 inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive)
88 { QtPrivate::QStringList_sort(self(), cs); }
90 { return QtPrivate::QStringList_removeDuplicates(self()); }
91
92 inline QString join(QStringView sep) const
93 { return QtPrivate::QStringList_join(self(), sep); }
94 inline QString join(QLatin1StringView sep) const
95 { return QtPrivate::QStringList_join(*self(), sep); }
96 inline QString join(QChar sep) const
97 { return QtPrivate::QStringList_join(self(), &sep, 1); }
98
99 QStringList filter(const QStringMatcher &matcher) const
100 { return QtPrivate::QStringList_filter(*self(), matcher); }
102 { return QtPrivate::QStringList_filter(*self(), matcher); }
103
104 QStringList filter(QLatin1StringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
105 { return QtPrivate::QStringList_filter(*self(), needle, cs); }
106 inline QStringList filter(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
107 { return QtPrivate::QStringList_filter(self(), str, cs); }
108 inline QStringList &replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
109 {
110 QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
111 return *self();
112 }
113
114 inline QString join(const QString &sep) const
115 { return QtPrivate::QStringList_join(self(), sep.constData(), sep.size()); }
116 inline QStringList filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
117 { return QtPrivate::QStringList_filter(self(), str, cs); }
118 inline QStringList &replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
119 {
120 QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
121 return *self();
122 }
123 inline QStringList &replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
124 {
125 QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
126 return *self();
127 }
128 inline QStringList &replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
129 {
130 QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
131 return *self();
132 }
133 using QListSpecialMethodsBase<QString>::contains;
134 using QListSpecialMethodsBase<QString>::indexOf;
135 using QListSpecialMethodsBase<QString>::lastIndexOf;
136
137 inline bool contains(QLatin1StringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
138 { return QtPrivate::QStringList_contains(self(), str, cs); }
139 inline bool contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
140 { return QtPrivate::QStringList_contains(self(), str, cs); }
141
142 inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
143 { return QtPrivate::QStringList_contains(self(), str, cs); }
144
145 qsizetype indexOf(const QString &str, qsizetype from = 0,
146 Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
147 { return indexOf(QStringView(str), from, cs); }
148 qsizetype indexOf(QStringView needle, qsizetype from = 0,
149 Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
150 { return QtPrivate::QStringList_indexOf(*self(), needle, from, cs); }
151 qsizetype indexOf(QLatin1StringView needle, qsizetype from = 0,
152 Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
153 { return QtPrivate::QStringList_indexOf(*self(), needle, from, cs); }
154
155 qsizetype lastIndexOf(const QString &str, qsizetype from = -1,
156 Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
157 { return lastIndexOf(QStringView(str), from, cs); }
158 qsizetype lastIndexOf(QStringView str, qsizetype from = -1,
159 Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
160 { return QtPrivate::QStringList_lastIndexOf(*self(), str, from, cs); }
161 qsizetype lastIndexOf(QLatin1StringView needle, qsizetype from = -1,
162 Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
163 { return QtPrivate::QStringList_lastIndexOf(*self(), needle, from, cs); }
164
165#if QT_CONFIG(regularexpression)
166 inline QStringList filter(const QRegularExpression &re) const
167 { return QtPrivate::QStringList_filter(self(), re); }
168 inline QStringList &replaceInStrings(const QRegularExpression &re, const QString &after)
169 {
170 QtPrivate::QStringList_replaceInStrings(self(), re, after);
171 return *self();
172 }
173 inline qsizetype indexOf(const QRegularExpression &re, qsizetype from = 0) const
174 { return QtPrivate::QStringList_indexOf(self(), re, from); }
175 inline qsizetype lastIndexOf(const QRegularExpression &re, qsizetype from = -1) const
176 { return QtPrivate::QStringList_lastIndexOf(self(), re, from); }
177#endif // QT_CONFIG(regularexpression)
178};
179
180QT_END_NAMESPACE
181
182#endif // QSTRINGLIST_H
#define ARCH_FULL
Combined button and popup list for selecting options.
\macro QT_NO_KEYWORDS >
Definition qcompare.h:24
static const char * qt_build_string() noexcept
static QString getPrefix(QLibraryInfoPrivate::UsageMode usageMode)
void qDumpCPUFeatures()
Definition qsimd.cpp:688
static QString prefixFromAppDirHelper()
#define SHARED_STRING
static bool keepQtBuildDefaults()
#define COMPILER_STRING
#define DEBUG_STRING
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
qsizetype indexOf(const QString &str, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QStringList filter(const QLatin1StringMatcher &matcher) const
void sort(Qt::CaseSensitivity cs=Qt::CaseSensitive)
Definition qstringlist.h:87
QString join(const QString &sep) const
qsizetype indexOf(QStringView needle, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QStringList & replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QString join(QStringView sep) const
Definition qstringlist.h:92
qsizetype lastIndexOf(QStringView str, qsizetype from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QStringList filter(QLatin1StringView needle, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QStringList filter(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QStringList & replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QStringList & replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QStringList & replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QStringList filter(const QStringMatcher &matcher) const
Definition qstringlist.h:99
qsizetype lastIndexOf(const QString &str, qsizetype from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept