Qt 4.8
Classes | Functions
qvariant_p.h File Reference
#include <QtCore/qglobal.h>
#include <QtCore/qvariant.h>

Go to the source code of this file.

Classes

class  QVariantPrivateSharedEx< T >
 

Functions

Q_CORE_EXPORT const QVariant::Handler * qcoreVariantHandler ()
 
template<typename T >
const T * v_cast (const QVariant::Private *d, T *=0)
 
template<typename T >
T * v_cast (QVariant::Private *d, T *=0)
 
template<class T >
void v_clear (QVariant::Private *d, T *=0)
 
template<class T >
void v_construct (QVariant::Private *x, const void *copy, T *=0)
 
template<class T >
void v_construct (QVariant::Private *x, const T &t)
 

Function Documentation

◆ qcoreVariantHandler()

Q_CORE_EXPORT const QVariant::Handler* qcoreVariantHandler ( )

Definition at line 1193 of file qvariant.cpp.

Referenced by v_clear().

1194 {
1195  return &qt_kernel_variant_handler;
1196 }
const QVariant::Handler qt_kernel_variant_handler
Definition: qvariant.cpp:1175

◆ v_cast() [1/2]

template<typename T >
const T* v_cast ( const QVariant::Private *  d,
T *  = 0 
)
inline

Definition at line 78 of file qvariant_p.h.

Referenced by QVariant::canConvert(), compare(), convert(), isNull(), qConvertToNumber(), qConvertToUnsignedNumber(), qt_convertToBool(), qVariantToHelper(), and v_clear().

79 {
80  return ((sizeof(T) > sizeof(QVariant::Private::Data))
81  ? static_cast<const T *>(d->data.shared->ptr)
82  : static_cast<const T *>(static_cast<const void *>(&d->data.c)));
83 }
double d
Definition: qnumeric_p.h:62

◆ v_cast() [2/2]

template<typename T >
T* v_cast ( QVariant::Private *  d,
T *  = 0 
)
inline

Definition at line 86 of file qvariant_p.h.

87 {
88  return ((sizeof(T) > sizeof(QVariant::Private::Data))
89  ? static_cast<T *>(d->data.shared->ptr)
90  : static_cast<T *>(static_cast<void *>(&d->data.c)));
91 }
double d
Definition: qnumeric_p.h:62

◆ v_clear()

template<class T >
void v_clear ( QVariant::Private *  d,
T *  = 0 
)
inline

Definition at line 136 of file qvariant_p.h.

137 {
138 
139  if (sizeof(T) > sizeof(QVariant::Private::Data)) {
140  //now we need to cast
141  //because QVariant::PrivateShared doesn't have a virtual destructor
142  delete static_cast<QVariantPrivateSharedEx<T>*>(d->data.shared);
143  } else {
144  v_cast<T>(d)->~T();
145  }
146 
147 }
double d
Definition: qnumeric_p.h:62
const T * v_cast(const QVariant::Private *d, T *=0)
Definition: qvariant_p.h:78

◆ v_construct() [1/2]

template<class T >
void v_construct ( QVariant::Private *  x,
const void *  copy,
T *  = 0 
)
inline

Definition at line 109 of file qvariant_p.h.

110 {
111  if (sizeof(T) > sizeof(QVariant::Private::Data)) {
112  x->data.shared = copy ? new QVariantPrivateSharedEx<T>(*static_cast<const T *>(copy))
113  : new QVariantPrivateSharedEx<T>;
114  x->is_shared = true;
115  } else {
116  if (copy)
117  new (&x->data.ptr) T(*static_cast<const T *>(copy));
118  else
119  new (&x->data.ptr) T;
120  }
121 }

◆ v_construct() [2/2]

template<class T >
void v_construct ( QVariant::Private *  x,
const T &  t 
)
inline

Definition at line 124 of file qvariant_p.h.

125 {
126  if (sizeof(T) > sizeof(QVariant::Private::Data)) {
127  x->data.shared = new QVariantPrivateSharedEx<T>(t);
128  x->is_shared = true;
129  } else {
130  new (&x->data.ptr) T(t);
131  }
132 }