Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmlcustomparser_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// Qt-Security score:significant
4
5#ifndef QQMLCUSTOMPARSER_H
6#define QQMLCUSTOMPARSER_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQml/qqmlerror.h>
20#include <QtQml/private/qqmlbinding_p.h>
21#include <private/qv4compileddata_p.h>
22
23#include <QtCore/qbytearray.h>
24
26
27class QQmlPropertyValidator;
29
30class Q_QML_EXPORT QQmlCustomParser
31{
32public:
33 enum Flag {
34 NoFlag = 0x00000000,
35 AcceptsAttachedProperties = 0x00000001,
36 AcceptsSignalHandlers = 0x00000002
37 };
38 Q_DECLARE_FLAGS(Flags, Flag)
39
40 QQmlCustomParser() : engine(nullptr), validator(nullptr), m_flags(NoFlag) {}
41 QQmlCustomParser(Flags f) : engine(nullptr), validator(nullptr), m_flags(f) {}
42 virtual ~QQmlCustomParser() {}
43
44 void clearErrors();
45 Flags flags() const { return m_flags; }
46
47 virtual void verifyBindings(
48 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &,
49 const QList<const QV4::CompiledData::Binding *> &) = 0;
50 virtual void applyBindings(
51 QObject *, const QQmlRefPointer<QV4::ExecutableCompilationUnit> &,
52 const QList<const QV4::CompiledData::Binding *> &) = 0;
53
54 QList<QQmlError> errors() const { return exceptions; }
55
56protected:
57 void error(const QV4::CompiledData::Binding *binding, const QString& description)
58 { error(binding->location, description); }
59 void error(const QV4::CompiledData::Object *object, const QString& description)
60 { error(object->location, description); }
61 void error(const QV4::CompiledData::Location &location, const QString& description);
62
63 int evaluateEnum(const QString &, bool *ok) const;
64
65 const QMetaObject *resolveType(const QString&) const;
66 QQmlTypeLoader *typeLoader() const;
67
68private:
69 QList<QQmlError> exceptions;
70 QQmlEnginePrivate *engine;
71 const QQmlPropertyValidator *validator;
72 Flags m_flags;
73 QBiPointer<const QQmlImports, QQmlTypeNameCache> imports;
74 friend class QQmlPropertyValidator;
75 friend class QQmlObjectCreator;
76};
77Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlCustomParser::Flags)
78
79QT_END_NAMESPACE
80
81#endif
The QQmlCustomParser class allows you to add new arbitrary types to QML.
friend class QQmlEnginePrivate
Combined button and popup list for selecting options.