5#ifndef QDBUSPENDINGREPLY_H
6#define QDBUSPENDINGREPLY_H
8#include <QtDBus/qtdbusglobal.h>
9#include <QtDBus/qdbusargument.h>
10#include <QtDBus/qdbuspendingcall.h>
14class tst_QDBusPendingReply;
22 QDBusPendingReplyBase();
23#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
24 ~QDBusPendingReplyBase();
25 QDBusPendingReplyBase(
const QDBusPendingReplyBase &) =
default;
26 QDBusPendingReplyBase &operator=(
const QDBusPendingReplyBase &) =
default;
27 QDBusPendingReplyBase(QDBusPendingReplyBase &&)
noexcept =
default;
28 QDBusPendingReplyBase &operator=(QDBusPendingReplyBase &&)
noexcept =
default;
31 void assign(
const QDBusPendingCall &call);
32 void assign(
const QDBusMessage &message);
34 QVariant argumentAt(
int index)
const;
35 void setMetaTypes(
int count,
const QMetaType *metaTypes);
39 template<
int Index,
typename T,
typename... Types>
45 template<
typename T,
typename... Types>
52 {
return QMetaType::fromType<T>(); }
59template<
typename... Types>
62 friend class ::tst_QDBusPendingReply;
65 enum {
Count = std::is_same_v<
typename Select<0>::Type,
void> ? 0 :
sizeof...(Types) };
78 { assign(call);
return *
this; }
80 { assign(message);
return *
this; }
83 template<
int Index>
inline
86 static_assert(Index >= 0 && Index <
Count,
"Index out of bounds");
87 typedef typename Select<Index>::Type ResultType;
88 return qdbus_cast<ResultType>(argumentAt(Index));
104 return argumentAt<0>();
116 if constexpr (
Count == 0) {
140 friend class ::tst_QDBusPendingReply;
154 { assign(call);
return *
this; }
156 { assign(message);
return *
this; }
159 inline void assign(
const QDBusPendingCall &call)
161 QDBusPendingReplyBase::assign(call);
163 setMetaTypes(0,
nullptr);
166 inline void assign(
const QDBusMessage &message)
168 QDBusPendingReplyBase::assign(message);
170 setMetaTypes(0,
nullptr);
QDBusPendingReply()=default
QDBusPendingReply & operator=(const QDBusPendingCall &call)
Select< Index >::Type argumentAt() const
Returns the argument at position index in the reply's contents.
constexpr int count() const
Return the number of arguments the reply is supposed to have.
QDBusPendingReply()=default
Creates an empty QDBusPendingReply object.
Select< 0 >::Type value() const
Returns the first argument in this reply, cast to type Types[0] (the first template parameter of this...
QDBusPendingReply & operator=(const QDBusPendingCall &call)
Makes this object take its contents from the call pending call and drops the reference to the current...
Select< Index - 1, Types... > Next