// clang-format off // SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company // clang-format on // SPDX-FileContributor: Andrew Hayzen // // SPDX-License-Identifier: MIT OR Apache-2.0 #pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef CXX_QT_GUI_FEATURE #include #endif #include "rust/cxx.h" // In Qt 6 QList and QVector are the same, so we only need IsRelocatable defined // once #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) #include "qlist_qvector.h" #else // Define namespace otherwise we hit a GCC bug // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480 namespace rust { // This has static asserts in the cpp file to ensure this is valid. template struct IsRelocatable> : ::std::true_type { }; } // namespace rust #endif namespace rust { namespace cxxqtlib1 { namespace qlist { template ::rust::isize qlistLen(const QList& v) noexcept; template void qlistAppend(QList& v, const T& value) noexcept { // Qt 5 has const T& Qt 6 has QList::rvalue_ref or QList::parameter_type v.append(value); } template const T& qlistGetUnchecked(const QList& v, ::rust::isize pos) noexcept { Q_ASSERT(pos < qlistLen(v)); Q_ASSERT(pos >= 0); // Qt has an int Qt 6 has a qsizetype #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) return v.at(static_cast(pos)); #else return v.at(static_cast(pos)); #endif } template ::rust::isize qlistIndexOf(const QList& v, const T& value) noexcept { // Qt 5 has an int Qt 6 has a qsizetype return static_cast<::rust::isize>(v.indexOf(value)); } template void qlistInsert(QList& v, ::rust::isize pos, const T& value) noexcept { Q_ASSERT(pos >= 0); // Qt 5 has an int Qt 6 has a qsizetype #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) v.insert(static_cast(pos), value); #else v.insert(static_cast(pos), value); #endif } template ::rust::isize qlistLen(const QList& v) noexcept { // In Qt 5 the type was int now it is qsizetype, so we need to ensure the type // is the same for CXX return static_cast<::rust::isize>(v.size()); } template void qlistRemove(QList& v, ::rust::isize pos) noexcept { Q_ASSERT(pos >= 0); // Qt 5 has an int Qt 6 has a qsizetype // Qt 5 only has removeAt Qt 6 has remove or removeAt #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) v.remove(static_cast(pos)); #else v.removeAt(static_cast(pos)); #endif } template void qlistReserve(QList& v, ::rust::isize size) noexcept { Q_ASSERT(size >= 0); // Qt has an int Qt 6 has a qsizetype #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) v.reserve(static_cast(size)); #else v.reserve(static_cast(size)); #endif } } } } using QList_bool = QList; using QList_f32 = QList; using QList_f64 = QList; using QList_i8 = QList<::std::int8_t>; using QList_i16 = QList<::std::int16_t>; using QList_i32 = QList<::std::int32_t>; using QList_i64 = QList<::std::int64_t>; using QList_QByteArray = QList<::QByteArray>; #ifdef CXX_QT_GUI_FEATURE using QList_QColor = QList<::QColor>; #endif using QList_QDate = QList<::QDate>; using QList_QDateTime = QList<::QDateTime>; using QList_QMargins = QList<::QMargins>; using QList_QMarginsF = QList<::QMarginsF>; using QList_QPersistentModelIndex = QList<::QPersistentModelIndex>; using QList_QPoint = QList<::QPoint>; using QList_QPointF = QList<::QPointF>; using QList_QRect = QList<::QRect>; using QList_QRectF = QList<::QRectF>; using QList_QSize = QList<::QSize>; using QList_QSizeF = QList<::QSizeF>; using QList_QString = QList<::QString>; using QList_QTime = QList<::QTime>; using QList_QUrl = QList<::QUrl>; using QList_QVariant = QList<::QVariant>; using QList_u8 = QList<::std::uint8_t>; using QList_u16 = QList<::std::uint16_t>; using QList_u32 = QList<::std::uint32_t>; using QList_u64 = QList<::std::uint64_t>;