// 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 "rust/cxx.h" // 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 namespace rust { namespace cxxqtlib1 { namespace qmap { template ::rust::isize qmapLen(const QMap& m) noexcept; template V qmapGetOrDefault(const QMap& m, const K& key) noexcept { // Qt 6 returns a T and Qt 5 returns an const T // so we need to define our own method here for CXX return m.value(key); } template const K& qmapGetUncheckedKey(const QMap& m, ::rust::isize pos) noexcept { Q_ASSERT(pos < qmapLen(m)); Q_ASSERT(pos >= 0); auto it = m.cbegin(); ::std::advance(it, pos); return it.key(); } template const V& qmapGetUncheckedValue(const QMap& m, ::rust::isize pos) noexcept { Q_ASSERT(pos < qmapLen(m)); Q_ASSERT(pos >= 0); auto it = m.cbegin(); ::std::advance(it, pos); return it.value(); } template void qmapInsert(QMap& m, const K& key, const V& value) noexcept { m.insert(key, value); } template ::rust::isize qmapLen(const QMap& m) noexcept { // Qt has an int as the QMap::size_type return static_cast<::rust::isize>(m.size()); } template bool qmapRemove(QMap& m, const K& key) noexcept { return m.remove(key) >= 1; } } } } using QMap_QString_QVariant = QMap;