Qt 4.8
Functions
qdbusinterface.cpp File Reference
#include "qdbusinterface.h"
#include "qdbus_symbols_p.h"
#include <QtCore/qpointer.h>
#include <QtCore/qstringlist.h>
#include "qdbusmetatype_p.h"
#include "qdbusinterface_p.h"
#include "qdbusconnection_p.h"

Go to the source code of this file.

Functions

static void copyArgument (void *to, int id, const QVariant &arg)
 

Function Documentation

◆ copyArgument()

static void copyArgument ( void *  to,
int  id,
const QVariant arg 
)
static

Definition at line 56 of file qdbusinterface.cpp.

Referenced by QDBusInterfacePrivate::metacall().

57 {
58  if (id == arg.userType()) {
59  switch (id) {
60  case QVariant::Bool:
61  *reinterpret_cast<bool *>(to) = arg.toBool();
62  return;
63 
64  case QMetaType::UChar:
65  *reinterpret_cast<uchar *>(to) = arg.value<uchar>();
66  return;
67 
68  case QMetaType::Short:
69  *reinterpret_cast<short *>(to) = arg.value<short>();
70  return;
71 
72  case QMetaType::UShort:
73  *reinterpret_cast<ushort *>(to) = arg.value<ushort>();
74  return;
75 
76  case QVariant::Int:
77  *reinterpret_cast<int *>(to) = arg.toInt();
78  return;
79 
80  case QVariant::UInt:
81  *reinterpret_cast<uint *>(to) = arg.toUInt();
82  return;
83 
84  case QVariant::LongLong:
85  *reinterpret_cast<qlonglong *>(to) = arg.toLongLong();
86  return;
87 
89  *reinterpret_cast<qulonglong *>(to) = arg.toULongLong();
90  return;
91 
92  case QVariant::Double:
93  *reinterpret_cast<double *>(to) = arg.toDouble();
94  return;
95 
96  case QVariant::String:
97  *reinterpret_cast<QString *>(to) = arg.toString();
98  return;
99 
100  case QVariant::ByteArray:
101  *reinterpret_cast<QByteArray *>(to) = arg.toByteArray();
102  return;
103 
105  *reinterpret_cast<QStringList *>(to) = arg.toStringList();
106  return;
107  }
108 
109  if (id == QDBusMetaTypeId::variant) {
110  *reinterpret_cast<QDBusVariant *>(to) = arg.value<QDBusVariant>();
111  return;
112  } else if (id == QDBusMetaTypeId::objectpath) {
113  *reinterpret_cast<QDBusObjectPath *>(to) = arg.value<QDBusObjectPath>();
114  return;
115  } else if (id == QDBusMetaTypeId::signature) {
116  *reinterpret_cast<QDBusSignature *>(to) = arg.value<QDBusSignature>();
117  return;
118  }
119 
120  // those above are the only types possible
121  // the demarshaller code doesn't demarshall anything else
122  qFatal("Found a decoded basic type in a D-Bus reply that shouldn't be there");
123  }
124 
125  // if we got here, it's either an un-dermarshalled type or a mismatch
126  if (arg.userType() != QDBusMetaTypeId::argument) {
127  // it's a mismatch
128  //qWarning?
129  return;
130  }
131 
132  // is this type registered?
133  const char *userSignature = QDBusMetaType::typeToSignature(id);
134  if (!userSignature || !*userSignature) {
135  // type not registered
136  //qWarning?
137  return;
138  }
139 
140  // is it the same signature?
141  QDBusArgument dbarg = arg.value<QDBusArgument>();
142  if (dbarg.currentSignature() != QLatin1String(userSignature)) {
143  // not the same signature, another mismatch
144  //qWarning?
145  return;
146  }
147 
148  // we can demarshall
149  QDBusMetaType::demarshall(dbarg, id, to);
150 }
The QDBusArgument class is used to marshall and demarshall D-Bus arguments.
Definition: qdbusargument.h:69
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
QString currentSignature() const
Returns the type signature of the D-Bus type this QDBusArgument object is currently pointing to...
The QDBusSignature class enables the programmer to identify the SIGNATURE type provided by the D-Bus ...
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
Definition: qvariant.cpp:2691
static int variant
static int objectpath
The QString class provides a Unicode character string.
Definition: qstring.h:83
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
Definition: qvariant.cpp:2383
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
static const char * typeToSignature(int type)
Returns the D-Bus signature equivalent to the supplied meta type id type.
unsigned char uchar
Definition: qglobal.h:994
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
Definition: qvariant.cpp:2259
qlonglong toLongLong(bool *ok=0) const
Returns the variant as a long long int if the variant has type() LongLong , Bool , ByteArray , Char , Double , Int , String , UInt , or ULongLong ; otherwise returns 0.
Definition: qvariant.cpp:2659
static bool demarshall(const QDBusArgument &, int id, void *data)
Executes the demarshalling of type id (whose data will be placed in data) from the D-Bus marshalling ...
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
qulonglong toULongLong(bool *ok=0) const
Returns the variant as as an unsigned long long int if the variant has type() ULongLong ...
Definition: qvariant.cpp:2675
unsigned int uint
Definition: qglobal.h:996
Q_CORE_EXPORT void qFatal(const char *,...)
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
unsigned short ushort
Definition: qglobal.h:995
uint toUInt(bool *ok=0) const
Returns the variant as an unsigned int if the variant has type() UInt , Bool , ByteArray ...
Definition: qvariant.cpp:2644
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
Definition: qvariant.cpp:2710
static int signature
quint64 qulonglong
Definition: qglobal.h:952
T value() const
Returns the stored value converted to the template type T.
Definition: qvariant.h:332
static int argument
qint64 qlonglong
Definition: qglobal.h:951
The QDBusVariant class enables the programmer to identify the variant type provided by the D-Bus type...