// 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 qvector { template ::rust::isize qvectorLen(const QVector& v) noexcept; template void qvectorAppend(QVector& 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& qvectorGetUnchecked(const QVector& v, ::rust::isize pos) noexcept { Q_ASSERT(pos < qvectorLen(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 qvectorIndexOf(const QVector& 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 qvectorInsert(QVector& 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 qvectorLen(const QVector& 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 qvectorRemove(QVector& v, ::rust::isize pos) 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.removeAt(static_cast(pos)); #else v.removeAt(static_cast(pos)); #endif } template void qvectorReserve(QVector& 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 QVector_bool = QVector; using QVector_f32 = QVector; using QVector_f64 = QVector; using QVector_i8 = QVector<::std::int8_t>; using QVector_i16 = QVector<::std::int16_t>; using QVector_i32 = QVector<::std::int32_t>; using QVector_i64 = QVector<::std::int64_t>; using QVector_QByteArray = QVector<::QByteArray>; #ifdef CXX_QT_GUI_FEATURE using QVector_QColor = QVector<::QColor>; #endif using QVector_QDate = QVector<::QDate>; using QVector_QDateTime = QVector<::QDateTime>; using QVector_QMargins = QVector<::QMargins>; using QVector_QMarginsF = QVector<::QMarginsF>; using QVector_QPersistentModelIndex = QVector<::QPersistentModelIndex>; using QVector_QPoint = QVector<::QPoint>; using QVector_QPointF = QVector<::QPointF>; using QVector_QRect = QVector<::QRect>; using QVector_QRectF = QVector<::QRectF>; using QVector_QSize = QVector<::QSize>; using QVector_QSizeF = QVector<::QSizeF>; using QVector_QString = QVector<::QString>; using QVector_QTime = QVector<::QTime>; using QVector_QUrl = QVector<::QUrl>; using QVector_QVariant = QVector<::QVariant>; using QVector_u8 = QVector<::std::uint8_t>; using QVector_u16 = QVector<::std::uint16_t>; using QVector_u32 = QVector<::std::uint32_t>; using QVector_u64 = QVector<::std::uint64_t>;