Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
18
19#if !defined(QT_NO_JAVA_STYLE_ITERATORS)
20using QStringListIterator = QListIterator<QString>;
21using QMutableStringListIterator = QMutableListIterator<QString>;
22#endif
23
24
25namespace QtPrivate {
26 void Q_CORE_EXPORT QStringList_sort(QStringList *that, Qt::CaseSensitivity cs);
28 QString Q_CORE_EXPORT QStringList_join(const QStringList *that, QStringView sep);
29 QString Q_CORE_EXPORT QStringList_join(const QStringList *that, const QChar *sep, qsizetype seplen);
31 QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, QStringView str,
33 Q_CORE_EXPORT QStringList QStringList_filter(const QStringList &that, QLatin1StringView needle,
35 Q_CORE_EXPORT QStringList QStringList_filter(const QStringList &that,
36 const QStringMatcher &matcher);
37
38 bool Q_CORE_EXPORT QStringList_contains(const QStringList *that, QStringView str, Qt::CaseSensitivity cs);
40 void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, QStringView before, QStringView after,
42
43 qsizetype Q_CORE_EXPORT QStringList_indexOf(const QStringList &that, QStringView str,
47
52
53#if QT_CONFIG(regularexpression)
54 void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, const QRegularExpression &rx, const QString &after);
55 QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, const QRegularExpression &re);
56 qsizetype Q_CORE_EXPORT QStringList_indexOf(const QStringList *that, const QRegularExpression &re, qsizetype from);
57 qsizetype Q_CORE_EXPORT QStringList_lastIndexOf(const QStringList *that, const QRegularExpression &re, qsizetype from);
58#endif // QT_CONFIG(regularexpression)
59}
60
61#ifdef Q_QDOC
62class QStringList : public QList<QString>
63#else
64template <> struct QListSpecialMethods<QString> : QListSpecialMethodsBase<QString>
65#endif
66{
67#ifdef Q_QDOC
68public:
69 using QList<QString>::QList;
70 QStringList(const QString &str);
71 QStringList(const QList<QString> &other);
72 QStringList(QList<QString> &&other);
73
74 QStringList &operator=(const QList<QString> &other);
75 QStringList &operator=(QList<QString> &&other);
79 QStringList &operator<<(const QList<QString> &other);
80private:
81#endif
82
83public:
84 inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive)
85 { QtPrivate::QStringList_sort(self(), cs); }
86 inline qsizetype removeDuplicates()
88
89 inline QString join(QStringView sep) const
91 inline QString join(QLatin1StringView sep) const
92 { return QtPrivate::QStringList_join(*self(), sep); }
93 inline QString join(QChar sep) const
94 { return QtPrivate::QStringList_join(self(), &sep, 1); }
95
99 { return QtPrivate::QStringList_filter(*self(), needle, cs); }
101 { return QtPrivate::QStringList_filter(self(), str, cs); }
102 inline QStringList &replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
103 {
104 QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
105 return *self();
106 }
107
108 inline QString join(const QString &sep) const
109 { return QtPrivate::QStringList_join(self(), sep.constData(), sep.size()); }
111 { return QtPrivate::QStringList_filter(self(), str, cs); }
112 inline QStringList &replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
113 {
114 QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
115 return *self();
116 }
117 inline QStringList &replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
118 {
119 QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
120 return *self();
121 }
122 inline QStringList &replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
123 {
124 QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
125 return *self();
126 }
130
131 inline bool contains(QLatin1StringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
132 { return QtPrivate::QStringList_contains(self(), str, cs); }
133 inline bool contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
134 { return QtPrivate::QStringList_contains(self(), str, cs); }
135
136 inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
137 { return QtPrivate::QStringList_contains(self(), str, cs); }
138
139 qsizetype indexOf(const QString &str, qsizetype from = 0,
140 Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
141 { return indexOf(QStringView(str), from, cs); }
142 qsizetype indexOf(QStringView needle, qsizetype from = 0,
143 Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
144 { return QtPrivate::QStringList_indexOf(*self(), needle, from, cs); }
146 Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
147 { return QtPrivate::QStringList_indexOf(*self(), needle, from, cs); }
148
149 qsizetype lastIndexOf(const QString &str, qsizetype from = -1,
150 Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
151 { return lastIndexOf(QStringView(str), from, cs); }
153 Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
154 { return QtPrivate::QStringList_lastIndexOf(*self(), str, from, cs); }
156 Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
157 { return QtPrivate::QStringList_lastIndexOf(*self(), needle, from, cs); }
158
159#if QT_CONFIG(regularexpression)
160 inline QStringList filter(const QRegularExpression &re) const
161 { return QtPrivate::QStringList_filter(self(), re); }
162 inline QStringList &replaceInStrings(const QRegularExpression &re, const QString &after)
163 {
165 return *self();
166 }
167 inline qsizetype indexOf(const QRegularExpression &re, qsizetype from = 0) const
168 { return QtPrivate::QStringList_indexOf(self(), re, from); }
169 inline qsizetype lastIndexOf(const QRegularExpression &re, qsizetype from = -1) const
170 { return QtPrivate::QStringList_lastIndexOf(self(), re, from); }
171#endif // QT_CONFIG(regularexpression)
172};
173
175
176#endif // QSTRINGLIST_H
\inmodule QtCore
Definition qlist.h:75
\inmodule QtCore \reentrant
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore
Definition qstringview.h:78
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QString str
[2]
Combined button and popup list for selecting options.
\macro QT_NO_KEYWORDS >
void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, QStringView before, QStringView after, Qt::CaseSensitivity cs)
bool Q_CORE_EXPORT QStringList_contains(const QStringList *that, QStringView str, Qt::CaseSensitivity cs)
qsizetype Q_CORE_EXPORT QStringList_indexOf(const QStringList &that, QStringView str, qsizetype from, Qt::CaseSensitivity cs)
QString Q_CORE_EXPORT QStringList_join(const QStringList *that, QStringView sep)
qsizetype Q_CORE_EXPORT QStringList_removeDuplicates(QStringList *that)
QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, QStringView str, Qt::CaseSensitivity cs)
void Q_CORE_EXPORT QStringList_sort(QStringList *that, Qt::CaseSensitivity cs)
Q_CORE_EXPORT qsizetype QStringList_lastIndexOf(const QStringList &that, QStringView str, qsizetype from, Qt::CaseSensitivity cs)
CaseSensitivity
@ CaseSensitive
QString self
Definition language.cpp:58
QList< QString > QStringList
Constructs a string list that contains the given string, str.
constexpr timespec operator+(const timespec &t1, const timespec &t2)
QList(InputIterator, InputIterator) -> QList< ValueType >
static bool contains(const QJsonArray &haystack, unsigned needle)
Definition qopengl.cpp:116
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
static constexpr QChar sep
QListIterator< QString > QStringListIterator
Definition qstringlist.h:20
QMutableListIterator< QString > QMutableStringListIterator
Definition qstringlist.h:21
ptrdiff_t qsizetype
Definition qtypes.h:165
QList< int > list
[14]
QDataStream & operator<<(QDataStream &out, const MyClass &myObj)
[4]
static const auto matcher
[0]
list lastIndexOf("B")
list indexOf("B")
p rx()++
QSharedPointer< T > other(t)
[5]