Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qdbusreply.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 reason:default
4
5
#
ifndef
QDBUSREPLY_H
6
#
define
QDBUSREPLY_H
7
8
#
include
<
QtDBus
/
qtdbusglobal
.
h
>
9
#
include
<
QtCore
/
qvariant
.
h
>
10
11
#
include
<
QtDBus
/
qdbusmessage
.
h
>
12
#
include
<
QtDBus
/
qdbuserror
.
h
>
13
#
include
<
QtDBus
/
qdbusextratypes
.
h
>
14
#
include
<
QtDBus
/
qdbuspendingreply
.
h
>
15
16
#
ifndef
QT_NO_DBUS
17
18
QT_BEGIN_NAMESPACE
19
20
21
Q_DBUS_EXPORT
void
qDBusReplyFill
(
const
QDBusMessage &reply, QDBusError &error, QVariant &data);
22
23
template
<
typename
T>
24
class
QDBusReply
25
{
26
typedef
T Type;
27
public
:
28
// Rule Of Zero applies!
29
30
inline
QDBusReply
(
const
QDBusMessage &reply)
31
{
32
*
this
= reply;
33
}
34
inline
QDBusReply
&
operator
=(
const
QDBusMessage &reply)
35
{
36
QVariant data(QMetaType::fromType<Type>());
37
qDBusReplyFill(reply, m_error, data);
38
m_data = qvariant_cast<Type>(data);
39
return
*
this
;
40
}
41
42
inline
QDBusReply
(
const
QDBusPendingCall &pcall)
43
{
44
*
this
= pcall;
45
}
46
inline
QDBusReply
&
operator
=(
const
QDBusPendingCall &pcall)
47
{
48
QDBusPendingCall other(pcall);
49
other.waitForFinished();
50
return
*
this
= other.reply();
51
}
52
inline
QDBusReply
(
const
QDBusPendingReply<T> &reply)
53
{
54
*
this
=
static_cast
<QDBusPendingCall>(reply);
55
}
56
57
inline
QDBusReply
(
const
QDBusError &dbusError = QDBusError())
58
:
m_error
(
dbusError
), m_data(Type())
59
{
60
}
61
inline
QDBusReply
&
operator
=(
const
QDBusError& dbusError)
62
{
63
m_error = dbusError;
64
m_data = Type();
65
return
*
this
;
66
}
67
68
inline
bool
isValid
()
const
{
return
!m_error.isValid(); }
69
70
inline
const
QDBusError
&
error
()
const
{
return
m_error; }
71
72
inline
Type
value
()
const
73
{
74
return
m_data;
75
}
76
77
inline
operator
Type ()
const
78
{
79
return
m_data;
80
}
81
82
private
:
83
QDBusError m_error;
84
Type m_data;
85
};
86
87
#
ifndef
Q_QDOC
88
// specialize for QVariant:
89
template
<>
inline
QDBusReply<QVariant>&
90
QDBusReply<QVariant>::operator=(
const
QDBusMessage &reply)
91
{
92
QVariant data(QMetaType::fromType<QDBusVariant>());
93
qDBusReplyFill(reply, m_error, data);
94
m_data = qvariant_cast<QDBusVariant>(data).variant();
95
return
*
this
;
96
}
97
98
// specialize for void:
99
template
<>
100
class
QDBusReply
<
void
>
101
{
102
public
:
103
// Rule Of Zero applies!
104
105
inline
QDBusReply
(
const
QDBusMessage &reply)
106
:
m_error
(
reply
)
107
{
108
}
109
inline
QDBusReply
&
operator
=(
const
QDBusMessage &reply)
110
{
111
m_error = QDBusError(reply);
112
return
*
this
;
113
}
114
inline
QDBusReply
(
const
QDBusError &dbusError = QDBusError())
115
:
m_error
(
dbusError
)
116
{
117
}
118
inline
QDBusReply
(
const
QDBusPendingCall &pcall)
119
{
120
*
this
= pcall;
121
}
122
inline
QDBusReply
&
operator
=(
const
QDBusPendingCall &pcall)
123
{
124
QDBusPendingCall other(pcall);
125
other.waitForFinished();
126
return
*
this
= other.reply();
127
}
128
inline
QDBusReply
&
operator
=(
const
QDBusError& dbusError)
129
{
130
m_error = dbusError;
131
return
*
this
;
132
}
133
134
inline
bool
isValid
()
const
{
return
!m_error.isValid(); }
135
136
inline
const
QDBusError
&
error
()
const
{
return
m_error; }
137
138
private
:
139
QDBusError m_error;
140
};
141
#
endif
142
143
QT_END_NAMESPACE
144
145
#
endif
// QT_NO_DBUS
146
#
endif
QDBusArgument
\inmodule QtDBus
Definition
qdbusargument.h:32
QDBusReply< void >
Definition
qdbusreply.h:101
QDBusReply< void >::error
const QDBusError & error() const
Definition
qdbusreply.h:136
QDBusReply< void >::QDBusReply
QDBusReply(const QDBusMessage &reply)
Definition
qdbusreply.h:105
QDBusReply< void >::operator=
QDBusReply & operator=(const QDBusMessage &reply)
Definition
qdbusreply.h:109
QDBusReply< void >::isValid
bool isValid() const
Definition
qdbusreply.h:134
QDBusReply
\inmodule QtDBus
Definition
qdbusreply.h:25
QDBusReply::QDBusReply
QDBusReply(const QDBusMessage &reply)
Automatically construct a QDBusReply object from the reply message reply, extracting the first return...
Definition
qdbusreply.h:30
QDBusReply::isValid
bool isValid() const
Returns true if no error occurred; otherwise, returns false.
Definition
qdbusreply.h:68
QDBusReply::error
const QDBusError & error() const
Returns the error code that was returned from the remote function call.
Definition
qdbusreply.h:70
QDBusReply::operator Type
operator Type() const
Returns the same as value().
Definition
qdbusreply.h:77
QDBusReply::operator=
QDBusReply & operator=(const QDBusMessage &reply)
Makes this object contain the reply message.
Definition
qdbusreply.h:34
QDBusReply::value
Type value() const
Returns the remote function's calls return value.
Definition
qdbusreply.h:72
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qDBusReplyFill
void qDBusReplyFill(const QDBusMessage &reply, QDBusError &error, QVariant &data)
Definition
qdbusreply.cpp:148
qDBusReplyFill
QT_BEGIN_NAMESPACE Q_DBUS_EXPORT void qDBusReplyFill(const QDBusMessage &reply, QDBusError &error, QVariant &data)
Definition
qdbusreply.cpp:148
qtbase
src
dbus
qdbusreply.h
Generated on
for Qt by
1.18.0