1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef QMLTYPESCREATOR_P_H
5#define QMLTYPESCREATOR_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qqmltypesclassdescription_p.h"
19#include "qqmljsstreamwriter_p.h"
20
21#include <QtCore/qstring.h>
22#include <QtCore/qset.h>
23
24QT_BEGIN_NAMESPACE
25
26class QmlTypesCreator
27{
28public:
29 QmlTypesCreator() : m_qml(&m_output) {}
30
31 bool generate(const QString &outFileName);
32
33 void setOwnTypes(QVector<QJsonObject> ownTypes) { m_ownTypes = std::move(ownTypes); }
34 void setForeignTypes(QVector<QJsonObject> foreignTypes) { m_foreignTypes = std::move(foreignTypes); }
35 void setReferencedTypes(QStringList referencedTypes) { m_referencedTypes = std::move(referencedTypes); }
36 void setModule(QString module) { m_module = std::move(module); }
37 void setVersion(QTypeRevision version) { m_version = version; }
38
39private:
40 void writeClassProperties(const QmlTypesClassDescription &collector);
41 void writeType(const QJsonObject &property, const QString &key);
42 void writeProperties(const QJsonArray &properties);
43 void writeMethods(const QJsonArray &methods, const QString &type);
44 void writeEnums(const QJsonArray &enums);
45 void writeComponents();
46
47 QByteArray m_output;
48 QQmlJSStreamWriter m_qml;
49 QVector<QJsonObject> m_ownTypes;
50 QVector<QJsonObject> m_foreignTypes;
51 QStringList m_referencedTypes;
52 QString m_module;
53 QTypeRevision m_version = QTypeRevision::zero();
54};
55
56QT_END_NAMESPACE
57
58#endif // QMLTYPESCREATOR_P_H
59

source code of qtdeclarative/src/qmltyperegistrar/qqmltypescreator_p.h