1 /* 2 * DQt - D bindings for the Qt Toolkit 3 * 4 * GNU Lesser General Public License Usage 5 * This file may be used under the terms of the GNU Lesser 6 * General Public License version 3 as published by the Free Software 7 * Foundation and appearing in the file LICENSE.LGPL3 included in the 8 * packaging of this file. Please review the following information to 9 * ensure the GNU Lesser General Public License version 3 requirements 10 * will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 11 */ 12 module qt.core.stringlist; 13 extern(C++): 14 15 import qt.config; 16 import qt.core.global; 17 import qt.core.list; 18 import qt.core.namespace; 19 import qt.core.qchar; 20 import qt.core.regularexpression; 21 import qt.core.string; 22 import qt.core.stringview; 23 import qt.helpers; 24 25 /// Binding for C++ class [QStringList](https://doc.qt.io/qt-6/qstringlist.html). 26 alias QStringList = QList!(QString); 27 /+ #ifndef QSTRINGLIST_H +/ 28 /+ #define QSTRINGLIST_H 29 30 31 32 #if !defined(QT_NO_JAVA_STYLE_ITERATORS) 33 using QStringListIterator = QListIterator<QString>; 34 using QMutableStringListIterator = QMutableListIterator<QString>; 35 #endif +/ 36 37 38 extern(C++, "QtPrivate") { 39 void /+ Q_CORE_EXPORT +/ QStringList_sort(QStringList* that, /+ Qt:: +/qt.core.namespace.CaseSensitivity cs); 40 qsizetype /+ Q_CORE_EXPORT +/ QStringList_removeDuplicates(QStringList* that); 41 QString /+ Q_CORE_EXPORT +/ QStringList_join(const(QStringList)* that, QStringView sep); 42 QString /+ Q_CORE_EXPORT +/ QStringList_join(const(QStringList)* that, const(QChar)* sep, qsizetype seplen); 43 /+ Q_CORE_EXPORT +/ QString QStringList_join(ref const(QStringList) list, QLatin1String sep); 44 QStringList /+ Q_CORE_EXPORT +/ QStringList_filter(const(QStringList)* that, QStringView str, 45 /+ Qt:: +/qt.core.namespace.CaseSensitivity cs); 46 bool /+ Q_CORE_EXPORT +/ QStringList_contains(const(QStringList)* that, QStringView str, /+ Qt:: +/qt.core.namespace.CaseSensitivity cs); 47 bool /+ Q_CORE_EXPORT +/ QStringList_contains(const(QStringList)* that, QLatin1String str, /+ Qt:: +/qt.core.namespace.CaseSensitivity cs); 48 void /+ Q_CORE_EXPORT +/ QStringList_replaceInStrings(QStringList* that, QStringView before, QStringView after, 49 /+ Qt:: +/qt.core.namespace.CaseSensitivity cs); 50 51 /+ #if QT_CONFIG(regularexpression) +/ 52 void /+ Q_CORE_EXPORT +/ QStringList_replaceInStrings(QStringList* that, ref const(QRegularExpression) rx, ref const(QString) after); 53 QStringList /+ Q_CORE_EXPORT +/ QStringList_filter(const(QStringList)* that, ref const(QRegularExpression) re); 54 qsizetype /+ Q_CORE_EXPORT +/ QStringList_indexOf(const(QStringList)* that, ref const(QRegularExpression) re, qsizetype from); 55 qsizetype /+ Q_CORE_EXPORT +/ QStringList_lastIndexOf(const(QStringList)* that, ref const(QRegularExpression) re, qsizetype from); 56 /+ #endif +/ // QT_CONFIG(regularexpression) 57 } 58 59 /+ #ifdef Q_QDOC 60 class QStringList : public QList<QString> 61 #else 62 template <> struct QListSpecialMethods<QString> : QListSpecialMethodsBase<QString> 63 #endif 64 { 65 #ifdef Q_QDOC 66 public: 67 using QList<QString>::QList; 68 QStringList(const QString &str); 69 QStringList(const QList<QString> &other); 70 QStringList(QList<QString> &&other); 71 72 QStringList &operator=(const QList<QString> &other); 73 QStringList &operator=(QList<QString> &&other); 74 QStringList operator+(const QStringList &other) const; 75 QStringList &operator<<(const QString &str); 76 QStringList &operator<<(const QStringList &other); 77 QStringList &operator<<(const QList<QString> &other); 78 private: 79 #endif 80 81 public: 82 inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive) 83 { QtPrivate::QStringList_sort(self(), cs); } 84 inline qsizetype removeDuplicates() 85 { return QtPrivate::QStringList_removeDuplicates(self()); } 86 87 inline QString join(QStringView sep) const 88 { return QtPrivate::QStringList_join(self(), sep); } 89 inline QString join(QLatin1String sep) const 90 { return QtPrivate::QStringList_join(*self(), sep); } 91 inline QString join(QChar sep) const 92 { return QtPrivate::QStringList_join(self(), &sep, 1); } 93 94 inline QStringList filter(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const 95 { return QtPrivate::QStringList_filter(self(), str, cs); } 96 inline QStringList &replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive) 97 { 98 QtPrivate::QStringList_replaceInStrings(self(), before, after, cs); 99 return *self(); 100 } 101 102 #if QT_STRINGVIEW_LEVEL < 2 103 inline QString join(const QString &sep) const 104 { return QtPrivate::QStringList_join(self(), sep.constData(), sep.length()); } 105 inline QStringList filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const 106 { return QtPrivate::QStringList_filter(self(), str, cs); } 107 inline QStringList &replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive) 108 { 109 QtPrivate::QStringList_replaceInStrings(self(), before, after, cs); 110 return *self(); 111 } 112 inline QStringList &replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive) 113 { 114 QtPrivate::QStringList_replaceInStrings(self(), before, after, cs); 115 return *self(); 116 } 117 inline QStringList &replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive) 118 { 119 QtPrivate::QStringList_replaceInStrings(self(), before, after, cs); 120 return *self(); 121 } 122 #endif 123 using QListSpecialMethodsBase<QString>::contains; 124 using QListSpecialMethodsBase<QString>::indexOf; 125 using QListSpecialMethodsBase<QString>::lastIndexOf; 126 127 inline bool contains(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept 128 { return QtPrivate::QStringList_contains(self(), str, cs); } 129 inline bool contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept 130 { return QtPrivate::QStringList_contains(self(), str, cs); } 131 132 #if QT_STRINGVIEW_LEVEL < 2 133 inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept 134 { return QtPrivate::QStringList_contains(self(), str, cs); } 135 qsizetype indexOf(const QString &str, qsizetype from = 0) const noexcept 136 { return indexOf(QStringView(str), from); } 137 qsizetype lastIndexOf(const QString &str, qsizetype from = -1) const noexcept 138 { return lastIndexOf(QStringView(str), from); } 139 #endif 140 141 #if QT_CONFIG(regularexpression) 142 inline QStringList filter(const QRegularExpression &re) const 143 { return QtPrivate::QStringList_filter(self(), re); } 144 inline QStringList &replaceInStrings(const QRegularExpression &re, const QString &after) 145 { 146 QtPrivate::QStringList_replaceInStrings(self(), re, after); 147 return *self(); 148 } 149 inline qsizetype indexOf(const QRegularExpression &re, qsizetype from = 0) const 150 { return QtPrivate::QStringList_indexOf(self(), re, from); } 151 inline qsizetype lastIndexOf(const QRegularExpression &re, qsizetype from = -1) const 152 { return QtPrivate::QStringList_lastIndexOf(self(), re, from); } 153 #endif // QT_CONFIG(regularexpression) 154 }; +/ 155 156 157 /+ #endif +/ // QSTRINGLIST_H 158