Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qv4jsonobject_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3#ifndef QV4JSONOBJECT_H
4#define QV4JSONOBJECT_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
17#include "qv4object_p.h"
18#include <qjsonarray.h>
19#include <qjsonobject.h>
20#include <qjsonvalue.h>
21#include <qjsondocument.h>
22#include <qhash.h>
23
25
26namespace QV4 {
27
28namespace Heap {
29
31 void init();
32};
33
34}
35
36struct ObjectItem {
37 const QV4::Object *o;
38 ObjectItem(const QV4::Object *o) : o(o) {}
39};
40
41inline bool operator ==(const ObjectItem &a, const ObjectItem &b)
42{ return a.o->d() == b.o->d(); }
43
44inline size_t qHash(const ObjectItem &i, size_t seed = 0)
45{ return ::qHash((void *)i.o->d(), seed); }
46
50private:
51
53public:
54
55 static ReturnedValue method_parse(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
56 static ReturnedValue method_stringify(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
57
61
62 static inline QJsonValue toJsonValue(const QV4::Value &value)
63 { V4ObjectSet visitedObjects; return toJsonValue(value, visitedObjects); }
64 static inline QJsonObject toJsonObject(const QV4::Object *o)
65 { V4ObjectSet visitedObjects; return toJsonObject(o, visitedObjects); }
67 { V4ObjectSet visitedObjects; return toJsonArray(a, visitedObjects); }
68
69private:
70 static QJsonValue toJsonValue(const QV4::Value &value, V4ObjectSet &visitedObjects);
71 static QJsonObject toJsonObject(const Object *o, V4ObjectSet &visitedObjects);
72 static QJsonArray toJsonArray(const ArrayObject *a, V4ObjectSet &visitedObjects);
73
74};
75
77{
78public:
79 JsonParser(ExecutionEngine *engine, const QChar *json, int length);
80
82
83private:
84 inline bool eatSpace();
85 inline QChar nextToken();
86
87 ReturnedValue parseObject();
88 ReturnedValue parseArray();
89 bool parseMember(Object *o);
90 bool parseString(QString *string);
91 bool parseValue(Value *val);
92 bool parseNumber(Value *val);
93
95 const QChar *head;
96 const QChar *json;
97 const QChar *end;
98
99 int nestingLevel;
101};
102
103}
104
106
107#endif
108
\inmodule QtCore
Definition qchar.h:48
\inmodule QtCore\reentrant
Definition qjsonarray.h:18
\inmodule QtCore\reentrant
Definition qjsonobject.h:20
\inmodule QtCore\reentrant
Definition qjsonvalue.h:24
Definition qset.h:18
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
ReturnedValue parse(QJsonParseError *error)
Combined button and popup list for selecting options.
\qmltype Particle \inqmlmodule QtQuick.Particles
quint64 ReturnedValue
bool operator==(const ObjectItem &a, const ObjectItem &b)
size_t qHash(const ObjectItem &i, size_t seed=0)
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint GLuint end
GLenum GLuint GLenum GLsizei length
GLuint GLfloat * val
GLenum array
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
#define Q_MANAGED_TYPE(type)
#define V4_OBJECT2(DataClass, superClass)
QJSEngine engine
[0]
\inmodule QtCore\reentrant
ParseError
This enum describes the type of error that occurred during the parsing of a JSON document.
static ReturnedValue fromJsonValue(ExecutionEngine *engine, const QJsonValue &value)
static ReturnedValue fromJsonObject(ExecutionEngine *engine, const QJsonObject &object)
static ReturnedValue fromJsonArray(ExecutionEngine *engine, const QJsonArray &array)
static ReturnedValue method_parse(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static QJsonObject toJsonObject(const QV4::Object *o)
static QJsonArray toJsonArray(const QV4::ArrayObject *a)
static ReturnedValue method_stringify(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static QJsonValue toJsonValue(const QV4::Value &value)
ExecutionEngine * engine() const
ObjectItem(const QV4::Object *o)
const QV4::Object * o