1 /******************************************************************************
2 * Copyright (C) 2018 Kitsune Ral <kitsune-ral@users.sf.net>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include "converters.h"
20
21 #include <QtCore/QVariant>
22
23 using namespace Quotient;
24
dump(const QVariant & v)25 QJsonValue JsonConverter<QVariant>::dump(const QVariant& v)
26 {
27 return QJsonValue::fromVariant(v);
28 }
29
load(const QJsonValue & jv)30 QVariant JsonConverter<QVariant>::load(const QJsonValue& jv)
31 {
32 return jv.toVariant();
33 }
34
dump(const variant_map_t & map)35 QJsonObject JsonConverter<variant_map_t>::dump(const variant_map_t& map)
36 {
37 return
38 #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
39 QJsonObject::fromVariantHash
40 #else
41 QJsonObject::fromVariantMap
42 #endif
43 (map);
44 }
45
load(const QJsonValue & jv)46 variant_map_t JsonConverter<QVariantHash>::load(const QJsonValue& jv)
47 {
48 return jv.toObject().
49 #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
50 toVariantHash
51 #else
52 toVariantMap
53 #endif
54 ();
55 }
56