Qt 6.x
The Qt SDK
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 bool Q_CORE_EXPORT QStringList_contains(const QStringList *that, QStringView str, Qt::CaseSensitivity cs);
35 void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, QStringView before, QStringView after,
37
38#if QT_CONFIG(regularexpression)
39 void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, const QRegularExpression &rx, const QString &after);
40 QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, const QRegularExpression &re);
41 qsizetype Q_CORE_EXPORT QStringList_indexOf(const QStringList *that, const QRegularExpression &re, qsizetype from);
42 qsizetype Q_CORE_EXPORT QStringList_lastIndexOf(const QStringList *that, const QRegularExpression &re, qsizetype from);
43#endif // QT_CONFIG(regularexpression)
44}
45
46#ifdef Q_QDOC
47class QStringList : public QList<QString>
48#else
49template <> struct QListSpecialMethods<QString> : QListSpecialMethodsBase<QString>
50#endif
51{
52#ifdef Q_QDOC
53public:
54 using QList<QString>::QList;
55 QStringList(const QString &str);
58
59 QStringList &operator=(const QList<QString> &other);
60 QStringList &operator=(QList<QString> &&other);
65private:
66#endif
67
68public:
69 inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive)
70 { QtPrivate::QStringList_sort(self(), cs); }
71 inline qsizetype removeDuplicates()
73
74 inline QString join(QStringView sep) const
76 inline QString join(QLatin1StringView sep) const
77 { return QtPrivate::QStringList_join(*self(), sep); }
78 inline QString join(QChar sep) const
79 { return QtPrivate::QStringList_join(self(), &sep, 1); }
80
82 { return QtPrivate::QStringList_filter(self(), str, cs); }
83 inline QStringList &replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
84 {
86 return *self();
87 }
88
89 inline QString join(const QString &sep) const
90 { return QtPrivate::QStringList_join(self(), sep.constData(), sep.size()); }
92 { return QtPrivate::QStringList_filter(self(), str, cs); }
93 inline QStringList &replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
94 {
96 return *self();
97 }
98 inline QStringList &replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
99 {
100 QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
101 return *self();
102 }
103 inline QStringList &replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
104 {
105 QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
106 return *self();
107 }
111
112 inline bool contains(QLatin1StringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
113 { return QtPrivate::QStringList_contains(self(), str, cs); }
114 inline bool contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
115 { return QtPrivate::QStringList_contains(self(), str, cs); }
116
117 inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
118 { return QtPrivate::QStringList_contains(self(), str, cs); }
119 qsizetype indexOf(const QString &str, qsizetype from = 0) const noexcept
120 { return indexOf(QStringView(str), from); }
121 qsizetype lastIndexOf(const QString &str, qsizetype from = -1) const noexcept
122 { return lastIndexOf(QStringView(str), from); }
123
124#if QT_CONFIG(regularexpression)
125 inline QStringList filter(const QRegularExpression &re) const
126 { return QtPrivate::QStringList_filter(self(), re); }
127 inline QStringList &replaceInStrings(const QRegularExpression &re, const QString &after)
128 {
130 return *self();
131 }
132 inline qsizetype indexOf(const QRegularExpression &re, qsizetype from = 0) const
133 { return QtPrivate::QStringList_indexOf(self(), re, from); }
134 inline qsizetype lastIndexOf(const QRegularExpression &re, qsizetype from = -1) const
135 { return QtPrivate::QStringList_lastIndexOf(self(), re, from); }
136#endif // QT_CONFIG(regularexpression)
137};
138
140
141#endif // QSTRINGLIST_H
\inmodule QtCore
Definition qchar.h:48
Definition qlist.h:74
\inmodule QtCore \reentrant
\inmodule QtCore
\inmodule QtCore
Definition qstringview.h:76
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
QString str
[2]
Combined button and popup list for selecting options.
\macro QT_NAMESPACE
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)
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)
CaseSensitivity
@ CaseSensitive
QString self
Definition language.cpp:57
constexpr timespec operator+(const timespec &t1, const timespec &t2)
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:70
QList< int > list
[14]
QDataStream & operator<<(QDataStream &out, const MyClass &myObj)
[4]
list lastIndexOf("B")
list indexOf("B")
p rx()++
QSharedPointer< T > other(t)
[5]