| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // Copyright (C) 2016 Intel Corporation. |
| 3 | // Copyright (C) 2014 by Southwest Research Institute (R) |
| 4 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 5 | |
| 6 | #include <QtCore/qlist.h> |
| 7 | |
| 8 | #ifndef QBYTEARRAYLIST_H |
| 9 | #define QBYTEARRAYLIST_H |
| 10 | |
| 11 | #include <QtCore/qbytearray.h> |
| 12 | |
| 13 | #include <limits> |
| 14 | |
| 15 | QT_BEGIN_NAMESPACE |
| 16 | |
| 17 | #if !defined(QT_NO_JAVA_STYLE_ITERATORS) |
| 18 | typedef QListIterator<QByteArray> QByteArrayListIterator; |
| 19 | typedef QMutableListIterator<QByteArray> QMutableByteArrayListIterator; |
| 20 | #endif |
| 21 | |
| 22 | #ifndef Q_QDOC |
| 23 | |
| 24 | namespace QtPrivate { |
| 25 | #if QT_CORE_REMOVED_SINCE(6, 3) && QT_POINTER_SIZE != 4 |
| 26 | QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *separator, int separatorLength); |
| 27 | #endif |
| 28 | QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *sep, qsizetype len); |
| 29 | } |
| 30 | #endif |
| 31 | |
| 32 | #ifdef Q_QDOC |
| 33 | class QByteArrayList : public QList<QByteArray> |
| 34 | #else |
| 35 | template <> struct QListSpecialMethods<QByteArray> : QListSpecialMethodsBase<QByteArray> |
| 36 | #endif |
| 37 | { |
| 38 | #ifndef Q_QDOC |
| 39 | protected: |
| 40 | QListSpecialMethods() = default; |
| 41 | ~QListSpecialMethods() = default; |
| 42 | QListSpecialMethods(const QListSpecialMethods &) = default; |
| 43 | QListSpecialMethods(QListSpecialMethods &&) = default; |
| 44 | QListSpecialMethods &operator=(const QListSpecialMethods &) = default; |
| 45 | QListSpecialMethods &operator=(QListSpecialMethods &&) = default; |
| 46 | #endif |
| 47 | public: |
| 48 | using QListSpecialMethodsBase<QByteArray>::indexOf; |
| 49 | using QListSpecialMethodsBase<QByteArray>::lastIndexOf; |
| 50 | using QListSpecialMethodsBase<QByteArray>::contains; |
| 51 | |
| 52 | QByteArray join(QByteArrayView sep = {}) const |
| 53 | { |
| 54 | return QtPrivate::QByteArrayList_join(that: self(), sep: sep.data(), len: sep.size()); |
| 55 | } |
| 56 | Q_WEAK_OVERLOAD |
| 57 | inline QByteArray join(const QByteArray &sep) const |
| 58 | { return join(sep: qToByteArrayViewIgnoringNull(b: sep)); } |
| 59 | inline QByteArray join(char sep) const |
| 60 | { return join(sep: {&sep, 1}); } |
| 61 | }; |
| 62 | |
| 63 | QT_END_NAMESPACE |
| 64 | |
| 65 | #endif // QBYTEARRAYLIST_H |
| 66 |
