Qt 4.8
Functions
qdbusdemarshaller.cpp File Reference
#include "qdbusargument_p.h"
#include "qdbusconnection.h"
#include <stdlib.h>

Go to the source code of this file.

Functions

template<typename T >
static T qIterGet (DBusMessageIter *it)
 

Function Documentation

◆ qIterGet()

template<typename T >
static T qIterGet ( DBusMessageIter *  it)
inlinestatic

Definition at line 49 of file qdbusdemarshaller.cpp.

50 {
51  // Use a union of expected and largest type q_dbus_message_iter_get_basic
52  // will return to ensure reading the wrong basic type does not result in
53  // stack overwrite
54  union {
55  // The value to be extracted
56  T t;
57  // Largest type that q_dbus_message_iter_get_basic will return
58  // according to dbus_message_iter_get_basic API documentation
59  dbus_uint64_t maxValue;
60  // A pointer to ensure no stack overwrite in case there is a platform
61  // where sizeof(void*) > sizeof(dbus_uint64_t)
62  void* ptr;
63  } value;
64 
65  // Initialize the value in case a narrower type is extracted to it.
66  // Note that the result of extracting a narrower type in place of a wider
67  // one and vice-versa will be platform-dependent.
68  value.t = T();
69 
70  q_dbus_message_iter_get_basic(it, &value);
71  q_dbus_message_iter_next(it);
72  return value.t;
73 }
#define it(className, varName)
const T * ptr(const T &t)