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#include "qdbusextratypes.h"
5#include "qdbusutil_p.h"
6
7#ifndef QT_NO_DBUS
8
9QT_BEGIN_NAMESPACE
10
11QT_IMPL_METATYPE_EXTERN(QDBusVariant)
12QT_IMPL_METATYPE_EXTERN(QDBusObjectPath)
13QT_IMPL_METATYPE_EXTERN(QDBusSignature)
14
15void QDBusObjectPath::doCheck()
16{
17 if (!QDBusUtil::isValidObjectPath(path: m_path)) {
18 qWarning(msg: "QDBusObjectPath: invalid path \"%s\"", qPrintable(m_path));
19 m_path.clear();
20 }
21}
22
23void QDBusSignature::doCheck()
24{
25 if (!QDBusUtil::isValidSignature(signature: m_signature)) {
26 qWarning(msg: "QDBusSignature: invalid signature \"%s\"", qPrintable(m_signature));
27 m_signature.clear();
28 }
29}
30
31/*!
32 \class QDBusVariant
33 \inmodule QtDBus
34 \since 4.2
35
36 \brief The QDBusVariant class enables the programmer to identify
37 the variant type provided by the D-Bus typesystem.
38
39 A D-Bus function that takes an integer, a D-Bus variant and a string as parameters
40 can be called with the following argument list (see QDBusMessage::setArguments()):
41
42 \snippet qdbusextratypes/qdbusextratypes.cpp 0
43
44 When a D-Bus function returns a D-Bus variant, it can be retrieved as follows:
45
46 \snippet qdbusextratypes/qdbusextratypes.cpp 1
47
48 The QVariant within a QDBusVariant is required to distinguish between a normal
49 D-Bus value and a value within a D-Bus variant.
50
51 \sa {The Qt D-Bus Type System}
52*/
53
54/*!
55 \fn QDBusVariant::QDBusVariant()
56
57 Constructs a new D-Bus variant.
58*/
59
60/*!
61 \fn QDBusVariant::QDBusVariant(const QVariant &variant)
62
63 Constructs a new D-Bus variant from the given Qt \a variant.
64
65 \sa setVariant()
66*/
67
68/*!
69 \fn QVariant QDBusVariant::variant() const
70
71 Returns this D-Bus variant as a QVariant object.
72
73 \sa setVariant()
74*/
75
76/*!
77 \fn void QDBusVariant::setVariant(const QVariant &variant)
78
79 Assigns the value of the given Qt \a variant to this D-Bus variant.
80
81 \sa variant()
82*/
83
84/*!
85 \class QDBusObjectPath
86 \inmodule QtDBus
87 \since 4.2
88
89 \brief The QDBusObjectPath class enables the programmer to
90 identify the OBJECT_PATH type provided by the D-Bus typesystem.
91
92 \sa {The Qt D-Bus Type System}
93*/
94
95/*!
96 \fn QDBusObjectPath::QDBusObjectPath()
97
98 Constructs a new object path.
99*/
100
101/*!
102 \fn QDBusObjectPath::QDBusObjectPath(const char *path)
103
104 Constructs a new object path from the given \a path.
105
106 \sa setPath()
107*/
108
109/*!
110 \fn QDBusObjectPath::QDBusObjectPath(QLatin1StringView path)
111
112 Constructs a new object path from the Latin-1 string viewed by \a path.
113*/
114
115/*!
116 \fn QDBusObjectPath::QDBusObjectPath(const QString &path)
117
118 Constructs a new object path from the given \a path.
119*/
120
121/*!
122 \fn QString QDBusObjectPath::path() const
123
124 Returns this object path.
125
126 \sa setPath()
127*/
128
129/*!
130 \fn void QDBusObjectPath::setPath(const QString &path)
131
132 Assigns the value of the given \a path to this object path.
133
134 \sa path()
135*/
136
137/*!
138 \since 5.14
139
140 Implicit cast to QVariant. Equivalent to calling
141 QVariant::fromValue() with this object as argument.
142*/
143QDBusObjectPath::operator QVariant() const { return QVariant::fromValue(value: *this); }
144
145/*!
146 \class QDBusSignature
147 \inmodule QtDBus
148 \since 4.2
149
150 \brief The QDBusSignature class enables the programmer to
151 identify the SIGNATURE type provided by the D-Bus typesystem.
152
153 \sa {The Qt D-Bus Type System}
154*/
155
156/*!
157 \fn QDBusSignature::QDBusSignature()
158
159 Constructs a new signature.
160
161 \sa setSignature()
162*/
163
164/*!
165 \fn QDBusSignature::QDBusSignature(const char *signature)
166
167 Constructs a new signature from the given \a signature.
168*/
169
170/*!
171 \fn QDBusSignature::QDBusSignature(QLatin1StringView signature)
172
173 Constructs a new signature from the Latin-1 string viewed by \a signature.
174*/
175
176/*!
177 \fn QDBusSignature::QDBusSignature(const QString &signature)
178
179 Constructs a new signature from the given \a signature.
180*/
181
182/*!
183 \fn QString QDBusSignature::signature() const
184
185 Returns this signature.
186
187 \sa setSignature()
188*/
189
190/*!
191 \fn void QDBusSignature::setSignature(const QString &signature)
192
193 Assigns the value of the given \a signature to this signature.
194 \sa signature()
195*/
196
197/*!
198 \fn void QDBusObjectPath::swap(QDBusObjectPath &other)
199
200 Swaps this QDBusObjectPath instance with \a other.
201*/
202
203/*!
204 \fn void QDBusSignature::swap(QDBusSignature &other)
205
206 Swaps this QDBusSignature instance with \a other.
207*/
208
209/*!
210 \fn void QDBusVariant::swap(QDBusVariant &other)
211
212 Swaps this QDBusVariant instance with \a other.
213*/
214
215QT_END_NAMESPACE
216
217#endif // QT_NO_DBUS
218

source code of qtbase/src/dbus/qdbusextratypes.cpp