Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-12 09:05:22

0001 // Copyright (C) 2020 The Qt Company Ltd.
0002 // Copyright (C) 2016 Intel Corporation.
0003 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0004 
0005 #include <QtCore/qlist.h>
0006 
0007 #ifndef QSTRINGLIST_H
0008 #define QSTRINGLIST_H
0009 
0010 #include <QtCore/qalgorithms.h>
0011 #include <QtCore/qcontainertools_impl.h>
0012 #include <QtCore/qstring.h>
0013 #include <QtCore/qstringmatcher.h>
0014 
0015 QT_BEGIN_NAMESPACE
0016 
0017 class QLatin1StringMatcher;
0018 class QRegularExpression;
0019 
0020 #if !defined(QT_NO_JAVA_STYLE_ITERATORS)
0021 using QStringListIterator = QListIterator<QString>;
0022 using QMutableStringListIterator = QMutableListIterator<QString>;
0023 #endif
0024 
0025 
0026 namespace QtPrivate {
0027     void Q_CORE_EXPORT QStringList_sort(QStringList *that, Qt::CaseSensitivity cs);
0028     qsizetype Q_CORE_EXPORT QStringList_removeDuplicates(QStringList *that);
0029     QString Q_CORE_EXPORT QStringList_join(const QStringList *that, QStringView sep);
0030     QString Q_CORE_EXPORT QStringList_join(const QStringList *that, const QChar *sep, qsizetype seplen);
0031     Q_CORE_EXPORT QString QStringList_join(const QStringList &list, QLatin1StringView sep);
0032     QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, QStringView str,
0033                                                Qt::CaseSensitivity cs);
0034     Q_CORE_EXPORT QStringList QStringList_filter(const QStringList &that, QLatin1StringView needle,
0035                                                  Qt::CaseSensitivity cs);
0036     Q_CORE_EXPORT QStringList QStringList_filter(const QStringList &that,
0037                                                  const QStringMatcher &matcher);
0038     Q_CORE_EXPORT QStringList QStringList_filter(const QStringList &that,
0039                                                  const QLatin1StringMatcher &matcher);
0040 
0041     bool Q_CORE_EXPORT QStringList_contains(const QStringList *that, QStringView str, Qt::CaseSensitivity cs);
0042     bool Q_CORE_EXPORT QStringList_contains(const QStringList *that, QLatin1StringView str, Qt::CaseSensitivity cs);
0043     void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, QStringView before, QStringView after,
0044                                       Qt::CaseSensitivity cs);
0045 
0046     qsizetype Q_CORE_EXPORT QStringList_indexOf(const QStringList &that, QStringView str,
0047                                                 qsizetype from, Qt::CaseSensitivity cs);
0048     qsizetype Q_CORE_EXPORT QStringList_indexOf(const QStringList &that, QLatin1StringView str,
0049                                                 qsizetype from, Qt::CaseSensitivity cs);
0050 
0051     Q_CORE_EXPORT qsizetype QStringList_lastIndexOf(const QStringList &that, QStringView str,
0052                                                     qsizetype from, Qt::CaseSensitivity cs);
0053     Q_CORE_EXPORT qsizetype QStringList_lastIndexOf(const QStringList &that, QLatin1StringView str,
0054                                                     qsizetype from, Qt::CaseSensitivity cs);
0055 
0056 #if QT_CONFIG(regularexpression)
0057     void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, const QRegularExpression &rx, const QString &after);
0058     QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, const QRegularExpression &re);
0059     qsizetype Q_CORE_EXPORT QStringList_indexOf(const QStringList *that, const QRegularExpression &re, qsizetype from);
0060     qsizetype Q_CORE_EXPORT QStringList_lastIndexOf(const QStringList *that, const QRegularExpression &re, qsizetype from);
0061 #endif // QT_CONFIG(regularexpression)
0062 }
0063 
0064 #ifdef Q_QDOC
0065 class QStringList : public QList<QString>
0066 #else
0067 template <> struct QListSpecialMethods<QString> : QListSpecialMethodsBase<QString>
0068 #endif
0069 {
0070 #ifdef Q_QDOC
0071 public:
0072     using QList<QString>::QList;
0073     QStringList(const QString &str);
0074     QStringList(const QList<QString> &other);
0075     QStringList(QList<QString> &&other);
0076 
0077     QStringList &operator=(const QList<QString> &other);
0078     QStringList &operator=(QList<QString> &&other);
0079     QStringList operator+(const QStringList &other) const;
0080     QStringList &operator<<(const QString &str);
0081     QStringList &operator<<(const QStringList &other);
0082     QStringList &operator<<(const QList<QString> &other);
0083 private:
0084 #endif
0085 
0086 public:
0087     inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive)
0088     { QtPrivate::QStringList_sort(self(), cs); }
0089     inline qsizetype removeDuplicates()
0090     { return QtPrivate::QStringList_removeDuplicates(self()); }
0091 
0092     inline QString join(QStringView sep) const
0093     { return QtPrivate::QStringList_join(self(), sep); }
0094     inline QString join(QLatin1StringView sep) const
0095     { return QtPrivate::QStringList_join(*self(), sep); }
0096     inline QString join(QChar sep) const
0097     { return QtPrivate::QStringList_join(self(), &sep, 1); }
0098 
0099     QStringList filter(const QStringMatcher &matcher) const
0100     { return QtPrivate::QStringList_filter(*self(), matcher); }
0101     QStringList filter(const QLatin1StringMatcher &matcher) const
0102     { return QtPrivate::QStringList_filter(*self(), matcher); }
0103 
0104     QStringList filter(QLatin1StringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
0105     { return QtPrivate::QStringList_filter(*self(), needle, cs); }
0106     inline QStringList filter(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
0107     { return QtPrivate::QStringList_filter(self(), str, cs); }
0108     inline QStringList &replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
0109     {
0110         QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
0111         return *self();
0112     }
0113 
0114     inline QString join(const QString &sep) const
0115     { return QtPrivate::QStringList_join(self(), sep.constData(), sep.size()); }
0116     inline QStringList filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
0117     { return QtPrivate::QStringList_filter(self(), str, cs); }
0118     inline QStringList &replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
0119     {
0120         QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
0121         return *self();
0122     }
0123     inline QStringList &replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
0124     {
0125         QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
0126         return *self();
0127     }
0128     inline QStringList &replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
0129     {
0130         QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
0131         return *self();
0132     }
0133     using QListSpecialMethodsBase<QString>::contains;
0134     using QListSpecialMethodsBase<QString>::indexOf;
0135     using QListSpecialMethodsBase<QString>::lastIndexOf;
0136 
0137     inline bool contains(QLatin1StringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
0138     { return QtPrivate::QStringList_contains(self(), str, cs); }
0139     inline bool contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
0140     { return QtPrivate::QStringList_contains(self(), str, cs); }
0141 
0142     inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
0143     { return QtPrivate::QStringList_contains(self(), str, cs); }
0144 
0145     qsizetype indexOf(const QString &str, qsizetype from = 0,
0146                       Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
0147     { return indexOf(QStringView(str), from, cs); }
0148     qsizetype indexOf(QStringView needle, qsizetype from = 0,
0149                       Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
0150     { return QtPrivate::QStringList_indexOf(*self(), needle, from, cs); }
0151     qsizetype indexOf(QLatin1StringView needle, qsizetype from = 0,
0152                       Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
0153     { return QtPrivate::QStringList_indexOf(*self(), needle, from, cs); }
0154 
0155     qsizetype lastIndexOf(const QString &str, qsizetype from = -1,
0156                           Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
0157     { return lastIndexOf(QStringView(str), from, cs); }
0158     qsizetype lastIndexOf(QStringView str, qsizetype from = -1,
0159                           Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
0160     { return QtPrivate::QStringList_lastIndexOf(*self(), str, from, cs); }
0161     qsizetype lastIndexOf(QLatin1StringView needle, qsizetype from = -1,
0162                           Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
0163     { return QtPrivate::QStringList_lastIndexOf(*self(), needle, from, cs); }
0164 
0165 #if QT_CONFIG(regularexpression)
0166     inline QStringList filter(const QRegularExpression &re) const
0167     { return QtPrivate::QStringList_filter(self(), re); }
0168     inline QStringList &replaceInStrings(const QRegularExpression &re, const QString &after)
0169     {
0170         QtPrivate::QStringList_replaceInStrings(self(), re, after);
0171         return *self();
0172     }
0173     inline qsizetype indexOf(const QRegularExpression &re, qsizetype from = 0) const
0174     { return QtPrivate::QStringList_indexOf(self(), re, from); }
0175     inline qsizetype lastIndexOf(const QRegularExpression &re, qsizetype from = -1) const
0176     { return QtPrivate::QStringList_lastIndexOf(self(), re, from); }
0177 #endif // QT_CONFIG(regularexpression)
0178 };
0179 
0180 QT_END_NAMESPACE
0181 
0182 #endif // QSTRINGLIST_H