1 | // Copyright (C) 2020 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 METATYPESJSONPROCESSOR_P_H |
5 | #define METATYPESJSONPROCESSOR_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 | |
20 | #include <QtCore/qstring.h> |
21 | #include <QtCore/qvector.h> |
22 | #include <QtCore/qjsonobject.h> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class MetaTypesJsonProcessor |
27 | { |
28 | public: |
29 | static QStringList namespaces(const QJsonObject &classDef); |
30 | |
31 | MetaTypesJsonProcessor(bool privateIncludes) : m_privateIncludes(privateIncludes) {} |
32 | |
33 | bool processTypes(const QStringList &files); |
34 | bool processForeignTypes(const QStringList &foreignTypesFiles); |
35 | |
36 | void postProcessTypes(); |
37 | void postProcessForeignTypes(); |
38 | |
39 | QVector<QJsonObject> types() const { return m_types; } |
40 | QVector<QJsonObject> foreignTypes() const { return m_foreignTypes; } |
41 | QStringList referencedTypes() const { return m_referencedTypes; } |
42 | QStringList includes() const { return m_includes; } |
43 | |
44 | QString () const; |
45 | |
46 | private: |
47 | enum RegistrationMode { |
48 | NoRegistration, |
49 | ObjectRegistration, |
50 | GadgetRegistration, |
51 | NamespaceRegistration |
52 | }; |
53 | |
54 | static RegistrationMode qmlTypeRegistrationMode(const QJsonObject &classDef); |
55 | void addRelatedTypes(); |
56 | |
57 | void sortTypes(QVector<QJsonObject> &types); |
58 | QString resolvedInclude(const QString &include); |
59 | void processTypes(const QJsonObject &types); |
60 | void processForeignTypes(const QJsonObject &types); |
61 | |
62 | QStringList m_includes; |
63 | QStringList m_referencedTypes; |
64 | QVector<QJsonObject> m_types; |
65 | QVector<QJsonObject> m_foreignTypes; |
66 | bool m_privateIncludes = false; |
67 | }; |
68 | QT_END_NAMESPACE |
69 | |
70 | #endif // METATYPESJSONPROCESSOR_P_H |
71 | |