1 /**************************************************************************** 2 ** 3 ** DQt - D bindings for the Qt Toolkit 4 ** 5 ** GNU Lesser General Public License Usage 6 ** This file may be used under the terms of the GNU Lesser 7 ** General Public License version 3 as published by the Free Software 8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 9 ** packaging of this file. Please review the following information to 10 ** ensure the GNU Lesser General Public License version 3 requirements 11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 12 ** 13 ****************************************************************************/ 14 module qt.core.stringlist; 15 extern(C++): 16 17 import qt.config; 18 import qt.core.list; 19 import qt.core.metatype; 20 import qt.core.namespace; 21 import qt.core.qchar; 22 import qt.core.regularexpression; 23 import qt.core.string; 24 import qt.core.stringview; 25 import qt.core.typeinfo; 26 import qt.helpers; 27 version(QT_NO_REGEXP){}else 28 import qt.core.regexp; 29 30 /+ #ifndef QSTRINGLIST_H +/ 31 /+ #define QSTRINGLIST_H 32 33 34 class QRegExp; 35 class QRegularExpression; 36 37 #if !defined(QT_NO_JAVA_STYLE_ITERATORS) 38 typedef QListIterator<QString> QStringListIterator; 39 typedef QMutableListIterator<QString> QMutableStringListIterator; 40 #endif 41 42 class QStringList; 43 44 #ifdef Q_QDOC 45 class QStringList : public QList<QString> 46 #else 47 template <> struct QListSpecialMethods<QString> 48 #endif 49 { 50 #ifndef Q_QDOC 51 protected: 52 ~QListSpecialMethods() = default; 53 #endif 54 public: 55 inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive); 56 inline int removeDuplicates(); 57 58 #if QT_STRINGVIEW_LEVEL < 2 59 inline QString join(const QString &sep) const; 60 #endif 61 inline QString join(QStringView sep) const; 62 inline QString join(QLatin1String sep) const; 63 inline QString join(QChar sep) const; 64 65 inline QStringList filter(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; 66 inline QStringList &replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive); 67 #if QT_STRINGVIEW_LEVEL < 2 68 inline QStringList filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; 69 inline QStringList &replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive); 70 inline QStringList &replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive); 71 inline QStringList &replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive); 72 #endif 73 74 #ifndef QT_NO_REGEXP 75 inline QStringList filter(const QRegExp &rx) const; 76 inline QStringList &replaceInStrings(const QRegExp &rx, const QString &after); 77 #endif 78 79 #if QT_CONFIG(regularexpression) 80 inline QStringList filter(const QRegularExpression &re) const; 81 inline QStringList &replaceInStrings(const QRegularExpression &re, const QString &after); 82 #endif // QT_CONFIG(regularexpression) 83 84 #ifndef Q_QDOC 85 private: 86 inline QStringList *self(); 87 inline const QStringList *self() const; 88 }; +/ 89 90 // ### Qt6: check if there's a better way 91 @(QMetaType.Type.QStringList) @Q_MOVABLE_TYPE extern(C++, class) struct QStringList 92 { 93 public QList!(QString) base0; 94 alias base0 this; 95 /+ #endif +/ 96 public: 97 version(Windows) 98 @disable this(); 99 /+pragma(inline, true) this()/+ noexcept+/ { }+/ 100 101 static QStringList create() 102 { 103 QStringList r = QStringList.init; 104 r.base0 = QList!QString.create; 105 return r; 106 } 107 108 /+ explicit +/pragma(inline, true) this(ref const(QString) i) 109 { 110 base0 = QList!QString.create; 111 append(i); 112 } 113 pragma(inline, true) this(ref const(QList!(QString)) l) 114 { 115 this.base0 = *cast(QList!(QString)*)&l; 116 } 117 /+ inline QStringList(QList<QString> &&l) noexcept : QList<QString>(std::move(l)) { } +/ 118 /+ inline QStringList(std::initializer_list<QString> args) : QList<QString>(args) { } +/ 119 /+ template <typename InputIterator, QtPrivate::IfIsInputIterator<InputIterator> = true> +/ 120 /+ inline QStringList(InputIterator first, InputIterator last) 121 : QList<QString>(first, last) { } +/ 122 123 /+ref QStringList operator =(ref const(QList!(QString)) other) 124 { QList!(QString).operator=(other); return this; }+/ 125 /+ QStringList &operator=(QList<QString> &&other) noexcept 126 { QList<QString>::operator=(std::move(other)); return *this; } +/ 127 128 static if(QT_STRINGVIEW_LEVEL < 2) 129 { 130 pragma(inline, true) bool contains(ref const(QString) str, /+ Qt:: +/qt.core.namespace.CaseSensitivity cs = /+ Qt:: +/qt.core.namespace.CaseSensitivity.CaseSensitive) const 131 { 132 return /+ QtPrivate:: +/QStringList_contains(&this, str, cs); 133 } 134 } 135 pragma(inline, true) bool contains(QLatin1String str, /+ Qt:: +/qt.core.namespace.CaseSensitivity cs = /+ Qt:: +/qt.core.namespace.CaseSensitivity.CaseSensitive) const 136 { 137 return /+ QtPrivate:: +/QStringList_contains(&this, str, cs); 138 } 139 140 auto opSlice() const 141 { 142 return base0.opSlice(); 143 } 144 145 pragma(inline, true) bool contains(QStringView str, /+ Qt:: +/qt.core.namespace.CaseSensitivity cs = /+ Qt:: +/qt.core.namespace.CaseSensitivity.CaseSensitive) const 146 { 147 return /+ QtPrivate:: +/QStringList_contains(&this, str, cs); 148 } 149 150 extern(D) pragma(inline, true) QStringList opBinary(string op)(ref const(QStringList) other) const if(op == "~") 151 { QStringList n = this; n ~= other; return n; } 152 /+pragma(inline, true) ref QStringList operator <<(ref const(QString) str) 153 { append(str); return this; }+/ 154 /+pragma(inline, true) ref QStringList operator <<(ref const(QStringList) l) 155 { this += l; return this; }+/ 156 /+pragma(inline, true) ref QStringList operator <<(ref const(QList!(QString)) l) 157 { this += l; return this; }+/ 158 159 pragma(inline, true) int indexOf(QStringView string, int from = 0) const 160 { 161 return /+ QtPrivate:: +/qt.core.list.indexOf!(QString, QStringView)(this, string, from); 162 } 163 pragma(inline, true) int indexOf(QLatin1String string, int from = 0) const 164 { 165 return /+ QtPrivate:: +/qt.core.list.indexOf!(QString, QLatin1String)(this, string, from); 166 } 167 168 pragma(inline, true) int lastIndexOf(QStringView string, int from = -1) const 169 { 170 return /+ QtPrivate:: +/qt.core.list.lastIndexOf!(QString, QStringView)(this, string, from); 171 } 172 pragma(inline, true) int lastIndexOf(QLatin1String string, int from = -1) const 173 { 174 return /+ QtPrivate:: +/qt.core.list.lastIndexOf!(QString, QLatin1String)(this, string, from); 175 } 176 177 /+ #ifndef QT_NO_REGEXP +/ 178 version(QT_NO_REGEXP){}else 179 { 180 pragma(inline, true) int indexOf(ref const(QRegExp) rx, int from = 0) const 181 { 182 return /+ QtPrivate:: +/QStringList_indexOf(&this, rx, from); 183 } 184 pragma(inline, true) int lastIndexOf(ref const(QRegExp) rx, int from = -1) const 185 { 186 return /+ QtPrivate:: +/QStringList_lastIndexOf(&this, rx, from); 187 } 188 pragma(inline, true) int indexOf(ref QRegExp rx, int from = 0) const 189 { 190 return /+ QtPrivate:: +/QStringList_indexOf(&this, rx, from); 191 } 192 pragma(inline, true) int lastIndexOf(ref QRegExp rx, int from = -1) const 193 { 194 return /+ QtPrivate:: +/QStringList_lastIndexOf(&this, rx, from); 195 } 196 } 197 /+ #endif 198 199 #if QT_CONFIG(regularexpression) +/ 200 pragma(inline, true) int indexOf(ref const(QRegularExpression) rx, int from = 0) const 201 { 202 return /+ QtPrivate:: +/QStringList_indexOf(&this, rx, from); 203 } 204 pragma(inline, true) int lastIndexOf(ref const(QRegularExpression) rx, int from = -1) const 205 { 206 return /+ QtPrivate:: +/QStringList_lastIndexOf(&this, rx, from); 207 } 208 /+ #endif +/ // QT_CONFIG(regularexpression) 209 210 /+ using QList<QString>::indexOf; +/ 211 /+ using QList<QString>::lastIndexOf; +/ 212 } 213 214 /+ Q_DECLARE_TYPEINFO(QStringList, Q_MOVABLE_TYPE); 215 216 #ifndef Q_QDOC +/ 217 218 extern(C++, "QtPrivate") { 219 void /+ Q_CORE_EXPORT +/ QStringList_sort(QStringList* that, /+ Qt:: +/qt.core.namespace.CaseSensitivity cs); 220 int /+ Q_CORE_EXPORT +/ QStringList_removeDuplicates(QStringList* that); 221 QString /+ Q_CORE_EXPORT +/ QStringList_join(const(QStringList)* that, QStringView sep); 222 QString /+ Q_CORE_EXPORT +/ QStringList_join(const(QStringList)* that, const(QChar)* sep, int seplen); 223 /+ Q_CORE_EXPORT +/ QString QStringList_join(ref const(QStringList) list, QLatin1String sep); 224 QStringList /+ Q_CORE_EXPORT +/ QStringList_filter(const(QStringList)* that, QStringView str, 225 /+ Qt:: +/qt.core.namespace.CaseSensitivity cs); 226 /+ #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +/ 227 QStringList /+ Q_CORE_EXPORT +/ QStringList_filter(const(QStringList)* that, ref const(QString) str, 228 /+ Qt:: +/qt.core.namespace.CaseSensitivity cs); 229 /+ #endif 230 231 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +/ 232 bool /+ Q_CORE_EXPORT +/ QStringList_contains(const(QStringList)* that, ref const(QString) str, /+ Qt:: +/qt.core.namespace.CaseSensitivity cs); 233 /+ #endif +/ 234 bool /+ Q_CORE_EXPORT +/ QStringList_contains(const(QStringList)* that, QStringView str, /+ Qt:: +/qt.core.namespace.CaseSensitivity cs); 235 bool /+ Q_CORE_EXPORT +/ QStringList_contains(const(QStringList)* that, QLatin1String str, /+ Qt:: +/qt.core.namespace.CaseSensitivity cs); 236 void /+ Q_CORE_EXPORT +/ QStringList_replaceInStrings(QStringList* that, QStringView before, QStringView after, 237 /+ Qt:: +/qt.core.namespace.CaseSensitivity cs); 238 /+ #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +/ 239 void /+ Q_CORE_EXPORT +/ QStringList_replaceInStrings(QStringList* that, ref const(QString) before, ref const(QString) after, 240 /+ Qt:: +/qt.core.namespace.CaseSensitivity cs); 241 /+ #endif +/ 242 243 version(QT_NO_REGEXP){}else 244 { 245 void /+ Q_CORE_EXPORT +/ QStringList_replaceInStrings(QStringList* that, ref const(QRegExp) rx, ref const(QString) after); 246 QStringList /+ Q_CORE_EXPORT +/ QStringList_filter(const(QStringList)* that, ref const(QRegExp) re); 247 int /+ Q_CORE_EXPORT +/ QStringList_indexOf(const(QStringList)* that, ref const(QRegExp) rx, int from); 248 int /+ Q_CORE_EXPORT +/ QStringList_lastIndexOf(const(QStringList)* that, ref const(QRegExp) rx, int from); 249 int /+ Q_CORE_EXPORT +/ QStringList_indexOf(const(QStringList)* that, ref QRegExp rx, int from); 250 int /+ Q_CORE_EXPORT +/ QStringList_lastIndexOf(const(QStringList)* that, ref QRegExp rx, int from); 251 } 252 253 /+ #if QT_CONFIG(regularexpression) +/ 254 void /+ Q_CORE_EXPORT +/ QStringList_replaceInStrings(QStringList* that, ref const(QRegularExpression) rx, ref const(QString) after); 255 QStringList /+ Q_CORE_EXPORT +/ QStringList_filter(const(QStringList)* that, ref const(QRegularExpression) re); 256 int /+ Q_CORE_EXPORT +/ QStringList_indexOf(const(QStringList)* that, ref const(QRegularExpression) re, int from); 257 int /+ Q_CORE_EXPORT +/ QStringList_lastIndexOf(const(QStringList)* that, ref const(QRegularExpression) re, int from); 258 /+ #endif +/ // QT_CONFIG(regularexpression) 259 } 260 261 /+ #if QT_STRINGVIEW_LEVEL < 2 262 #endif 263 264 #if QT_STRINGVIEW_LEVEL < 2 265 #endif 266 267 #if QT_STRINGVIEW_LEVEL < 2 268 #endif 269 270 #if QT_STRINGVIEW_LEVEL < 2 271 #endif +/ 272 273 /+pragma(inline, true) QStringList operator +(ref const(QList!(QString)) one, ref const(QStringList) other) 274 { 275 QStringList n = one; 276 n ~= other; 277 return n; 278 }+/ 279 280 /+ #ifndef QT_NO_REGEXP 281 #endif 282 283 #if QT_CONFIG(regularexpression) 284 #endif +/ // QT_CONFIG(regularexpression) 285 /+ #endif +/ // Q_QDOC 286 287 288 /+ #endif +/ // QSTRINGLIST_H 289