LCOV - code coverage report
Current view: top level - home/aheinecke/dev/main/qt5/include/QtCore - qstringlist.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 12 17 70.6 %
Date: 2018-11-14 16:53:58 Functions: 11 15 73.3 %

          Line data    Source code
       1             : /****************************************************************************
       2             : **
       3             : ** Copyright (C) 2016 The Qt Company Ltd.
       4             : ** Copyright (C) 2016 Intel Corporation.
       5             : ** Contact: https://www.qt.io/licensing/
       6             : **
       7             : ** This file is part of the QtCore module of the Qt Toolkit.
       8             : **
       9             : ** $QT_BEGIN_LICENSE:LGPL$
      10             : ** Commercial License Usage
      11             : ** Licensees holding valid commercial Qt licenses may use this file in
      12             : ** accordance with the commercial license agreement provided with the
      13             : ** Software or, alternatively, in accordance with the terms contained in
      14             : ** a written agreement between you and The Qt Company. For licensing terms
      15             : ** and conditions see https://www.qt.io/terms-conditions. For further
      16             : ** information use the contact form at https://www.qt.io/contact-us.
      17             : **
      18             : ** GNU Lesser General Public License Usage
      19             : ** Alternatively, this file may be used under the terms of the GNU Lesser
      20             : ** General Public License version 3 as published by the Free Software
      21             : ** Foundation and appearing in the file LICENSE.LGPL3 included in the
      22             : ** packaging of this file. Please review the following information to
      23             : ** ensure the GNU Lesser General Public License version 3 requirements
      24             : ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
      25             : **
      26             : ** GNU General Public License Usage
      27             : ** Alternatively, this file may be used under the terms of the GNU
      28             : ** General Public License version 2.0 or (at your option) the GNU General
      29             : ** Public license version 3 or any later version approved by the KDE Free
      30             : ** Qt Foundation. The licenses are as published by the Free Software
      31             : ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
      32             : ** included in the packaging of this file. Please review the following
      33             : ** information to ensure the GNU General Public License requirements will
      34             : ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
      35             : ** https://www.gnu.org/licenses/gpl-3.0.html.
      36             : **
      37             : ** $QT_END_LICENSE$
      38             : **
      39             : ****************************************************************************/
      40             : 
      41             : #include <QtCore/qlist.h>
      42             : 
      43             : #ifndef QSTRINGLIST_H
      44             : #define QSTRINGLIST_H
      45             : 
      46             : #include <QtCore/qalgorithms.h>
      47             : #include <QtCore/qregexp.h>
      48             : #include <QtCore/qstring.h>
      49             : #include <QtCore/qstringmatcher.h>
      50             : 
      51             : QT_BEGIN_NAMESPACE
      52             : 
      53             : class QRegExp;
      54             : class QRegularExpression;
      55             : 
      56             : typedef QListIterator<QString> QStringListIterator;
      57             : typedef QMutableListIterator<QString> QMutableStringListIterator;
      58             : 
      59             : class QStringList;
      60             : 
      61             : #ifdef Q_QDOC
      62             : class QStringList : public QList<QString>
      63             : #else
      64         655 : template <> struct QListSpecialMethods<QString>
      65             : #endif
      66             : {
      67             : #ifndef Q_QDOC
      68             : protected:
      69         671 :     ~QListSpecialMethods() {}
      70             : #endif
      71             : public:
      72             :     inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive);
      73             :     inline int removeDuplicates();
      74             : 
      75             :     inline QString join(const QString &sep) const;
      76             :     inline QString join(QLatin1String sep) const;
      77             :     inline QString join(QChar sep) const;
      78             : 
      79             :     inline QStringList filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
      80             :     inline QStringList &replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
      81             : 
      82             : #ifndef QT_NO_REGEXP
      83             :     inline QStringList filter(const QRegExp &rx) const;
      84             :     inline QStringList &replaceInStrings(const QRegExp &rx, const QString &after);
      85             : #endif
      86             : 
      87             : #ifndef QT_BOOTSTRAPPED
      88             : #ifndef QT_NO_REGULAREXPRESSION
      89             :     inline QStringList filter(const QRegularExpression &re) const;
      90             :     inline QStringList &replaceInStrings(const QRegularExpression &re, const QString &after);
      91             : #endif // QT_NO_REGULAREXPRESSION
      92             : #endif // QT_BOOTSTRAPPED
      93             : 
      94             : #ifndef Q_QDOC
      95             : private:
      96             :     inline QStringList *self();
      97             :     inline const QStringList *self() const;
      98             : };
      99             : 
     100             : // ### Qt6: check if there's a better way
     101         715 : class QStringList : public QList<QString>
     102             : {
     103             : #endif
     104             : public:
     105         651 :     inline QStringList() Q_DECL_NOTHROW { }
     106           0 :     inline explicit QStringList(const QString &i) { append(i); }
     107             :     inline QStringList(const QList<QString> &l) : QList<QString>(l) { }
     108             : #ifdef Q_COMPILER_RVALUE_REFS
     109           0 :     inline QStringList(QList<QString> &&l) Q_DECL_NOTHROW : QList<QString>(std::move(l)) { }
     110             : #endif
     111             : #ifdef Q_COMPILER_INITIALIZER_LISTS
     112           0 :     inline QStringList(std::initializer_list<QString> args) : QList<QString>(args) { }
     113             : #endif
     114             : 
     115             :     QStringList &operator=(const QList<QString> &other)
     116             :     { QList<QString>::operator=(other); return *this; }
     117             : #ifdef Q_COMPILER_RVALUE_REFS
     118           0 :     QStringList &operator=(QList<QString> &&other) Q_DECL_NOTHROW
     119           0 :     { QList<QString>::operator=(std::move(other)); return *this; }
     120             : #endif
     121             : 
     122             :     inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     123             :     inline bool contains(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
     124             : 
     125             :     inline QStringList operator+(const QStringList &other) const
     126             :     { QStringList n = *this; n += other; return n; }
     127          38 :     inline QStringList &operator<<(const QString &str)
     128          38 :     { append(str); return *this; }
     129             :     inline QStringList &operator<<(const QStringList &l)
     130             :     { *this += l; return *this; }
     131             :     inline QStringList &operator<<(const QList<QString> &l)
     132             :     { *this += l; return *this; }
     133             : 
     134             : #ifndef QT_NO_REGEXP
     135             :     inline int indexOf(const QRegExp &rx, int from = 0) const;
     136             :     inline int lastIndexOf(const QRegExp &rx, int from = -1) const;
     137             :     inline int indexOf(QRegExp &rx, int from = 0) const;
     138             :     inline int lastIndexOf(QRegExp &rx, int from = -1) const;
     139             : #endif
     140             : 
     141             : #ifndef QT_BOOTSTRAPPED
     142             : #ifndef QT_NO_REGULAREXPRESSION
     143             :     inline int indexOf(const QRegularExpression &re, int from = 0) const;
     144             :     inline int lastIndexOf(const QRegularExpression &re, int from = -1) const;
     145             : #endif // QT_NO_REGULAREXPRESSION
     146             : #endif // QT_BOOTSTRAPPED
     147             : 
     148             :     using QList<QString>::indexOf;
     149             :     using QList<QString>::lastIndexOf;
     150             : };
     151             : 
     152             : Q_DECLARE_TYPEINFO(QStringList, Q_MOVABLE_TYPE);
     153             : 
     154             : #ifndef Q_QDOC
     155             : inline QStringList *QListSpecialMethods<QString>::self()
     156             : { return static_cast<QStringList *>(this); }
     157           2 : inline const QStringList *QListSpecialMethods<QString>::self() const
     158           2 : { return static_cast<const QStringList *>(this); }
     159             : 
     160             : namespace QtPrivate {
     161             :     void Q_CORE_EXPORT QStringList_sort(QStringList *that, Qt::CaseSensitivity cs);
     162             :     int Q_CORE_EXPORT QStringList_removeDuplicates(QStringList *that);
     163             :     QString Q_CORE_EXPORT QStringList_join(const QStringList *that, const QChar *sep, int seplen);
     164             :     Q_CORE_EXPORT QString QStringList_join(const QStringList &list, QLatin1String sep);
     165             :     QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, const QString &str,
     166             :                                                Qt::CaseSensitivity cs);
     167             : 
     168             :     bool Q_CORE_EXPORT QStringList_contains(const QStringList *that, const QString &str, Qt::CaseSensitivity cs);
     169             :     bool Q_CORE_EXPORT QStringList_contains(const QStringList *that, QLatin1String str, Qt::CaseSensitivity cs);
     170             :     void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, const QString &before, const QString &after,
     171             :                                       Qt::CaseSensitivity cs);
     172             : 
     173             : #ifndef QT_NO_REGEXP
     174             :     void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, const QRegExp &rx, const QString &after);
     175             :     QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, const QRegExp &re);
     176             :     int Q_CORE_EXPORT QStringList_indexOf(const QStringList *that, const QRegExp &rx, int from);
     177             :     int Q_CORE_EXPORT QStringList_lastIndexOf(const QStringList *that, const QRegExp &rx, int from);
     178             :     int Q_CORE_EXPORT QStringList_indexOf(const QStringList *that, QRegExp &rx, int from);
     179             :     int Q_CORE_EXPORT QStringList_lastIndexOf(const QStringList *that, QRegExp &rx, int from);
     180             : #endif
     181             : 
     182             : #ifndef QT_BOOTSTRAPPED
     183             : #ifndef QT_NO_REGULAREXPRESSION
     184             :     void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, const QRegularExpression &rx, const QString &after);
     185             :     QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, const QRegularExpression &re);
     186             :     int Q_CORE_EXPORT QStringList_indexOf(const QStringList *that, const QRegularExpression &re, int from);
     187             :     int Q_CORE_EXPORT QStringList_lastIndexOf(const QStringList *that, const QRegularExpression &re, int from);
     188             : #endif // QT_NO_REGULAREXPRESSION
     189             : #endif // QT_BOOTSTRAPPED
     190             : }
     191             : 
     192             : inline void QListSpecialMethods<QString>::sort(Qt::CaseSensitivity cs)
     193             : {
     194             :     QtPrivate::QStringList_sort(self(), cs);
     195             : }
     196             : 
     197             : inline int QListSpecialMethods<QString>::removeDuplicates()
     198             : {
     199             :     return QtPrivate::QStringList_removeDuplicates(self());
     200             : }
     201             : 
     202           2 : inline QString QListSpecialMethods<QString>::join(const QString &sep) const
     203             : {
     204           2 :     return QtPrivate::QStringList_join(self(), sep.constData(), sep.length());
     205             : }
     206             : 
     207             : QString QListSpecialMethods<QString>::join(QLatin1String sep) const
     208             : {
     209             :     return QtPrivate::QStringList_join(*self(), sep);
     210             : }
     211             : 
     212             : inline QString QListSpecialMethods<QString>::join(QChar sep) const
     213             : {
     214             :     return QtPrivate::QStringList_join(self(), &sep, 1);
     215             : }
     216             : 
     217             : inline QStringList QListSpecialMethods<QString>::filter(const QString &str, Qt::CaseSensitivity cs) const
     218             : {
     219             :     return QtPrivate::QStringList_filter(self(), str, cs);
     220             : }
     221             : 
     222           5 : inline bool QStringList::contains(const QString &str, Qt::CaseSensitivity cs) const
     223             : {
     224           5 :     return QtPrivate::QStringList_contains(this, str, cs);
     225             : }
     226             : 
     227             : inline bool QStringList::contains(QLatin1String str, Qt::CaseSensitivity cs) const
     228             : {
     229             :     return QtPrivate::QStringList_contains(this, str, cs);
     230             : }
     231             : 
     232             : inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs)
     233             : {
     234             :     QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
     235             :     return *self();
     236             : }
     237             : 
     238             : inline QStringList operator+(const QList<QString> &one, const QStringList &other)
     239             : {
     240             :     QStringList n = one;
     241             :     n += other;
     242             :     return n;
     243             : }
     244             : 
     245             : #ifndef QT_NO_REGEXP
     246             : inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QRegExp &rx, const QString &after)
     247             : {
     248             :     QtPrivate::QStringList_replaceInStrings(self(), rx, after);
     249             :     return *self();
     250             : }
     251             : 
     252             : inline QStringList QListSpecialMethods<QString>::filter(const QRegExp &rx) const
     253             : {
     254             :     return QtPrivate::QStringList_filter(self(), rx);
     255             : }
     256             : 
     257             : inline int QStringList::indexOf(const QRegExp &rx, int from) const
     258             : {
     259             :     return QtPrivate::QStringList_indexOf(this, rx, from);
     260             : }
     261             : 
     262             : inline int QStringList::lastIndexOf(const QRegExp &rx, int from) const
     263             : {
     264             :     return QtPrivate::QStringList_lastIndexOf(this, rx, from);
     265             : }
     266             : 
     267             : inline int QStringList::indexOf(QRegExp &rx, int from) const
     268             : {
     269             :     return QtPrivate::QStringList_indexOf(this, rx, from);
     270             : }
     271             : 
     272             : inline int QStringList::lastIndexOf(QRegExp &rx, int from) const
     273             : {
     274             :     return QtPrivate::QStringList_lastIndexOf(this, rx, from);
     275             : }
     276             : #endif
     277             : 
     278             : #ifndef QT_BOOTSTRAPPED
     279             : #ifndef QT_NO_REGULAREXPRESSION
     280             : inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QRegularExpression &rx, const QString &after)
     281             : {
     282             :     QtPrivate::QStringList_replaceInStrings(self(), rx, after);
     283             :     return *self();
     284             : }
     285             : 
     286             : inline QStringList QListSpecialMethods<QString>::filter(const QRegularExpression &rx) const
     287             : {
     288             :     return QtPrivate::QStringList_filter(self(), rx);
     289             : }
     290             : 
     291             : inline int QStringList::indexOf(const QRegularExpression &rx, int from) const
     292             : {
     293             :     return QtPrivate::QStringList_indexOf(this, rx, from);
     294             : }
     295             : 
     296             : inline int QStringList::lastIndexOf(const QRegularExpression &rx, int from) const
     297             : {
     298             :     return QtPrivate::QStringList_lastIndexOf(this, rx, from);
     299             : }
     300             : #endif // QT_NO_REGULAREXPRESSION
     301             : #endif // QT_BOOTSTRAPPED
     302             : #endif // Q_QDOC
     303             : 
     304             : QT_END_NAMESPACE
     305             : 
     306             : #endif // QSTRINGLIST_H

Generated by: LCOV version 1.13