Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QDBusReply< T > Class Template Reference

\inmodule QtDBus More...

#include <qdbusreply.h>

+ Collaboration diagram for QDBusReply< T >:

Public Member Functions

 QDBusReply (const QDBusMessage &reply)
 Automatically construct a QDBusReply object from the reply message reply, extracting the first return value from it if it is a success reply.
 
 QDBusReply (const QDBusReply &)=default
 
QDBusReplyoperator= (const QDBusMessage &reply)
 Makes this object contain the reply message.
 
 QDBusReply (const QDBusPendingCall &pcall)
 Automatically construct a QDBusReply object from the asynchronous pending call pcall.
 
QDBusReplyoperator= (const QDBusPendingCall &pcall)
 Makes this object contain the reply specified by the pending asynchronous call pcall.
 
 QDBusReply (const QDBusPendingReply< T > &reply)
 Constructs a QDBusReply object from the pending reply message, reply.
 
 QDBusReply (const QDBusError &dbusError=QDBusError())
 Constructs an error reply from the D-Bus error code given by error.
 
QDBusReplyoperator= (const QDBusError &dbusError)
 Sets this object to contain the error code given by dbusError.
 
QDBusReplyoperator= (const QDBusReply &other)
 Makes this object be a copy of the object other.
 
bool isValid () const
 Returns true if no error occurred; otherwise, returns false.
 
const QDBusErrorerror ()
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const QDBusErrorerror () const
 Returns the error code that was returned from the remote function call.
 
Type value () const
 Returns the remote function's calls return value.
 
 operator Type () const
 Returns the same as value().
 
QDBusReply< QVariant > & operator= (const QDBusMessage &reply)
 

Detailed Description

template<typename T>
class QDBusReply< T >

\inmodule QtDBus

Since
4.2

The QDBusReply class stores the reply for a method call to a remote object.

A QDBusReply object is a subset of the QDBusMessage object that represents a method call's reply. It contains only the first output argument or the error code and is used by QDBusInterface-derived classes to allow returning the error code as the function's return argument.

It can be used in the following manner:

QDBusReply<QString> reply = interface->call("RemoteMethod");
if (reply.isValid())
// use the returned value
useValue(reply.value());
else
// call failed. Show an error condition.

If the remote method call cannot fail, you can skip the error checking:

However, if it does fail under those conditions, the value returned by QDBusReply<T>::value() is a default-constructed value. It may be indistinguishable from a valid return value.

QDBusReply objects are used for remote calls that have no output arguments or return values (i.e., they have a "void" return type). Use the isValid() function to test if the reply succeeded.

See also
QDBusMessage, QDBusInterface

Definition at line 23 of file qdbusreply.h.

Constructor & Destructor Documentation

◆ QDBusReply() [1/5]

template<typename T >
template< typename T > QDBusReply< T >::QDBusReply ( const QDBusMessage & reply)
inline

Automatically construct a QDBusReply object from the reply message reply, extracting the first return value from it if it is a success reply.

Definition at line 27 of file qdbusreply.h.

References reply.

◆ QDBusReply() [2/5]

template<typename T >
template< typename T > QDBusReply< T >::QDBusReply ( const QDBusReply< T > & other)
inlinedefault
Since
5.15

Constructs a copy of other.

◆ QDBusReply() [3/5]

template<typename T >
template< typename T > QDBusReply< T >::QDBusReply ( const QDBusPendingCall & pcall)
inline

Automatically construct a QDBusReply object from the asynchronous pending call pcall.

If the call isn't finished yet, QDBusReply will call QDBusPendingCall::waitForFinished(), which is a blocking operation.

If the return types patch, QDBusReply will extract the first return argument from the reply.

Definition at line 40 of file qdbusreply.h.

◆ QDBusReply() [4/5]

template<typename T >
template< typename T > QDBusReply< T >::QDBusReply ( const QDBusPendingReply< T > & reply)
inline

