1// SPDX-FileCopyrightText: 2018 Kitsune Ral <kitsune-ral@users.sf.net>
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#include "converters.h"
5
6#include "logging_categories_p.h"
7
8#include <QtCore/QVariant>
9
10void Quotient::_impl::warnUnknownEnumValue(const QString& stringValue,
11 const char* enumTypeName)
12{
13 qWarning(catFunc: EVENTS).noquote()
14 << "Unknown" << enumTypeName << "value:" << stringValue;
15}
16
17void Quotient::_impl::reportEnumOutOfBounds(uint32_t v, const char* enumTypeName)
18{
19 qCritical(catFunc: MAIN).noquote()
20 << "Value" << v << "is out of bounds for enumeration" << enumTypeName;
21}
22
23QJsonValue Quotient::JsonConverter<QVariant>::dump(const QVariant& v)
24{
25 return QJsonValue::fromVariant(variant: v);
26}
27
28QVariant Quotient::JsonConverter<QVariant>::load(const QJsonValue& jv)
29{
30 return jv.toVariant();
31}
32
33QJsonObject Quotient::toJson(const QVariantHash& vh)
34{
35 return QJsonObject::fromVariantHash(map: vh);
36}
37
38template<>
39QVariantHash Quotient::fromJson(const QJsonValue& jv)
40{
41 return jv.toObject().toVariantHash();
42}
43