forked from EasyRPG/Editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson.h
More file actions
85 lines (74 loc) · 2.48 KB
/
json.h
File metadata and controls
85 lines (74 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* This file is part of EasyRPG Editor.
*
* EasyRPG Editor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EasyRPG Editor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EasyRPG Editor. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QObject>
#include <QtQmlIntegration>
#include <QVariant>
/**
* Base class holding a LCF Object for use with the Glaze JSON API.
* The implementing template class is JsonT.
* This is required because the Qt MOC preprocessor does not support templates.
*/
class Json : public QObject {
Q_OBJECT
QML_ELEMENT
public:
explicit Json(QObject* parent = nullptr) : QObject(parent) {}
/**
* @param jsonPtr JSON Pointer to read from
* @return String at the given pointer location
*/
Q_INVOKABLE virtual QString str(QString jsonPtr) const = 0;
/**
* @param jsonPtr JSON Pointer to read from
* @return Integer at the given pointer location
*/
Q_INVOKABLE virtual int num(QString jsonPtr) const = 0;
/**
* @param jsonPtr JSON Pointer to read from
* @return bool at the given pointer location
*/
Q_INVOKABLE virtual bool boolean(QString jsonPtr) const = 0;
/**
* Writes value to the given pointer location
*
* @param jsonPtr JSON Pointer to write to
* @param value Value to write
*/
// Limited write support. Implement more types in JsonT<LCFTYPE>::set
Q_INVOKABLE virtual void set(QString jsonPtr, const QVariant& value) = 0;
/**
* @param jsonPtr JSON Pointer
* @return JsonView rooted at the given pointer location
*/
Q_INVOKABLE virtual QVariant subtree(QString jsonPtr) = 0;
/**
* Access std::vector<> data at the given pointer location.
*
* @param jsonPtr JSON Pointer
* @return JsonListView rooted at the given pointer location
*/
Q_INVOKABLE virtual QVariant list(QString jsonPtr) = 0;
/**
* Dump the data given at the pointer location as raw JSON data.
* Only use this as a last resort or for debugging purposes.
*
* @param jsonPtr JSON Pointer
* @return JSON string
*/
Q_INVOKABLE virtual QString toJson(QString jsonPtr) const = 0;
};