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 | |
4 | #ifndef QDBUSXMLPARSER_P_H |
5 | #define QDBUSXMLPARSER_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 for the convenience |
12 | // of the QLibrary class. This header file may change from |
13 | // version to version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtDBus/private/qtdbusglobal_p.h> |
19 | #include <QtCore/qloggingcategory.h> |
20 | #include <QtCore/qmap.h> |
21 | #include <QtCore/qxmlstream.h> |
22 | #include "qdbusintrospection_p.h" |
23 | |
24 | #ifndef QT_NO_DBUS |
25 | |
26 | QT_BEGIN_NAMESPACE |
27 | |
28 | Q_DECLARE_LOGGING_CATEGORY(dbusParser) |
29 | |
30 | /*! |
31 | \internal |
32 | */ |
33 | class QDBusXmlParser |
34 | { |
35 | QString m_service; |
36 | QString m_path; |
37 | QSharedDataPointer<QDBusIntrospection::Object> m_object; |
38 | std::unique_ptr<QDBusIntrospection::Interface> m_currentInterface; |
39 | QDBusIntrospection::Interfaces m_interfaces; |
40 | QXmlStreamReader m_xml; |
41 | QDBusIntrospection::SourceLocation m_currentLocation; |
42 | QDBusIntrospection::DiagnosticsReporter *m_reporter; |
43 | |
44 | public: |
45 | QDBusXmlParser(const QString &service, const QString &path, const QString &xmlData, |
46 | QDBusIntrospection::DiagnosticsReporter *reporter = nullptr); |
47 | |
48 | inline QDBusIntrospection::Interfaces interfaces() const { return m_interfaces; } |
49 | inline QSharedDataPointer<QDBusIntrospection::Object> object() const { return m_object; } |
50 | |
51 | private: |
52 | void readNode(int nodeLevel); |
53 | void readInterface(); |
54 | bool parseSignal(QDBusIntrospection::Signal &signalData); |
55 | bool parseMethod(QDBusIntrospection::Method &methodData); |
56 | bool parseProperty(QDBusIntrospection::Property &propertyData); |
57 | bool parseAnnotation(QDBusIntrospection::Annotations &annotations, |
58 | bool interfaceAnnotation = false); |
59 | bool parseArg(const QXmlStreamAttributes &attributes, QDBusIntrospection::Argument &argData); |
60 | bool readNextStartElement(); |
61 | void updateCurrentLocation(); |
62 | }; |
63 | |
64 | QT_END_NAMESPACE |
65 | |
66 | #endif // QT_NO_DBUS |
67 | #endif |
68 |