Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
52 typedef QSet<ObjectItem> V4ObjectSet;
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); }
66 static inline QJsonArray toJsonArray(const QV4::Object *o)
67 { V4ObjectSet visitedObjects; return toJsonArray(o, 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 Object *o, V4ObjectSet &visitedObjects);
73};
74
76{
77public:
78 JsonParser(ExecutionEngine *engine, const QChar *json, int length);
79
81
82private:
83 inline bool eatSpace();
84 inline QChar nextToken();
85
86 ReturnedValue parseObject();
87 ReturnedValue parseArray();
88 bool parseMember(Object *o);
89 bool parseString(QString *string);
90 bool parseValue(Value *val);
91 bool parseNumber(Value *val);
92
94 const QChar *head;
95 const QChar *json;
96 const QChar *end;
97
98 int nestingLevel;
100};
101
102}
103
105
106#endif
107
\inmodule QtCore
\inmodule QtCore\reentrant
Definition qjsonarray.h:18
\inmodule QtCore\reentrant
Definition qjsonobject.h:20
\inmodule QtCore\reentrant
Definition qjsonvalue.h:25
Definition qset.h:18
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
JsonParser(ExecutionEngine *engine, const QChar *json, int length)
ReturnedValue parse(QJsonParseError *error)
Combined button and popup list for selecting options.
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 QJsonArray toJsonArray(const QV4::Object *o)
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 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