qdbusargument.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtDBus module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qdbusargument.h" -
43#include "qdbusargument_p.h" -
44 -
45#include <qatomic.h> -
46#include <qbytearray.h> -
47#include <qlist.h> -
48#include <qmap.h> -
49#include <qstring.h> -
50#include <qstringlist.h> -
51#include <qvariant.h> -
52#include <qdatetime.h> -
53#include <qrect.h> -
54#include <qline.h> -
55 -
56#include "qdbusmetatype_p.h" -
57#include "qdbusutil_p.h" -
58 -
59#ifndef QT_NO_DBUS -
60 -
61QT_BEGIN_NAMESPACE -
62 -
63QDBusArgumentPrivate::~QDBusArgumentPrivate() -
64{ -
65 if (message)
evaluated: message
TRUEFALSE
yes
Evaluation Count:2201
yes
Evaluation Count:2177
2177-2201
66 q_dbus_message_unref(message);
executed: q_dbus_message_unref(message);
Execution Count:2201
2201
67}
executed: }
Execution Count:4378
4378
68 -
69QByteArray QDBusArgumentPrivate::createSignature(int id) -
70{ -
71 if (!qdbus_loadLibDBus())
partially evaluated: !qdbus_loadLibDBus()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:61
0-61
72 return "";
never executed: return "";
0
73 -
74 QByteArray signature;
executed (the execution status of this line is deduced): QByteArray signature;
-
75 QDBusMarshaller *marshaller = new QDBusMarshaller(0);
executed (the execution status of this line is deduced): QDBusMarshaller *marshaller = new QDBusMarshaller(0);
-
76 marshaller->ba = &signature;
executed (the execution status of this line is deduced): marshaller->ba = &signature;
-
77 -
78 // run it -
79 void *null = 0;
executed (the execution status of this line is deduced): void *null = 0;
-
80 QVariant v(id, null);
executed (the execution status of this line is deduced): QVariant v(id, null);
-
81 QDBusArgument arg(marshaller);
executed (the execution status of this line is deduced): QDBusArgument arg(marshaller);
-
82 QDBusMetaType::marshall(arg, v.userType(), v.constData());
executed (the execution status of this line is deduced): QDBusMetaType::marshall(arg, v.userType(), v.constData());
-
83 arg.d = 0;
executed (the execution status of this line is deduced): arg.d = 0;
-
84 -
85 // delete it -
86 bool ok = marshaller->ok;
executed (the execution status of this line is deduced): bool ok = marshaller->ok;
-
87 delete marshaller;
executed (the execution status of this line is deduced): delete marshaller;
-
88 -
89 if (signature.isEmpty() || !ok || !QDBusUtil::isValidSingleSignature(QString::fromLatin1(signature))) {
evaluated: signature.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:60
partially evaluated: !ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:60
evaluated: !QDBusUtil::isValidSingleSignature(QString::fromLatin1(signature))
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:57
0-60
90 qWarning("QDBusMarshaller: type `%s' produces invalid D-BUS signature `%s' "
executed (the execution status of this line is deduced): QMessageLogger("qdbusargument.cpp", 90, __PRETTY_FUNCTION__).warning("QDBusMarshaller: type `%s' produces invalid D-BUS signature `%s' "
-
91 "(Did you forget to call beginStructure() ?)",
executed (the execution status of this line is deduced): "(Did you forget to call beginStructure() ?)",
-
92 QMetaType::typeName(id),
executed (the execution status of this line is deduced): QMetaType::typeName(id),
-
93 signature.isEmpty() ? "<empty>" : signature.constData());
executed (the execution status of this line is deduced): signature.isEmpty() ? "<empty>" : signature.constData());
-
94 return "";
executed: return "";
Execution Count:4
4
95 } else if ((signature.at(0) != DBUS_TYPE_ARRAY && signature.at(0) != DBUS_STRUCT_BEGIN_CHAR) ||
evaluated: signature.at(0) != ((int) 'a')
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:31
evaluated: signature.at(0) != ((int) '(')
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:24
2-31
96 (signature.at(0) == DBUS_TYPE_ARRAY && (signature.at(1) == DBUS_TYPE_BYTE ||
evaluated: signature.at(0) == ((int) 'a')
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:24
evaluated: signature.at(1) == ((int) 'y')
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:30
1-31
97 signature.at(1) == DBUS_TYPE_STRING))) {
evaluated: signature.at(1) == ((int) 's')
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:29
1-29
98 qWarning("QDBusMarshaller: type `%s' attempts to redefine basic D-BUS type '%s' (%s) "
executed (the execution status of this line is deduced): QMessageLogger("qdbusargument.cpp", 98, __PRETTY_FUNCTION__).warning("QDBusMarshaller: type `%s' attempts to redefine basic D-BUS type '%s' (%s) "
-
99 "(Did you forget to call beginStructure() ?)",
executed (the execution status of this line is deduced): "(Did you forget to call beginStructure() ?)",
-
100 QMetaType::typeName(id),
executed (the execution status of this line is deduced): QMetaType::typeName(id),
-
101 signature.constData(),
executed (the execution status of this line is deduced): signature.constData(),
-
102 QMetaType::typeName(QDBusMetaType::signatureToType(signature)));
executed (the execution status of this line is deduced): QMetaType::typeName(QDBusMetaType::signatureToType(signature)));
-
103 return "";
executed: return "";
Execution Count:4
4
104 } -
105 return signature;
executed: return signature;
Execution Count:53
53
106} -
107 -
108bool QDBusArgumentPrivate::checkWrite(QDBusArgumentPrivate *&d) -
109{ -
110 if (!d)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:661
0-661
111 return false;
never executed: return false;
0
112 if (d->direction == Marshalling) {
partially evaluated: d->direction == Marshalling
TRUEFALSE
yes
Evaluation Count:661
no
Evaluation Count:0
0-661
113 if (!d->marshaller()->ok)
partially evaluated: !d->marshaller()->ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:661
0-661
114 return false;
never executed: return false;
0
115 -
116 if (d->message && d->ref.load() != 1) {
partially evaluated: d->message
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:661
never evaluated: d->ref.load() != 1
0-661
117 QDBusMarshaller *dd = new QDBusMarshaller(d->capabilities);
never executed (the execution status of this line is deduced): QDBusMarshaller *dd = new QDBusMarshaller(d->capabilities);
-
118 dd->message = q_dbus_message_copy(d->message);
never executed (the execution status of this line is deduced): dd->message = q_dbus_message_copy(d->message);
-
119 q_dbus_message_iter_init_append(dd->message, &dd->iterator);
never executed (the execution status of this line is deduced): q_dbus_message_iter_init_append(dd->message, &dd->iterator);
-
120 -
121 if (!d->ref.deref())
never evaluated: !d->ref.deref()
0
122 delete d;
never executed: delete d;
0
123 d = dd;
never executed (the execution status of this line is deduced): d = dd;
-
124 }
never executed: }
0
125 return true;
executed: return true;
Execution Count:661
661
126 } -
127 -
128#ifdef QT_DEBUG -
129 qFatal("QDBusArgument: write from a read-only object"); -
130#else -
131 qWarning("QDBusArgument: write from a read-only object");
never executed (the execution status of this line is deduced): QMessageLogger("qdbusargument.cpp", 131, __PRETTY_FUNCTION__).warning("QDBusArgument: write from a read-only object");
-
132#endif -
133 return false;
never executed: return false;
0
134} -
135 -
136bool QDBusArgumentPrivate::checkRead(QDBusArgumentPrivate *d) -
137{ -
138 if (!d)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:717
0-717
139 return false;
never executed: return false;
0
140 if (d->direction == Demarshalling)
partially evaluated: d->direction == Demarshalling
TRUEFALSE
yes
Evaluation Count:717
no
Evaluation Count:0
0-717
141 return true;
executed: return true;
Execution Count:717
717
142 -
143#ifdef QT_DEBUG -
144 qFatal("QDBusArgument: read from a write-only object"); -
145#else -
146 qWarning("QDBusArgument: read from a write-only object");
never executed (the execution status of this line is deduced): QMessageLogger("qdbusargument.cpp", 146, __PRETTY_FUNCTION__).warning("QDBusArgument: read from a write-only object");
-
147#endif -
148 -
149 return false;
never executed: return false;
0
150} -
151 -
152bool QDBusArgumentPrivate::checkReadAndDetach(QDBusArgumentPrivate *&d) -
153{ -
154 if (!checkRead(d))
partially evaluated: !checkRead(d)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:538
0-538
155 return false; // don't bother
never executed: return false;
0
156 -
157 if (d->ref.load() == 1)
evaluated: d->ref.load() == 1
TRUEFALSE
yes
Evaluation Count:467
yes
Evaluation Count:71
71-467
158 return true; // no need to detach
executed: return true;
Execution Count:467
467
159 -
160 QDBusDemarshaller *dd = new QDBusDemarshaller(d->capabilities);
executed (the execution status of this line is deduced): QDBusDemarshaller *dd = new QDBusDemarshaller(d->capabilities);
-
161 dd->message = q_dbus_message_ref(d->message);
executed (the execution status of this line is deduced): dd->message = q_dbus_message_ref(d->message);
-
162 dd->iterator = static_cast<QDBusDemarshaller*>(d)->iterator;
executed (the execution status of this line is deduced): dd->iterator = static_cast<QDBusDemarshaller*>(d)->iterator;
-
163 -
164 if (!d->ref.deref())
partially evaluated: !d->ref.deref()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:71
0-71
165 delete d;
never executed: delete d;
0
166 d = dd;
executed (the execution status of this line is deduced): d = dd;
-
167 return true;
executed: return true;
Execution Count:71
71
168} -
169 -
170/*! -
171 \class QDBusArgument -
172 \inmodule QtDBus -
173 \since 4.2 -
174 -
175 \brief The QDBusArgument class is used to marshall and demarshall D-Bus arguments. -
176 -
177 The class is used to send arguments over D-Bus to remote -
178 applications and to receive them back. D-Bus offers an extensible -
179 type system, based on a few primitive types and associations of -
180 them. See the \l {qdbustypesystem.html}{Qt D-Bus Type System} page -
181 for more information on the type system. -
182 -
183 QDBusArgument is the central class in the Qt D-Bus type system, -
184 providing functions to marshall and demarshall the primitive -
185 types. The compound types are then created by association of one -
186 or more of the primitive types in arrays, dictionaries or -
187 structures. -
188 -
189 The following example illustrates how a structure containing an -
190 integer and a string can be constructed using the \l -
191 {qdbustypesystem.html}{Qt D-Bus type system}: -
192 -
193 \snippet code/src_qdbus_qdbusargument.cpp 0 -
194 -
195 The type has to be registered with qDBusRegisterMetaType() before -
196 it can be used with QDBusArgument. Therefore, somewhere in your -
197 program, you should add the following code: -
198 -
199 \snippet code/src_qdbus_qdbusargument.cpp 1 -
200 -
201 Once registered, a type can be used in outgoing method calls -
202 (placed with QDBusAbstractInterface::call()), signal emissions -
203 from registered objects or in incoming calls from remote -
204 applications. -
205 -
206 It is important to note that the \c{operator<<} and \c{operator>>} -
207 streaming functions must always produce the same number of entries -
208 in case of structures, both in reading and in writing (marshalling -
209 and demarshalling), otherwise calls and signals may start to -
210 silently fail. -
211 -
212 The following example illustrates this wrong usage -
213 in context of a class that may contain invalid data: -
214 -
215 \code -
216 //bad code -
217 // Wrongly marshall the MyTime data into a D-Bus argument -
218 QDBusArgument &operator<<(QDBusArgument &argument, const MyTime &mytime) -
219 { -
220 argument.beginStructure(); -
221 if (mytime.isValid) -
222 argument << true << mytime.hour -
223 << mytime.minute << mytime.second; -
224 else -
225 argument << false; -
226 argument.endStructure(); -
227 return argument; -
228 } -
229 \endcode -
230 -
231 In this example, both the \c{operator<<} and the \c{operator>>} -
232 functions may produce a different number of reads/writes. This can -
233 confuse the Qt D-Bus type system and should be avoided. -
234 -
235 \sa QDBusAbstractInterface, {qdbustypesystem.html}{The Qt D-Bus type -
236 system}, {usingadaptors.html}{Using Adaptors}, qdbus_cast() -
237*/ -
238 -
239/*! -
240 \enum QDBusArgument::ElementType -
241 \since 4.5 -
242 -
243 This enum describes the type of element held by the argument. -
244 -
245 \value BasicType A basic element, which is understood by -
246 QVariant. The following types are considered basic: bool, -
247 byte, short, ushort, int, uint, qint64, quint64, double, -
248 QString, QByteArray, QDBusObjectPath, QDBusSignature -
249 -
250 \value VariantType The variant element (QDBusVariant) -
251 -
252 \value ArrayType An array element, usually represented by QList<T> -
253 or QVector<T>. Note: QByteArray and associative maps are not -
254 considered arrays, even if the D-Bus protocol transports them as such. -
255 -
256 \value StructureType A custom type represented by a structure, -
257 like QDateTime, QPoint, etc. -
258 -
259 \value MapType An associative container, like QMap<Key, Value> or -
260 QHash<Key, Value> -
261 -
262 \value MapEntryType One entry in an associative container: both -
263 the key and the value form one map-entry type. -
264 -
265 \value UnknownType The type is unknown or we have reached the end -
266 of the list. -
267 -
268 \sa currentType() -
269*/ -
270 -
271/*! -
272 \fn qdbus_cast(const QDBusArgument &argument) -
273 \relates QDBusArgument -
274 \since 4.2 -
275 -
276 Attempts to demarshall the contents of \a argument into the type -
277 \c{T}. For example: -
278 -
279 \snippet code/src_qdbus_qdbusargument.cpp 2 -
280 -
281 Note that it is equivalent to the following: -
282 -
283 \snippet code/src_qdbus_qdbusargument.cpp 3 -
284*/ -
285 -
286/*! -
287 Constructs an empty QDBusArgument argument. -
288 -
289 An empty QDBusArgument object does not allow either reading or -
290 writing to be performed. -
291*/ -
292QDBusArgument::QDBusArgument() -
293{ -
294 if (!qdbus_loadLibDBus()) {
never evaluated: !qdbus_loadLibDBus()
0
295 d = 0;
never executed (the execution status of this line is deduced): d = 0;
-
296 return;
never executed: return;
0
297 } -
298 -
299 QDBusMarshaller *dd = new QDBusMarshaller(0);
never executed (the execution status of this line is deduced): QDBusMarshaller *dd = new QDBusMarshaller(0);
-
300 d = dd;
never executed (the execution status of this line is deduced): d = dd;
-
301 -
302 // create a new message with any type, we won't sent it anyways -
303 dd->message = q_dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL);
never executed (the execution status of this line is deduced): dd->message = q_dbus_message_new(1);
-
304 q_dbus_message_iter_init_append(dd->message, &dd->iterator);
never executed (the execution status of this line is deduced): q_dbus_message_iter_init_append(dd->message, &dd->iterator);
-
305}
never executed: }
0
306 -
307/*! -
308 Constructs a copy of the \a other QDBusArgument object. -
309 -
310 Both objects will therefore contain the same state from this point -
311 forward. QDBusArguments are explicitly shared and, therefore, any -
312 modification to either copy will affect the other one too. -
313*/ -
314QDBusArgument::QDBusArgument(const QDBusArgument &other) -
315 : d(other.d) -
316{ -
317 if (d)
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:183
no
Evaluation Count:0
0-183
318 d->ref.ref();
executed: d->ref.ref();
Execution Count:183
183
319}
executed: }
Execution Count:183
183
320 -
321/*! -
322 \internal -
323*/ -
324QDBusArgument::QDBusArgument(QDBusArgumentPrivate *dd) -
325 : d(dd) -
326{ -
327}
executed: }
Execution Count:192
192
328 -
329/*! -
330 Copies the \a other QDBusArgument object into this one. -
331 -
332 Both objects will therefore contain the same state from this point -
333 forward. QDBusArguments are explicitly shared and, therefore, any -
334 modification to either copy will affect the other one too. -
335*/ -
336QDBusArgument &QDBusArgument::operator=(const QDBusArgument &other) -
337{ -
338 qAtomicAssign(d, other.d);
never executed (the execution status of this line is deduced): qAtomicAssign(d, other.d);
-
339 return *this;
never executed: return *this;
0
340} -
341 -
342/*! -
343 Disposes of the resources associated with this QDBusArgument -
344 object. -
345*/ -
346QDBusArgument::~QDBusArgument() -
347{ -
348 if (d && !d->ref.deref())
evaluated: d
TRUEFALSE
yes
Evaluation Count:313
yes
Evaluation Count:61
evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:147
yes
Evaluation Count:166
61-313
349 delete d;
executed: delete d;
Execution Count:147
147
350}
executed: }
Execution Count:374
374
351 -
352/*! -
353 Appends the primitive value \a arg of type \c{BYTE} to the D-Bus stream. -
354*/ -
355QDBusArgument &QDBusArgument::operator<<(uchar arg) -
356{ -
357 if (QDBusArgumentPrivate::checkWrite(d))
never evaluated: QDBusArgumentPrivate::checkWrite(d)
0
358 d->marshaller()->append(arg);
never executed: d->marshaller()->append(arg);
0
359 return *this;
never executed: return *this;
0
360} -
361 -
362/*! -
363 \overload -
364 Appends the primitive value \a arg of type \c{BOOLEAN} to the D-Bus stream. -
365*/ -
366QDBusArgument &QDBusArgument::operator<<(bool arg) -
367{ -
368 if (QDBusArgumentPrivate::checkWrite(d))
never evaluated: QDBusArgumentPrivate::checkWrite(d)
0
369 d->marshaller()->append(arg);
never executed: d->marshaller()->append(arg);
0
370 return *this;
never executed: return *this;
0
371} -
372 -
373/*! -
374 \overload -
375 Appends the primitive value \a arg of type \c{INT16} to the D-Bus stream. -
376*/ -
377QDBusArgument &QDBusArgument::operator<<(short arg) -
378{ -
379 if (QDBusArgumentPrivate::checkWrite(d))
never evaluated: QDBusArgumentPrivate::checkWrite(d)
0
380 d->marshaller()->append(arg);
never executed: d->marshaller()->append(arg);
0
381 return *this;
never executed: return *this;
0
382} -
383 -
384/*! -
385 \overload -
386 Appends the primitive value \a arg of type \c{UINT16} to the D-Bus stream. -
387*/ -
388QDBusArgument &QDBusArgument::operator<<(ushort arg) -
389{ -
390 if (QDBusArgumentPrivate::checkWrite(d))
never evaluated: QDBusArgumentPrivate::checkWrite(d)
0
391 d->marshaller()->append(arg);
never executed: d->marshaller()->append(arg);
0
392 return *this;
never executed: return *this;
0
393} -
394 -
395/*! -
396 \overload -
397 Appends the primitive value \a arg of type \c{INT32} to the D-Bus stream. -
398*/ -
399QDBusArgument &QDBusArgument::operator<<(int arg) -
400{ -
401 if (QDBusArgumentPrivate::checkWrite(d))
partially evaluated: QDBusArgumentPrivate::checkWrite(d)
TRUEFALSE
yes
Evaluation Count:120
no
Evaluation Count:0
0-120
402 d->marshaller()->append(arg);
executed: d->marshaller()->append(arg);
Execution Count:120
120
403 return *this;
executed: return *this;
Execution Count:120
120
404} -
405 -
406/*! -
407 \overload -
408 Appends the primitive value \a arg of type \c{UINT32} to the D-Bus stream. -
409*/ -
410QDBusArgument &QDBusArgument::operator<<(uint arg) -
411{ -
412 if (QDBusArgumentPrivate::checkWrite(d))
never evaluated: QDBusArgumentPrivate::checkWrite(d)
0
413 d->marshaller()->append(arg);
never executed: d->marshaller()->append(arg);
0
414 return *this;
never executed: return *this;
0
415} -
416 -
417/*! -
418 \overload -
419 Appends the primitive value \a arg of type \c{INT64} to the D-Bus stream. -
420*/ -
421QDBusArgument &QDBusArgument::operator<<(qlonglong arg) -
422{ -
423 if (QDBusArgumentPrivate::checkWrite(d))
partially evaluated: QDBusArgumentPrivate::checkWrite(d)
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
424 d->marshaller()->append(arg);
executed: d->marshaller()->append(arg);
Execution Count:6
6
425 return *this;
executed: return *this;
Execution Count:6
6
426} -
427 -
428/*! -
429 \overload -
430 Appends the primitive value \a arg of type \c{UINT64} to the D-Bus stream. -
431*/ -
432QDBusArgument &QDBusArgument::operator<<(qulonglong arg) -
433{ -
434 if (QDBusArgumentPrivate::checkWrite(d))
never evaluated: QDBusArgumentPrivate::checkWrite(d)
0
435 d->marshaller()->append(arg);
never executed: d->marshaller()->append(arg);
0
436 return *this;
never executed: return *this;
0
437} -
438 -
439/*! -
440 \overload -
441 Appends the primitive value \a arg of type \c{DOUBLE} (double-precision -
442 floating-point) to the D-Bus stream. -
443*/ -
444QDBusArgument &QDBusArgument::operator<<(double arg) -
445{ -
446 if (QDBusArgumentPrivate::checkWrite(d))
partially evaluated: QDBusArgumentPrivate::checkWrite(d)
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
447 d->marshaller()->append(arg);
executed: d->marshaller()->append(arg);
Execution Count:12
12
448 return *this;
executed: return *this;
Execution Count:12
12
449} -
450 -
451/*! -
452 \overload -
453 Appends the primitive value \a arg of type \c{STRING} (Unicode character -
454 string) to the D-Bus stream. -
455*/ -
456QDBusArgument &QDBusArgument::operator<<(const QString &arg) -
457{ -
458 if (QDBusArgumentPrivate::checkWrite(d))
partially evaluated: QDBusArgumentPrivate::checkWrite(d)
TRUEFALSE
yes
Evaluation Count:94
no
Evaluation Count:0
0-94
459 d->marshaller()->append(arg);
executed: d->marshaller()->append(arg);
Execution Count:94
94
460 return *this;
executed: return *this;
Execution Count:94
94
461} -
462 -
463/*! -
464 \overload -
465 \internal -
466 Appends the primitive value \a arg of type \c{OBJECT_PATH} (path to a D-Bus -
467 object) to the D-Bus stream. -
468*/ -
469QDBusArgument &QDBusArgument::operator<<(const QDBusObjectPath &arg) -
470{ -
471 if (QDBusArgumentPrivate::checkWrite(d))
partially evaluated: QDBusArgumentPrivate::checkWrite(d)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
472 d->marshaller()->append(arg);
executed: d->marshaller()->append(arg);
Execution Count:4
4
473 return *this;
executed: return *this;
Execution Count:4
4
474} -
475 -
476/*! -
477 \overload -
478 \internal -
479 Appends the primitive value \a arg of type \c{SIGNATURE} (D-Bus type -
480 signature) to the D-Bus stream. -
481*/ -
482QDBusArgument &QDBusArgument::operator<<(const QDBusSignature &arg) -
483{ -
484 if (QDBusArgumentPrivate::checkWrite(d))
never evaluated: QDBusArgumentPrivate::checkWrite(d)
0
485 d->marshaller()->append(arg);
never executed: d->marshaller()->append(arg);
0
486 return *this;
never executed: return *this;
0
487} -
488 -
489/*! -
490 \overload -
491 \since 4.8 -
492 \internal -
493 Appends the primitive value \a arg of type \c{UNIX_FILE_DESCRIPTOR} (Unix -
494 File Descriptor) to the D-Bus stream. -
495*/ -
496QDBusArgument &QDBusArgument::operator<<(const QDBusUnixFileDescriptor &arg) -
497{ -
498 if (QDBusArgumentPrivate::checkWrite(d))
never evaluated: QDBusArgumentPrivate::checkWrite(d)
0
499 d->marshaller()->append(arg);
never executed: d->marshaller()->append(arg);
0
500 return *this;
never executed: return *this;
0
501} -
502 -
503/*! -
504 \overload -
505 Appends the primitive value \a arg of type \c{VARIANT} to the D-Bus stream. -
506 -
507 A D-Bus variant type can contain any type, including other -
508 variants. It is similar to the Qt QVariant type. -
509*/ -
510QDBusArgument &QDBusArgument::operator<<(const QDBusVariant &arg) -
511{ -
512 if (QDBusArgumentPrivate::checkWrite(d))
partially evaluated: QDBusArgumentPrivate::checkWrite(d)
TRUEFALSE
yes
Evaluation Count:48
no
Evaluation Count:0
0-48
513 d->marshaller()->append(arg);
executed: d->marshaller()->append(arg);
Execution Count:48
48
514 return *this;
executed: return *this;
Execution Count:48
48
515} -
516 -
517/*! -
518 \overload -
519 Appends the QStringList given by \a arg as \c{ARRAY of STRING} -
520 to the D-Bus stream. -
521 -
522 QStringList and QByteArray are the only two non-primitive types -
523 that are supported directly by QDBusArgument because of their -
524 widespread usage in Qt applications. -
525 -
526 Other arrays are supported through compound types in Qt D-Bus. -
527*/ -
528QDBusArgument &QDBusArgument::operator<<(const QStringList &arg) -
529{ -
530 if (QDBusArgumentPrivate::checkWrite(d))
partially evaluated: QDBusArgumentPrivate::checkWrite(d)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
531 d->marshaller()->append(arg);
executed: d->marshaller()->append(arg);
Execution Count:4
4
532 return *this;
executed: return *this;
Execution Count:4
4
533} -
534 -
535/*! -
536 \overload -
537 Appends the QByteArray given by \a arg as \c{ARRAY of BYTE} -
538 to the D-Bus stream. -
539 -
540 QStringList and QByteArray are the only two non-primitive types -
541 that are supported directly by QDBusArgument because of their -
542 widespread usage in Qt applications. -
543 -
544 Other arrays are supported through compound types in Qt D-Bus. -
545*/ -
546QDBusArgument &QDBusArgument::operator<<(const QByteArray &arg) -
547{ -
548 if (QDBusArgumentPrivate::checkWrite(d))
partially evaluated: QDBusArgumentPrivate::checkWrite(d)
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
549 d->marshaller()->append(arg);
executed: d->marshaller()->append(arg);
Execution Count:3
3
550 return *this;
executed: return *this;
Execution Count:3
3
551} -
552 -
553/*! -
554 \internal -
555 \since 4.5 -
556 -
557 Appends the variant \a v. -
558 -
559 \sa asVariant() -
560*/ -
561void QDBusArgument::appendVariant(const QVariant &v) -
562{ -
563 if (QDBusArgumentPrivate::checkWrite(d))
never evaluated: QDBusArgumentPrivate::checkWrite(d)
0
564 d->marshaller()->appendVariantInternal(v);
never executed: d->marshaller()->appendVariantInternal(v);
0
565}
never executed: }
0
566 -
567/*! -
568 \internal -
569 Returns the type signature of the D-Bus type this QDBusArgument -
570 object is currently pointing to. -
571*/ -
572QString QDBusArgument::currentSignature() const -
573{ -
574 if (!d)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:35
0-35
575 return QString();
never executed: return QString();
0
576 if (d->direction == QDBusArgumentPrivate::Demarshalling)
partially evaluated: d->direction == QDBusArgumentPrivate::Demarshalling
TRUEFALSE
yes
Evaluation Count:35
no
Evaluation Count:0
0-35
577 return d->demarshaller()->currentSignature();
executed: return d->demarshaller()->currentSignature();
Execution Count:35
35
578 else -
579 return d->marshaller()->currentSignature();
never executed: return d->marshaller()->currentSignature();
0
580} -
581 -
582/*! -
583 \since 4.5 -
584 Returns the classification of the current element type. If an -
585 error decoding the type occurs or if we're at the end of the -
586 argument, this function returns QDBusArgument::UnknownType. -
587 -
588 This function only makes sense when demarshalling arguments. If it -
589 is used while marshalling, it will always return UnknownType. -
590*/ -
591QDBusArgument::ElementType QDBusArgument::currentType() const -
592{ -
593 if (!d)
never evaluated: !d
0
594 return UnknownType;
never executed: return UnknownType;
0
595 if (d->direction == QDBusArgumentPrivate::Demarshalling)
never evaluated: d->direction == QDBusArgumentPrivate::Demarshalling
0
596 return d->demarshaller()->currentType();
never executed: return d->demarshaller()->currentType();
0
597 return UnknownType;
never executed: return UnknownType;
0
598} -
599 -
600/*! -
601 Extracts one D-BUS primitive argument of type \c{BYTE} from the -
602 D-BUS stream and puts it into \a arg. -
603*/ -
604const QDBusArgument &QDBusArgument::operator>>(uchar &arg) const -
605{ -
606 if (QDBusArgumentPrivate::checkReadAndDetach(d))
never evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
0
607 arg = d->demarshaller()->toByte();
never executed: arg = d->demarshaller()->toByte();
0
608 return *this;
never executed: return *this;
0
609} -
610 -
611/*! -
612 \overload -
613 Extracts one D-Bus primitive argument of type \c{BOOLEAN} from the -
614 D-Bus stream. -
615*/ -
616const QDBusArgument &QDBusArgument::operator>>(bool &arg) const -
617{ -
618 if (QDBusArgumentPrivate::checkReadAndDetach(d))
never evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
0
619 arg = d->demarshaller()->toBool();
never executed: arg = d->demarshaller()->toBool();
0
620 return *this;
never executed: return *this;
0
621} -
622 -
623/*! -
624 \overload -
625 Extracts one D-Bus primitive argument of type \c{UINT16} from the -
626 D-Bus stream. -
627*/ -
628const QDBusArgument &QDBusArgument::operator>>(ushort &arg) const -
629{ -
630 if (QDBusArgumentPrivate::checkReadAndDetach(d))
never evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
0
631 arg = d->demarshaller()->toUShort();
never executed: arg = d->demarshaller()->toUShort();
0
632 return *this;
never executed: return *this;
0
633} -
634 -
635/*! -
636 \overload -
637 Extracts one D-Bus primitive argument of type \c{INT16} from the -
638 D-Bus stream. -
639*/ -
640const QDBusArgument &QDBusArgument::operator>>(short &arg) const -
641{ -
642 if (QDBusArgumentPrivate::checkReadAndDetach(d))
never evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
0
643 arg = d->demarshaller()->toShort();
never executed: arg = d->demarshaller()->toShort();
0
644 return *this;
never executed: return *this;
0
645} -
646 -
647/*! -
648 \overload -
649 Extracts one D-Bus primitive argument of type \c{INT32} from the -
650 D-Bus stream. -
651*/ -
652const QDBusArgument &QDBusArgument::operator>>(int &arg) const -
653{ -
654 if (QDBusArgumentPrivate::checkReadAndDetach(d))
partially evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
TRUEFALSE
yes
Evaluation Count:78
no
Evaluation Count:0
0-78
655 arg = d->demarshaller()->toInt();
executed: arg = d->demarshaller()->toInt();
Execution Count:78
78
656 return *this;
executed: return *this;
Execution Count:78
78
657} -
658 -
659/*! -
660 \overload -
661 Extracts one D-Bus primitive argument of type \c{UINT32} from the -
662 D-Bus stream. -
663*/ -
664const QDBusArgument &QDBusArgument::operator>>(uint &arg) const -
665{ -
666 if (QDBusArgumentPrivate::checkReadAndDetach(d))
never evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
0
667 arg = d->demarshaller()->toUInt();
never executed: arg = d->demarshaller()->toUInt();
0
668 return *this;
never executed: return *this;
0
669} -
670 -
671/*! -
672 \overload -
673 Extracts one D-Bus primitive argument of type \c{INT64} from the -
674 D-Bus stream. -
675*/ -
676const QDBusArgument &QDBusArgument::operator>>(qlonglong &arg) const -
677{ -
678 if (QDBusArgumentPrivate::checkReadAndDetach(d))
partially evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
679 arg = d->demarshaller()->toLongLong();
executed: arg = d->demarshaller()->toLongLong();
Execution Count:4
4
680 return *this;
executed: return *this;
Execution Count:4
4
681} -
682 -
683/*! -
684 \overload -
685 Extracts one D-Bus primitive argument of type \c{UINT64} from the -
686 D-Bus stream. -
687*/ -
688const QDBusArgument &QDBusArgument::operator>>(qulonglong &arg) const -
689{ -
690 if (QDBusArgumentPrivate::checkReadAndDetach(d))
never evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
0
691 arg = d->demarshaller()->toULongLong();
never executed: arg = d->demarshaller()->toULongLong();
0
692 return *this;
never executed: return *this;
0
693} -
694 -
695/*! -
696 \overload -
697 Extracts one D-Bus primitive argument of type \c{DOUBLE} -
698 (double-precision floating pount) from the D-Bus stream. -
699*/ -
700const QDBusArgument &QDBusArgument::operator>>(double &arg) const -
701{ -
702 if (QDBusArgumentPrivate::checkReadAndDetach(d))
never evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
0
703 arg = d->demarshaller()->toDouble();
never executed: arg = d->demarshaller()->toDouble();
0
704 return *this;
never executed: return *this;
0
705} -
706 -
707/*! -
708 \overload -
709 Extracts one D-Bus primitive argument of type \c{STRING} (Unicode -
710 character string) from the D-Bus stream. -
711*/ -
712const QDBusArgument &QDBusArgument::operator>>(QString &arg) const -
713{ -
714 if (QDBusArgumentPrivate::checkReadAndDetach(d))
partially evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
TRUEFALSE
yes
Evaluation Count:84
no
Evaluation Count:0
0-84
715 arg = d->demarshaller()->toString();
executed: arg = d->demarshaller()->toString();
Execution Count:84
84
716 return *this;
executed: return *this;
Execution Count:84
84
717} -
718 -
719/*! -
720 \overload -
721 \internal -
722 Extracts one D-Bus primitive argument of type \c{OBJECT_PATH} -
723 (D-Bus path to an object) from the D-Bus stream. -
724*/ -
725const QDBusArgument &QDBusArgument::operator>>(QDBusObjectPath &arg) const -
726{ -
727 if (QDBusArgumentPrivate::checkReadAndDetach(d))
partially evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
728 arg = d->demarshaller()->toObjectPath();
executed: arg = d->demarshaller()->toObjectPath();
Execution Count:2
2
729 return *this;
executed: return *this;
Execution Count:2
2
730} -
731 -
732/*! -
733 \overload -
734 \internal -
735 Extracts one D-Bus primitive argument of type \c{SIGNATURE} (D-Bus -
736 type signature) from the D-Bus stream. -
737*/ -
738const QDBusArgument &QDBusArgument::operator>>(QDBusSignature &arg) const -
739{ -
740 if (QDBusArgumentPrivate::checkReadAndDetach(d))
never evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
0
741 arg = d->demarshaller()->toSignature();
never executed: arg = d->demarshaller()->toSignature();
0
742 return *this;
never executed: return *this;
0
743} -
744 -
745/*! -
746 \overload -
747 \since 4.8 -
748 \internal -
749 Extracts one D-Bus primitive argument of type \c{UNIX_FILE_DESCRIPTOR} -
750 (Unix file descriptor) from the D-Bus stream. -
751*/ -
752const QDBusArgument &QDBusArgument::operator>>(QDBusUnixFileDescriptor &arg) const -
753{ -
754 if (QDBusArgumentPrivate::checkReadAndDetach(d))
never evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
0
755 arg = d->demarshaller()->toUnixFileDescriptor();
never executed: arg = d->demarshaller()->toUnixFileDescriptor();
0
756 return *this;
never executed: return *this;
0
757} -
758 -
759/*! -
760 \overload -
761 Extracts one D-Bus primitive argument of type \c{VARIANT} from the -
762 D-Bus stream. -
763 -
764 A D-Bus variant type can contain any type, including other -
765 variants. It is similar to the Qt QVariant type. -
766 -
767 In case the variant contains a type not directly supported by -
768 QDBusArgument, the value of the returned QDBusVariant will contain -
769 another QDBusArgument. It is your responsibility to further -
770 demarshall it into another type. -
771*/ -
772const QDBusArgument &QDBusArgument::operator>>(QDBusVariant &arg) const -
773{ -
774 if (QDBusArgumentPrivate::checkReadAndDetach(d))
partially evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
TRUEFALSE
yes
Evaluation Count:76
no
Evaluation Count:0
0-76
775 arg = d->demarshaller()->toVariant();
executed: arg = d->demarshaller()->toVariant();
Execution Count:76
76
776 return *this;
executed: return *this;
Execution Count:76
76
777} -
778 -
779/*! -
780 \overload -
781 Extracts an array of strings from the D-Bus stream and return it -
782 as a QStringList. -
783 -
784 QStringList and QByteArray are the only two non-primitive types -
785 that are supported directly by QDBusArgument because of their -
786 widespread usage in Qt applications. -
787 -
788 Other arrays are supported through compound types in Qt D-Bus. -
789*/ -
790const QDBusArgument &QDBusArgument::operator>>(QStringList &arg) const -
791{ -
792 if (QDBusArgumentPrivate::checkReadAndDetach(d))
never evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
0
793 arg = d->demarshaller()->toStringList();
never executed: arg = d->demarshaller()->toStringList();
0
794 return *this;
never executed: return *this;
0
795} -
796 -
797/*! -
798 \overload -
799 Extracts an array of bytes from the D-Bus stream and return it -
800 as a QByteArray. -
801 -
802 QStringList and QByteArray are the only two non-primitive types -
803 that are supported directly by QDBusArgument because of their -
804 widespread usage in Qt applications. -
805 -
806 Other arrays are supported through compound types in Qt D-Bus. -
807*/ -
808const QDBusArgument &QDBusArgument::operator>>(QByteArray &arg) const -
809{ -
810 if (QDBusArgumentPrivate::checkReadAndDetach(d))
never evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
0
811 arg = d->demarshaller()->toByteArray();
never executed: arg = d->demarshaller()->toByteArray();
0
812 return *this;
never executed: return *this;
0
813} -
814 -
815/*! -
816 Opens a new D-Bus structure suitable for appending new arguments. -
817 -
818 This function is used usually in \c{operator<<} streaming -
819 operators, as in the following example: -
820 -
821 \snippet code/src_qdbus_qdbusargument.cpp 4 -
822 -
823 Structures can contain other structures, so the following code is -
824 also valid: -
825 -
826 \snippet code/src_qdbus_qdbusargument.cpp 5 -
827 -
828 \sa endStructure(), beginArray(), beginMap() -
829*/ -
830void QDBusArgument::beginStructure() -
831{ -
832 if (QDBusArgumentPrivate::checkWrite(d))
partially evaluated: QDBusArgumentPrivate::checkWrite(d)
TRUEFALSE
yes
Evaluation Count:65
no
Evaluation Count:0
0-65
833 d = d->marshaller()->beginStructure();
executed: d = d->marshaller()->beginStructure();
Execution Count:65
65
834}
executed: }
Execution Count:65
65
835 -
836/*! -
837 Closes a D-Bus structure opened with beginStructure(). This function must be called -
838 same number of times that beginStructure() is called. -
839 -
840 \sa beginStructure(), endArray(), endMap() -
841*/ -
842void QDBusArgument::endStructure() -
843{ -
844 if (QDBusArgumentPrivate::checkWrite(d))
partially evaluated: QDBusArgumentPrivate::checkWrite(d)
TRUEFALSE
yes
Evaluation Count:65
no
Evaluation Count:0
0-65
845 d = d->marshaller()->endStructure();
executed: d = d->marshaller()->endStructure();
Execution Count:65
65
846}
executed: }
Execution Count:65
65
847 -
848/*! -
849 Opens a new D-Bus array suitable for appending elements of meta-type \a id. -
850 -
851 This function is used usually in \c{operator<<} streaming -
852 operators, as in the following example: -
853 -
854 \snippet code/src_qdbus_qdbusargument.cpp 6 -
855 -
856 If the type you want to marshall is a QList, QVector or any of the -
857 Qt's \l {Container Classes} that take one template parameter, -
858 you need not declare an \c{operator<<} function for it, since -
859 Qt D-Bus provides generic templates to do the job of marshalling -
860 the data. The same applies for STL's sequence containers, such -
861 as \c {std::list}, \c {std::vector}, etc. -
862 -
863 \sa endArray(), beginStructure(), beginMap() -
864*/ -
865void QDBusArgument::beginArray(int id) -
866{ -
867 if (QDBusArgumentPrivate::checkWrite(d))
partially evaluated: QDBusArgumentPrivate::checkWrite(d)
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
0-32
868 d = d->marshaller()->beginArray(id);
executed: d = d->marshaller()->beginArray(id);
Execution Count:32
32
869}
executed: }
Execution Count:32
32
870 -
871/*! -
872 Closes a D-Bus array opened with beginArray(). This function must be called -
873 same number of times that beginArray() is called. -
874 -
875 \sa beginArray(), endStructure(), endMap() -
876*/ -
877void QDBusArgument::endArray() -
878{ -
879 if (QDBusArgumentPrivate::checkWrite(d))
partially evaluated: QDBusArgumentPrivate::checkWrite(d)
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
0-32
880 d = d->marshaller()->endArray();
executed: d = d->marshaller()->endArray();
Execution Count:32
32
881}
executed: }
Execution Count:32
32
882 -
883/*! -
884 Opens a new D-Bus map suitable for -
885 appending elements. Maps are containers that associate one entry -
886 (the key) to another (the value), such as Qt's QMap or QHash. The -
887 ids of the map's key and value meta types must be passed in \a kid -
888 and \a vid respectively. -
889 -
890 This function is used usually in \c{operator<<} streaming -
891 operators, as in the following example: -
892 -
893 \snippet code/src_qdbus_qdbusargument.cpp 7 -
894 -
895 If the type you want to marshall is a QMap or QHash, you need not -
896 declare an \c{operator<<} function for it, since Qt D-Bus provides -
897 generic templates to do the job of marshalling the data. -
898 -
899 \sa endMap(), beginStructure(), beginArray(), beginMapEntry() -
900*/ -
901void QDBusArgument::beginMap(int kid, int vid) -
902{ -
903 if (QDBusArgumentPrivate::checkWrite(d))
partially evaluated: QDBusArgumentPrivate::checkWrite(d)
TRUEFALSE
yes
Evaluation Count:34
no
Evaluation Count:0
0-34
904 d = d->marshaller()->beginMap(kid, vid);
executed: d = d->marshaller()->beginMap(kid, vid);
Execution Count:34
34
905}
executed: }
Execution Count:34
34
906 -
907/*! -
908 Closes a D-Bus map opened with beginMap(). This function must be called -
909 same number of times that beginMap() is called. -
910 -
911 \sa beginMap(), endStructure(), endArray() -
912*/ -
913void QDBusArgument::endMap() -
914{ -
915 if (QDBusArgumentPrivate::checkWrite(d))
partially evaluated: QDBusArgumentPrivate::checkWrite(d)
TRUEFALSE
yes
Evaluation Count:34
no
Evaluation Count:0
0-34
916 d = d->marshaller()->endMap();
executed: d = d->marshaller()->endMap();
Execution Count:34
34
917}
executed: }
Execution Count:34
34
918 -
919/*! -
920 Opens a D-Bus map entry suitable for -
921 appending the key and value entries. This function is only valid -
922 when a map has been opened with beginMap(). -
923 -
924 See beginMap() for an example of usage of this function. -
925 -
926 \sa endMapEntry(), beginMap() -
927*/ -
928void QDBusArgument::beginMapEntry() -
929{ -
930 if (QDBusArgumentPrivate::checkWrite(d))
partially evaluated: QDBusArgumentPrivate::checkWrite(d)
TRUEFALSE
yes
Evaluation Count:54
no
Evaluation Count:0
0-54
931 d = d->marshaller()->beginMapEntry();
executed: d = d->marshaller()->beginMapEntry();
Execution Count:54
54
932}
executed: }
Execution Count:54
54
933 -
934/*! -
935 Closes a D-Bus map entry opened with beginMapEntry(). This function must be called -
936 same number of times that beginMapEntry() is called. -
937 -
938 \sa beginMapEntry() -
939*/ -
940void QDBusArgument::endMapEntry() -
941{ -
942 if (QDBusArgumentPrivate::checkWrite(d))
partially evaluated: QDBusArgumentPrivate::checkWrite(d)
TRUEFALSE
yes
Evaluation Count:54
no
Evaluation Count:0
0-54
943 d = d->marshaller()->endMapEntry();
executed: d = d->marshaller()->endMapEntry();
Execution Count:54
54
944}
executed: }
Execution Count:54
54
945 -
946/*! -
947 Opens a D-Bus structure suitable for extracting elements. -
948 -
949 This function is used usually in \c{operator>>} streaming -
950 operators, as in the following example: -
951 -
952 \snippet code/src_qdbus_qdbusargument.cpp 8 -
953 -
954 \sa endStructure(), beginArray(), beginMap() -
955*/ -
956void QDBusArgument::beginStructure() const -
957{ -
958 if (QDBusArgumentPrivate::checkReadAndDetach(d))
partially evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
0-32
959 d = d->demarshaller()->beginStructure();
executed: d = d->demarshaller()->beginStructure();
Execution Count:32
32
960}
executed: }
Execution Count:32
32
961 -
962/*! -
963 Closes the D-Bus structure and allow extracting of the next element -
964 after the structure. -
965 -
966 \sa beginStructure() -
967*/ -
968void QDBusArgument::endStructure() const -
969{ -
970 if (QDBusArgumentPrivate::checkReadAndDetach(d))
partially evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
TRUEFALSE
yes
Evaluation Count:32
no
Evaluation Count:0
0-32
971 d = d->demarshaller()->endStructure();
executed: d = d->demarshaller()->endStructure();
Execution Count:32
32
972}
executed: }
Execution Count:32
32
973 -
974/*! -
975 Recurses into the D-Bus array to allow extraction of -
976 the array elements. -
977 -
978 This function is used usually in \c{operator>>} streaming -
979 operators, as in the following example: -
980 -
981 \snippet code/src_qdbus_qdbusargument.cpp 9 -
982 -
983 If the type you want to demarshall is a QList, QVector or any of the -
984 Qt's \l {Container Classes} that take one template parameter, you -
985 need not declare an \c{operator>>} function for it, since Qt D-Bus -
986 provides generic templates to do the job of demarshalling the data. -
987 The same applies for STL's sequence containers, such as \c {std::list}, -
988 \c {std::vector}, etc. -
989 -
990 \sa atEnd(), beginStructure(), beginMap() -
991*/ -
992void QDBusArgument::beginArray() const -
993{ -
994 if (QDBusArgumentPrivate::checkReadAndDetach(d))
partially evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
TRUEFALSE
yes
Evaluation Count:31
no
Evaluation Count:0
0-31
995 d = d->demarshaller()->beginArray();
executed: d = d->demarshaller()->beginArray();
Execution Count:31
31
996}
executed: }
Execution Count:31
31
997 -
998/*! -
999 Closes the D-Bus array and allow extracting of the next element -
1000 after the array. -
1001 -
1002 \sa beginArray() -
1003*/ -
1004void QDBusArgument::endArray() const -
1005{ -
1006 if (QDBusArgumentPrivate::checkReadAndDetach(d))
partially evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
TRUEFALSE
yes
Evaluation Count:31
no
Evaluation Count:0
0-31
1007 d = d->demarshaller()->endArray();
executed: d = d->demarshaller()->endArray();
Execution Count:31
31
1008}
executed: }
Execution Count:31
31
1009 -
1010/*! -
1011 Recurses into the D-Bus map to allow extraction of -
1012 the map's elements. -
1013 -
1014 This function is used usually in \c{operator>>} streaming -
1015 operators, as in the following example: -
1016 -
1017 \snippet code/src_qdbus_qdbusargument.cpp 10 -
1018 -
1019 If the type you want to demarshall is a QMap or QHash, you need not -
1020 declare an \c{operator>>} function for it, since Qt D-Bus provides -
1021 generic templates to do the job of demarshalling the data. -
1022 -
1023 \sa endMap(), beginStructure(), beginArray(), beginMapEntry() -
1024*/ -
1025void QDBusArgument::beginMap() const -
1026{ -
1027 if (QDBusArgumentPrivate::checkReadAndDetach(d))
partially evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
0-20
1028 d = d->demarshaller()->beginMap();
executed: d = d->demarshaller()->beginMap();
Execution Count:20
20
1029}
executed: }
Execution Count:20
20
1030 -
1031/*! -
1032 Closes the D-Bus map and allow extracting of the next element -
1033 after the map. -
1034 -
1035 \sa beginMap() -
1036*/ -
1037void QDBusArgument::endMap() const -
1038{ -
1039 if (QDBusArgumentPrivate::checkReadAndDetach(d))
partially evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
0-20
1040 d = d->demarshaller()->endMap();
executed: d = d->demarshaller()->endMap();
Execution Count:20
20
1041}
executed: }
Execution Count:20
20
1042 -
1043/*! -
1044 Recurses into the D-Bus map entry to allow extraction -
1045 of the key and value pair. -
1046 -
1047 See beginMap() for an example of how this function is usually used. -
1048 -
1049 \sa endMapEntry(), beginMap() -
1050*/ -
1051void QDBusArgument::beginMapEntry() const -
1052{ -
1053 if (QDBusArgumentPrivate::checkReadAndDetach(d))
partially evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
TRUEFALSE
yes
Evaluation Count:64
no
Evaluation Count:0
0-64
1054 d = d->demarshaller()->beginMapEntry();
executed: d = d->demarshaller()->beginMapEntry();
Execution Count:64
64
1055}
executed: }
Execution Count:64
64
1056 -
1057/*! -
1058 Closes the D-Bus map entry and allow extracting of the next element -
1059 on the map. -
1060 -
1061 \sa beginMapEntry() -
1062*/ -
1063void QDBusArgument::endMapEntry() const -
1064{ -
1065 if (QDBusArgumentPrivate::checkReadAndDetach(d))
partially evaluated: QDBusArgumentPrivate::checkReadAndDetach(d)
TRUEFALSE
yes
Evaluation Count:64
no
Evaluation Count:0
0-64
1066 d = d->demarshaller()->endMapEntry();
executed: d = d->demarshaller()->endMapEntry();
Execution Count:64
64
1067}
executed: }
Execution Count:64
64
1068 -
1069/*! -
1070 Returns true if there are no more elements to be extracted from -
1071 this QDBusArgument. This function is usually used in QDBusArgument -
1072 objects returned from beginMap() and beginArray(). -
1073*/ -
1074bool QDBusArgument::atEnd() const -
1075{ -
1076 if (QDBusArgumentPrivate::checkRead(d))
partially evaluated: QDBusArgumentPrivate::checkRead(d)
TRUEFALSE
yes
Evaluation Count:179
no
Evaluation Count:0
0-179
1077 return d->demarshaller()->atEnd();
executed: return d->demarshaller()->atEnd();
Execution Count:179
179
1078 -
1079 return true; // at least, stop reading
never executed: return true;
0
1080} -
1081 -
1082/*! -
1083 \since 4.5 -
1084 -
1085 Returns the current argument in the form of a QVariant. Basic -
1086 types will be decoded and returned in the QVariant, but for -
1087 complex types, this function will return a QDBusArgument object in -
1088 the QVariant. It is the caller's responsibility to decode the -
1089 argument (for example, by calling asVariant() in it). -
1090 -
1091 For example, if the current argument is an INT32, this function -
1092 will return a QVariant with an argument of type QVariant::Int. For -
1093 an array of INT32, it will return a QVariant containing a -
1094 QDBusArgument. -
1095 -
1096 If an error occurs or if there are no more arguments to decode -
1097 (i.e., we are at the end of the argument list), this function will -
1098 return an invalid QVariant. -
1099 -
1100 \sa atEnd() -
1101*/ -
1102QVariant QDBusArgument::asVariant() const -
1103{ -
1104 if (QDBusArgumentPrivate::checkRead(d))
never evaluated: QDBusArgumentPrivate::checkRead(d)
0
1105 return d->demarshaller()->toVariantInternal();
never executed: return d->demarshaller()->toVariantInternal();
0
1106 -
1107 return QVariant();
never executed: return QVariant();
0
1108} -
1109 -
1110QT_END_NAMESPACE -
1111 -
1112// for optimization purposes, we include the marshallers here -
1113#include "qdbusmarshaller.cpp" -
1114#include "qdbusdemarshaller.cpp" -
1115 -
1116QT_BEGIN_NAMESPACE -
1117 -
1118// QDBusArgument operators -
1119 -
1120const QDBusArgument &operator>>(const QDBusArgument &a, QVariant &v) -
1121{ -
1122 QDBusVariant dbv;
executed (the execution status of this line is deduced): QDBusVariant dbv;
-
1123 a >> dbv;
executed (the execution status of this line is deduced): a >> dbv;
-
1124 v = dbv.variant();
executed (the execution status of this line is deduced): v = dbv.variant();
-
1125 return a;
executed: return a;
Execution Count:76
76
1126} -
1127 -
1128// QVariant types -
1129#ifndef QDBUS_NO_SPECIALTYPES -
1130const QDBusArgument &operator>>(const QDBusArgument &a, QDate &date) -
1131{ -
1132 int y, m, d;
executed (the execution status of this line is deduced): int y, m, d;
-
1133 a.beginStructure();
executed (the execution status of this line is deduced): a.beginStructure();
-
1134 a >> y >> m >> d;
executed (the execution status of this line is deduced): a >> y >> m >> d;
-
1135 a.endStructure();
executed (the execution status of this line is deduced): a.endStructure();
-
1136 -
1137 if (y != 0 && m != 0 && d != 0)
evaluated: y != 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
partially evaluated: m != 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: d != 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1138 date.setDate(y, m, d);
executed: date.setDate(y, m, d);
Execution Count:2
2
1139 else -
1140 date = QDate();
executed: date = QDate();
Execution Count:2
2
1141 return a;
executed: return a;
Execution Count:4
4
1142} -
1143 -
1144QDBusArgument &operator<<(QDBusArgument &a, const QDate &date) -
1145{ -
1146 a.beginStructure();
executed (the execution status of this line is deduced): a.beginStructure();
-
1147 if (date.isValid())
evaluated: date.isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
2-5
1148 a << date.year() << date.month() << date.day();
executed: a << date.year() << date.month() << date.day();
Execution Count:2
2
1149 else -
1150 a << 0 << 0 << 0;
executed: a << 0 << 0 << 0;
Execution Count:5
5
1151 a.endStructure();
executed (the execution status of this line is deduced): a.endStructure();
-
1152 return a;
executed: return a;
Execution Count:7
7
1153} -
1154 -
1155const QDBusArgument &operator>>(const QDBusArgument &a, QTime &time) -
1156{ -
1157 int h, m, s, ms;
executed (the execution status of this line is deduced): int h, m, s, ms;
-
1158 a.beginStructure();
executed (the execution status of this line is deduced): a.beginStructure();
-
1159 a >> h >> m >> s >> ms;
executed (the execution status of this line is deduced): a >> h >> m >> s >> ms;
-
1160 a.endStructure();
executed (the execution status of this line is deduced): a.endStructure();
-
1161 -
1162 if (h < 0)
evaluated: h < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
1163 time = QTime();
executed: time = QTime();
Execution Count:2
2
1164 else -
1165 time.setHMS(h, m, s, ms);
executed: time.setHMS(h, m, s, ms);
Execution Count:2
2
1166 return a;
executed: return a;
Execution Count:4
4
1167} -
1168 -
1169QDBusArgument &operator<<(QDBusArgument &a, const QTime &time) -
1170{ -
1171 a.beginStructure();
executed (the execution status of this line is deduced): a.beginStructure();
-
1172 if (time.isValid())
evaluated: time.isValid()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5
2-5
1173 a << time.hour() << time.minute() << time.second() << time.msec();
executed: a << time.hour() << time.minute() << time.second() << time.msec();
Execution Count:2
2
1174 else -
1175 a << -1 << -1 << -1 << -1;
executed: a << -1 << -1 << -1 << -1;
Execution Count:5
5
1176 a.endStructure();
executed (the execution status of this line is deduced): a.endStructure();
-
1177 return a;
executed: return a;
Execution Count:7
7
1178} -
1179 -
1180const QDBusArgument &operator>>(const QDBusArgument &a, QDateTime &dt) -
1181{ -
1182 QDate date;
executed (the execution status of this line is deduced): QDate date;
-
1183 QTime time;
executed (the execution status of this line is deduced): QTime time;
-
1184 int timespec;
executed (the execution status of this line is deduced): int timespec;
-
1185 -
1186 a.beginStructure();
executed (the execution status of this line is deduced): a.beginStructure();
-
1187 a >> date >> time >> timespec;
executed (the execution status of this line is deduced): a >> date >> time >> timespec;
-
1188 a.endStructure();
executed (the execution status of this line is deduced): a.endStructure();
-
1189 -
1190 dt = QDateTime(date, time, Qt::TimeSpec(timespec));
executed (the execution status of this line is deduced): dt = QDateTime(date, time, Qt::TimeSpec(timespec));
-
1191 return a;
executed: return a;
Execution Count:4
4
1192} -
1193 -
1194QDBusArgument &operator<<(QDBusArgument &a, const QDateTime &dt) -
1195{ -
1196 a.beginStructure();
executed (the execution status of this line is deduced): a.beginStructure();
-
1197 a << dt.date() << dt.time() << int(dt.timeSpec());
executed (the execution status of this line is deduced): a << dt.date() << dt.time() << int(dt.timeSpec());
-
1198 a.endStructure();
executed (the execution status of this line is deduced): a.endStructure();
-
1199 return a;
executed: return a;
Execution Count:6
6
1200} -
1201 -
1202const QDBusArgument &operator>>(const QDBusArgument &a, QRect &rect) -
1203{ -
1204 int x, y, width, height;
never executed (the execution status of this line is deduced): int x, y, width, height;
-
1205 a.beginStructure();
never executed (the execution status of this line is deduced): a.beginStructure();
-
1206 a >> x >> y >> width >> height;
never executed (the execution status of this line is deduced): a >> x >> y >> width >> height;
-
1207 a.endStructure();
never executed (the execution status of this line is deduced): a.endStructure();
-
1208 -
1209 rect.setRect(x, y, width, height);
never executed (the execution status of this line is deduced): rect.setRect(x, y, width, height);
-
1210 return a;
never executed: return a;
0
1211} -
1212 -
1213QDBusArgument &operator<<(QDBusArgument &a, const QRect &rect) -
1214{ -
1215 a.beginStructure();
executed (the execution status of this line is deduced): a.beginStructure();
-
1216 a << rect.x() << rect.y() << rect.width() << rect.height();
executed (the execution status of this line is deduced): a << rect.x() << rect.y() << rect.width() << rect.height();
-
1217 a.endStructure();
executed (the execution status of this line is deduced): a.endStructure();
-
1218 -
1219 return a;
executed: return a;
Execution Count:1
1
1220} -
1221 -
1222const QDBusArgument &operator>>(const QDBusArgument &a, QRectF &rect) -
1223{ -
1224 double x, y, width, height;
never executed (the execution status of this line is deduced): double x, y, width, height;
-
1225 a.beginStructure();
never executed (the execution status of this line is deduced): a.beginStructure();
-
1226 a >> x >> y >> width >> height;
never executed (the execution status of this line is deduced): a >> x >> y >> width >> height;
-
1227 a.endStructure();
never executed (the execution status of this line is deduced): a.endStructure();
-
1228 -
1229 rect.setRect(qreal(x), qreal(y), qreal(width), qreal(height));
never executed (the execution status of this line is deduced): rect.setRect(qreal(x), qreal(y), qreal(width), qreal(height));
-
1230 return a;
never executed: return a;
0
1231} -
1232 -
1233QDBusArgument &operator<<(QDBusArgument &a, const QRectF &rect) -
1234{ -
1235 a.beginStructure();
executed (the execution status of this line is deduced): a.beginStructure();
-
1236 a << double(rect.x()) << double(rect.y()) << double(rect.width()) << double(rect.height());
executed (the execution status of this line is deduced): a << double(rect.x()) << double(rect.y()) << double(rect.width()) << double(rect.height());
-
1237 a.endStructure();
executed (the execution status of this line is deduced): a.endStructure();
-
1238 -
1239 return a;
executed: return a;
Execution Count:1
1
1240} -
1241 -
1242const QDBusArgument &operator>>(const QDBusArgument &a, QSize &size) -
1243{ -
1244 a.beginStructure();
never executed (the execution status of this line is deduced): a.beginStructure();
-
1245 a >> size.rwidth() >> size.rheight();
never executed (the execution status of this line is deduced): a >> size.rwidth() >> size.rheight();
-
1246 a.endStructure();
never executed (the execution status of this line is deduced): a.endStructure();
-
1247 -
1248 return a;
never executed: return a;
0
1249} -
1250 -
1251QDBusArgument &operator<<(QDBusArgument &a, const QSize &size) -
1252{ -
1253 a.beginStructure();
executed (the execution status of this line is deduced): a.beginStructure();
-
1254 a << size.width() << size.height();
executed (the execution status of this line is deduced): a << size.width() << size.height();
-
1255 a.endStructure();
executed (the execution status of this line is deduced): a.endStructure();
-
1256 -
1257 return a;
executed: return a;
Execution Count:1
1
1258} -
1259 -
1260const QDBusArgument &operator>>(const QDBusArgument &a, QSizeF &size) -
1261{ -
1262 double width, height;
never executed (the execution status of this line is deduced): double width, height;
-
1263 a.beginStructure();
never executed (the execution status of this line is deduced): a.beginStructure();
-
1264 a >> width >> height;
never executed (the execution status of this line is deduced): a >> width >> height;
-
1265 a.endStructure();
never executed (the execution status of this line is deduced): a.endStructure();
-
1266 -
1267 size.setWidth(qreal(width));
never executed (the execution status of this line is deduced): size.setWidth(qreal(width));
-
1268 size.setHeight(qreal(height));
never executed (the execution status of this line is deduced): size.setHeight(qreal(height));
-
1269 return a;
never executed: return a;
0
1270} -
1271 -
1272QDBusArgument &operator<<(QDBusArgument &a, const QSizeF &size) -
1273{ -
1274 a.beginStructure();
executed (the execution status of this line is deduced): a.beginStructure();
-
1275 a << double(size.width()) << double(size.height());
executed (the execution status of this line is deduced): a << double(size.width()) << double(size.height());
-
1276 a.endStructure();
executed (the execution status of this line is deduced): a.endStructure();
-
1277 -
1278 return a;
executed: return a;
Execution Count:1
1
1279} -
1280 -
1281const QDBusArgument &operator>>(const QDBusArgument &a, QPoint &pt) -
1282{ -
1283 a.beginStructure();
never executed (the execution status of this line is deduced): a.beginStructure();
-
1284 a >> pt.rx() >> pt.ry();
never executed (the execution status of this line is deduced): a >> pt.rx() >> pt.ry();
-
1285 a.endStructure();
never executed (the execution status of this line is deduced): a.endStructure();
-
1286 -
1287 return a;
never executed: return a;
0
1288} -
1289 -
1290QDBusArgument &operator<<(QDBusArgument &a, const QPoint &pt) -
1291{ -
1292 a.beginStructure();
executed (the execution status of this line is deduced): a.beginStructure();
-
1293 a << pt.x() << pt.y();
executed (the execution status of this line is deduced): a << pt.x() << pt.y();
-
1294 a.endStructure();
executed (the execution status of this line is deduced): a.endStructure();
-
1295 -
1296 return a;
executed: return a;
Execution Count:3
3
1297} -
1298 -
1299const QDBusArgument &operator>>(const QDBusArgument &a, QPointF &pt) -
1300{ -
1301 double x, y;
never executed (the execution status of this line is deduced): double x, y;
-
1302 a.beginStructure();
never executed (the execution status of this line is deduced): a.beginStructure();
-
1303 a >> x >> y;
never executed (the execution status of this line is deduced): a >> x >> y;
-
1304 a.endStructure();
never executed (the execution status of this line is deduced): a.endStructure();
-
1305 -
1306 pt.setX(qreal(x));
never executed (the execution status of this line is deduced): pt.setX(qreal(x));
-
1307 pt.setY(qreal(y));
never executed (the execution status of this line is deduced): pt.setY(qreal(y));
-
1308 return a;
never executed: return a;
0
1309} -
1310 -
1311QDBusArgument &operator<<(QDBusArgument &a, const QPointF &pt) -
1312{ -
1313 a.beginStructure();
executed (the execution status of this line is deduced): a.beginStructure();
-
1314 a << double(pt.x()) << double(pt.y());
executed (the execution status of this line is deduced): a << double(pt.x()) << double(pt.y());
-
1315 a.endStructure();
executed (the execution status of this line is deduced): a.endStructure();
-
1316 -
1317 return a;
executed: return a;
Execution Count:3
3
1318} -
1319 -
1320const QDBusArgument &operator>>(const QDBusArgument &a, QLine &line) -
1321{ -
1322 QPoint p1, p2;
never executed (the execution status of this line is deduced): QPoint p1, p2;
-
1323 a.beginStructure();
never executed (the execution status of this line is deduced): a.beginStructure();
-
1324 a >> p1 >> p2;
never executed (the execution status of this line is deduced): a >> p1 >> p2;
-
1325 a.endStructure();
never executed (the execution status of this line is deduced): a.endStructure();
-
1326 -
1327 line = QLine(p1, p2);
never executed (the execution status of this line is deduced): line = QLine(p1, p2);
-
1328 return a;
never executed: return a;
0
1329} -
1330 -
1331QDBusArgument &operator<<(QDBusArgument &a, const QLine &line) -
1332{ -
1333 a.beginStructure();
executed (the execution status of this line is deduced): a.beginStructure();
-
1334 a << line.p1() << line.p2();
executed (the execution status of this line is deduced): a << line.p1() << line.p2();
-
1335 a.endStructure();
executed (the execution status of this line is deduced): a.endStructure();
-
1336 -
1337 return a;
executed: return a;
Execution Count:1
1
1338} -
1339 -
1340const QDBusArgument &operator>>(const QDBusArgument &a, QLineF &line) -
1341{ -
1342 QPointF p1, p2;
never executed (the execution status of this line is deduced): QPointF p1, p2;
-
1343 a.beginStructure();
never executed (the execution status of this line is deduced): a.beginStructure();
-
1344 a >> p1 >> p2;
never executed (the execution status of this line is deduced): a >> p1 >> p2;
-
1345 a.endStructure();
never executed (the execution status of this line is deduced): a.endStructure();
-
1346 -
1347 line = QLineF(p1, p2);
never executed (the execution status of this line is deduced): line = QLineF(p1, p2);
-
1348 return a;
never executed: return a;
0
1349} -
1350 -
1351QDBusArgument &operator<<(QDBusArgument &a, const QLineF &line) -
1352{ -
1353 a.beginStructure();
executed (the execution status of this line is deduced): a.beginStructure();
-
1354 a << line.p1() << line.p2();
executed (the execution status of this line is deduced): a << line.p1() << line.p2();
-
1355 a.endStructure();
executed (the execution status of this line is deduced): a.endStructure();
-
1356 -
1357 return a;
executed: return a;
Execution Count:1
1
1358} -
1359#endif -
1360 -
1361QT_END_NAMESPACE -
1362 -
1363#endif // QT_NO_DBUS -
1364 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial