magpie/API/helpers.h

18 lines
414 B
C++

//SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
//SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <QVariant>
#include <stdexcept>
#define UNUSED(X) (void)(X)
template <class T>
const T& qast(const QVariant& variant) {
if (variant.userType() == qMetaTypeId<T>())
return *reinterpret_cast<const T*>(variant.data());
throw std::runtime_error("An usuccessfull qast");
}