Constructs a QDBusReply object from the pending reply message, reply.

Definition at line 50 of file qdbusreply.h.

References reply.

◆ QDBusReply() [5/5]

template<typename T >
template< typename T > QDBusReply< T >::QDBusReply ( const QDBusError & dbusError = QDBusError())
inline

Constructs an error reply from the D-Bus error code given by error.

Definition at line 55 of file qdbusreply.h.

Member Function Documentation

◆ error() [1/2]

template<typename T >
template< typename T > const QDBusError & QDBusReply< T >::error ( )
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 75 of file qdbusreply.h.

◆ error() [2/2]

template<typename T >
template< typename T > const QDBusError & QDBusReply< T >::error ( ) const
inline

Returns the error code that was returned from the remote function call.

If the remote call did not return an error (i.e., if it succeeded), then the QDBusError object that is returned will not be a valid error code (QDBusError::isValid() will return false).

See also
isValid()

Definition at line 76 of file qdbusreply.h.

◆ isValid()

template<typename T >
template< typename T > bool QDBusReply< T >::isValid ( ) const
inline

Returns true if no error occurred; otherwise, returns false.

See also
error()

Definition at line 73 of file qdbusreply.h.

References QDBusError::isValid().

+ Here is the call graph for this function:

◆ operator Type()

template<typename T >
template< typename T > QDBusReply< T >::operator Type ( ) const
inline

Returns the same as value().

This function is not available if the remote call returns void.

Definition at line 83 of file qdbusreply.h.

◆ operator=() [1/5]

template<typename T >
template< typename T > QDBusReply< T >::operator= ( const QDBusError & dbusError)
inline

Sets this object to contain the error code given by dbusError.

You can later access it with error().

Definition at line 59 of file qdbusreply.h.

◆ operator=() [2/5]

template<typename T >
template< typename T > QDBusReply< T >::operator= ( const QDBusMessage & reply)
inline

Makes this object contain the reply message.

If reply is an error message, this function will copy the error code and message into this object

If reply is a standard reply message and contains at least one parameter, it will be copied into this object, as long as it is of the correct type. If it's not of the same type as this QDBusError object, this function will instead set an error code indicating a type mismatch.

Definition at line 32 of file qdbusreply.h.

References qDBusReplyFill(), and reply.

+ Here is the call graph for this function:

◆ operator=() [3/5]

QDBusReply< QVariant > & QDBusReply< QVariant >::operator= ( const QDBusMessage & reply)
inline

Definition at line 96 of file qdbusreply.h.

References m_data, qDBusReplyFill(), and reply.

+ Here is the call graph for this function:

◆ operator=() [4/5]

template<typename T >
template< typename T > QDBusReply< T >::operator= ( const QDBusPendingCall & pcall)
inline

Makes this object contain the reply specified by the pending asynchronous call pcall.

If the call is not finished yet, this function will call QDBusPendingCall::waitForFinished() to block until the reply arrives.

If pcall finishes with an error message, this function will copy the error code and message into this object

If pcall finished with a standard reply message and contains at least one parameter, it will be copied into this object, as long as it is of the correct type. If it's not of the same type as this QDBusError object, this function will instead set an error code indicating a type mismatch.

Definition at line 44 of file qdbusreply.h.

References other().

+ Here is the call graph for this function:

◆ operator=() [5/5]

template<typename T >
template< typename T > QDBusReply< T >::operator= ( const QDBusReply< T > & other)
inline

Makes this object be a copy of the object other.

Definition at line 66 of file qdbusreply.h.

References other().

+ Here is the call graph for this function:

◆ value()

template<typename T >
template< typename T > Type QDBusReply< T >::value ( ) const
inline

Returns the remote function's calls return value.

If the remote call returned with an error, the return value of this function is undefined and may be undistinguishable from a valid return value.

This function is not available if the remote call returns void.

Definition at line 78 of file qdbusreply.h.


The documentation for this class was generated from the following files: