swift
Loading...
Searching...
No Matches
variantmap.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_MISC_VARIANTMAP_H
7#define SWIFT_MISC_VARIANTMAP_H
8
9#include <initializer_list>
10#include <utility>
11
12#include <QJsonObject>
13#include <QMap>
14#include <QMetaType>
15#include <QString>
16
17#include "misc/dictionary.h"
20#include "misc/variant.h"
21
22namespace swift::misc
23{
24
26
33 public CDictionary<QString, CVariant, QMap>,
34 public mixin::MetaType<CVariantMap>
35 {
36 public:
39
41 CVariantMap() = default;
42
44 CVariantMap(const CVariantMap &) = default;
45
47 CVariantMap(CVariantMap &&other) noexcept : CDictionary(std::move(other)) {}
48
51 {
53 return *this;
54 }
55
58 {
59 CDictionary::operator=(std::move(other));
60 return *this;
61 }
62
64 ~CVariantMap() = default;
65
68
70 QJsonObject toJson() const;
71
73 void convertFromJson(const QJsonObject &json);
74
77 void convertFromJson(const QJsonObject &json, const QStringList &keys);
78
81 const QString &prefix);
82
85 const CLogCategoryList &categories, const QString &prefix);
86
89
92
94 void convertFromMemoizedJson(const QJsonObject &json);
95
98 void convertFromMemoizedJson(const QJsonObject &json, const QStringList &keys);
99
102 const QString &prefix);
103
106 const CLogCategoryList &categories, const QString &prefix);
107 };
108
109} // namespace swift::misc
110
111Q_DECLARE_METATYPE(swift::misc::CVariantMap)
112
113#endif // SWIFT_MISC_VARIANTMAP_H
CDictionary & operator=(const CDictionary &other)
Copy assignment.
Definition dictionary.h:456
CDictionary()=default
Default constructor.
A sequence of log categories.
Status messages, e.g. from Core -> GUI.
Map of { QString, CVariant } pairs.
Definition variantmap.h:35
CVariantMap(const CVariantMap &)=default
Copy constructor.
void convertFromJson(const QJsonObject &json)
Assign from JSON object.
CVariantMap & operator=(CVariantMap &&other) noexcept
Move assignment operator.
Definition variantmap.h:57
QJsonObject & mergeToMemoizedJson(QJsonObject &json) const
Insert values from this map into an existing compact JSON object.
~CVariantMap()=default
Destructor.
CStatusMessageList convertFromMemoizedJsonNoThrow(const QJsonObject &json, const CLogCategoryList &categories, const QString &prefix)
Call convertFromMemoizedJson, catch any CJsonException that are thrown and return them as CStatusMess...
void convertFromMemoizedJson(const QJsonObject &json)
From compact JSON format.
QJsonObject toMemoizedJson() const
To compact JSON format.
CVariantMap(CVariantMap &&other) noexcept
Move constructor.
Definition variantmap.h:47
CVariantMap & operator=(const CVariantMap &other)
Copy assignment operator.
Definition variantmap.h:50
CVariantMap()=default
Default constructor.
CDictionary()=default
Default constructor.
QJsonObject toJson() const
Cast to JSON object.
QJsonObject & mergeToJson(QJsonObject &json) const
Insert values from this map into an existing JSON object.
CStatusMessageList convertFromJsonNoThrow(const QJsonObject &json, const CLogCategoryList &categories, const QString &prefix)
Call convertFromJson, catch any CJsonException that are thrown and return them as CStatusMessage.
CRTP class template from which a derived class can inherit common methods dealing with the metatype o...
#define SWIFT_MISC_DECLARE_USING_MIXIN_METATYPE(DERIVED)
When a derived class and a base class both inherit from mixin::MetaType, the derived class uses this ...
Free functions in swift::misc.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.