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 QDBUSINTROSPECTION_P_H
5#define QDBUSINTROSPECTION_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/qlist.h>
20#include <QtCore/qmap.h>
21#include <QtCore/qshareddata.h>
22#include <QtCore/qstring.h>
23#include <QtCore/qstringlist.h>
24
25#ifndef QT_NO_DBUS
26
27QT_BEGIN_NAMESPACE
28
29class Q_DBUS_EXPORT QDBusIntrospection
30{
31public:
32 // forward declarations
33 struct Argument;
34 struct Method;
35 struct Signal;
36 struct Property;
37 struct Interface;
38 struct Object;
39 struct ObjectTree;
40 struct Annotation;
41
42 // typedefs
43 typedef QMap<QString, Annotation> Annotations;
44 typedef QList<Argument> Arguments;
45 typedef QMultiMap<QString, Method> Methods;
46 typedef QMultiMap<QString, Signal> Signals;
47 typedef QMap<QString, Property> Properties;
48 typedef QMap<QString, QSharedDataPointer<Interface> > Interfaces;
49 typedef QMap<QString, QSharedDataPointer<ObjectTree> > Objects;
50
51public:
52 // the structs
53
54 // Line and column numbers have the same meaning as in QXmlStreamReader.
55 struct SourceLocation
56 {
57 qint64 lineNumber = 1;
58 qint64 columnNumber = 0;
59 };
60
61 class Q_DBUS_EXPORT DiagnosticsReporter
62 {
63 Q_DISABLE_COPY_MOVE(DiagnosticsReporter)
64 public:
65 DiagnosticsReporter() = default;
66 virtual ~DiagnosticsReporter();
67 virtual void warning(const SourceLocation &location, const char *msg, ...)
68 Q_ATTRIBUTE_FORMAT_PRINTF(3, 4) = 0;
69 virtual void error(const SourceLocation &location, const char *msg, ...)
70 Q_ATTRIBUTE_FORMAT_PRINTF(3, 4) = 0;
71 };
72
73 struct Annotation
74 {
75 SourceLocation location;
76 QString name;
77 QString value;
78
79 inline bool operator==(const Annotation &other) const
80 {
81 return name == other.name && value == other.value;
82 }
83 };
84
85 struct Argument
86 {
87 SourceLocation location;
88 QString type;
89 QString name;
90
91 inline bool operator==(const Argument& other) const
92 { return name == other.name && type == other.type; }
93 };
94
95 struct Method
96 {
97 SourceLocation location;
98 QString name;
99 Arguments inputArgs;
100 Arguments outputArgs;
101 Annotations annotations;
102
103 inline bool operator==(const Method& other) const
104 { return name == other.name && annotations == other.annotations &&
105 inputArgs == other.inputArgs && outputArgs == other.outputArgs; }
106 };
107
108 struct Signal
109 {
110 SourceLocation location;
111 QString name;
112 Arguments outputArgs;
113 Annotations annotations;
114
115 inline bool operator==(const Signal& other) const
116 { return name == other.name && annotations == other.annotations &&
117 outputArgs == other.outputArgs; }
118 };
119
120 struct Property
121 {
122 enum Access { Read, Write, ReadWrite };
123 SourceLocation location;
124 QString name;
125 QString type;
126 Access access;
127 Annotations annotations;
128
129 inline bool operator==(const Property& other) const
130 { return access == other.access && name == other.name &&
131 annotations == other.annotations && type == other.type; }
132 };
133
134 struct Interface: public QSharedData
135 {
136 SourceLocation location;
137 QString name;
138 QString introspection;
139
140 Annotations annotations;
141 Methods methods;
142 Signals signals_;
143 Properties properties;
144
145 inline bool operator==(const Interface &other) const
146 { return !name.isEmpty() && name == other.name; }
147 };
148
149 struct Object: public QSharedData
150 {
151 SourceLocation location;
152 QString service;
153 QString path;
154
155 QStringList interfaces;
156 QStringList childObjects;
157 };
158
159public:
160 static Interface parseInterface(const QString &xml, DiagnosticsReporter *reporter = nullptr);
161 static Interfaces parseInterfaces(const QString &xml, DiagnosticsReporter *reporter = nullptr);
162 static Object parseObject(const QString &xml, const QString &service = QString(),
163 const QString &path = QString(),
164 DiagnosticsReporter *reporter = nullptr);
165
166private:
167 QDBusIntrospection();
168};
169
170QT_END_NAMESPACE
171
172#endif // QT_NO_DBUS
173#endif
174

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qtbase/src/dbus/qdbusintrospection_p.h