Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QDeclarativeVMEVariant Class Reference

Public Functions

bool asBool ()
 
double asDouble ()
 
int asInt ()
 
const QColorasQColor ()
 
const QDateasQDate ()
 
const QDateTimeasQDateTime ()
 
QObjectasQObject ()
 
const QScriptValueasQScriptValue ()
 
const QStringasQString ()
 
const QTimeasQTime ()
 
const QUrlasQUrl ()
 
const QVariantasQVariant ()
 
const void * dataPtr () const
 
void * dataPtr ()
 
int dataType () const
 
 QDeclarativeVMEVariant ()
 
void setValue (QObject *)
 
void setValue (const QVariant &)
 
void setValue (int)
 
void setValue (bool)
 
void setValue (double)
 
void setValue (const QString &)
 
void setValue (const QUrl &)
 
void setValue (const QColor &)
 
void setValue (const QTime &)
 
void setValue (const QDate &)
 
void setValue (const QDateTime &)
 
void setValue (const QScriptValue &)
 
 ~QDeclarativeVMEVariant ()
 

Private Functions

void cleanup ()
 

Properties

void * data [4]
 
int type
 

Detailed Description

Definition at line 55 of file qdeclarativevmemetaobject.cpp.

Constructors and Destructors

◆ QDeclarativeVMEVariant()

QDeclarativeVMEVariant::QDeclarativeVMEVariant ( )
inline

◆ ~QDeclarativeVMEVariant()

QDeclarativeVMEVariant::~QDeclarativeVMEVariant ( )
inline

Definition at line 102 of file qdeclarativevmemetaobject.cpp.

103 {
104  cleanup();
105 }

Functions

◆ asBool()

bool QDeclarativeVMEVariant::asBool ( )
inline

Definition at line 184 of file qdeclarativevmemetaobject.cpp.

185 {
186  if (type != QMetaType::Bool)
187  setValue(bool(false));
188 
189  return *(bool *)(dataPtr());
190 }

◆ asDouble()

double QDeclarativeVMEVariant::asDouble ( )
inline

Definition at line 192 of file qdeclarativevmemetaobject.cpp.

193 {
194  if (type != QMetaType::Double)
195  setValue(double(0));
196 
197  return *(double *)(dataPtr());
198 }

◆ asInt()

int QDeclarativeVMEVariant::asInt ( )
inline

Definition at line 176 of file qdeclarativevmemetaobject.cpp.

Referenced by QDeclarativeVMEMetaObject::metaCall().

177 {
178  if (type != QMetaType::Int)
179  setValue(int(0));
180 
181  return *(int *)(dataPtr());
182 }

◆ asQColor()

const QColor & QDeclarativeVMEVariant::asQColor ( )
inline

Definition at line 216 of file qdeclarativevmemetaobject.cpp.

217 {
218  if (type != QMetaType::QColor)
219  setValue(QColor());
220 
221  return *(QColor *)(dataPtr());
222 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67

◆ asQDate()

const QDate & QDeclarativeVMEVariant::asQDate ( )
inline

Definition at line 232 of file qdeclarativevmemetaobject.cpp.

233 {
234  if (type != QMetaType::QDate)
235  setValue(QDate());
236 
237  return *(QDate *)(dataPtr());
238 }
The QDate class provides date functions.
Definition: qdatetime.h:55

◆ asQDateTime()

const QDateTime & QDeclarativeVMEVariant::asQDateTime ( )
inline

Definition at line 240 of file qdeclarativevmemetaobject.cpp.

241 {
242  if (type != QMetaType::QDateTime)
243  setValue(QDateTime());
244 
245  return *(QDateTime *)(dataPtr());
246 }
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216

◆ asQObject()

QObject * QDeclarativeVMEVariant::asQObject ( )
inline

Definition at line 160 of file qdeclarativevmemetaobject.cpp.

Referenced by QDeclarativeVMEMetaObject::writeVarProperty().

161 {
163  setValue((QObject *)0);
164 
165  return *(QDeclarativeGuard<QObject> *)(dataPtr());
166 }
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111

◆ asQScriptValue()

const QScriptValue & QDeclarativeVMEVariant::asQScriptValue ( )
inline

Definition at line 248 of file qdeclarativevmemetaobject.cpp.

Referenced by QDeclarativeVMEMetaObject::readVarProperty().

249 {
250  if (type != qMetaTypeId<QScriptValue>())
252 
253  return *(QScriptValue *)(dataPtr());
254 }
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

◆ asQString()

const QString & QDeclarativeVMEVariant::asQString ( )
inline

Definition at line 200 of file qdeclarativevmemetaobject.cpp.

201 {
202  if (type != QMetaType::QString)
203  setValue(QString());
204 
205  return *(QString *)(dataPtr());
206 }
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ asQTime()

const QTime & QDeclarativeVMEVariant::asQTime ( )
inline

Definition at line 224 of file qdeclarativevmemetaobject.cpp.

225 {
226  if (type != QMetaType::QTime)
227  setValue(QTime());
228 
229  return *(QTime *)(dataPtr());
230 }
The QTime class provides clock time functions.
Definition: qdatetime.h:148

◆ asQUrl()

const QUrl & QDeclarativeVMEVariant::asQUrl ( )
inline

Definition at line 208 of file qdeclarativevmemetaobject.cpp.

209 {
210  if (type != QMetaType::QUrl)
211  setValue(QUrl());
212 
213  return *(QUrl *)(dataPtr());
214 }
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61

◆ asQVariant()

const QVariant & QDeclarativeVMEVariant::asQVariant ( )
inline

Definition at line 168 of file qdeclarativevmemetaobject.cpp.

Referenced by QDeclarativeVMEMetaObject::readVarPropertyAsVariant(), and QDeclarativeVMEMetaObject::writeVarProperty().

169 {
170  if (type != QMetaType::QVariant)
171  setValue(QVariant());
172 
173  return *(QVariant *)(dataPtr());
174 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92

◆ cleanup()

void QDeclarativeVMEVariant::cleanup ( )
inlineprivate

Definition at line 107 of file qdeclarativevmemetaobject.cpp.

Referenced by setValue(), and ~QDeclarativeVMEVariant().

108 {
109  if (type == QVariant::Invalid) {
110  } else if (type == QMetaType::Int ||
111  type == QMetaType::Bool ||
112  type == QMetaType::Double) {
114  } else if (type == QMetaType::QObjectStar) {
117  } else if (type == QMetaType::QString) {
118  ((QString *)dataPtr())->~QString();
120  } else if (type == QMetaType::QUrl) {
121  ((QUrl *)dataPtr())->~QUrl();
123  } else if (type == QMetaType::QColor) {
124  ((QColor *)dataPtr())->~QColor();
126  } else if (type == QMetaType::QTime) {
127  ((QTime *)dataPtr())->~QTime();
129  } else if (type == QMetaType::QDate) {
130  ((QDate *)dataPtr())->~QDate();
132  } else if (type == QMetaType::QDateTime) {
133  ((QDateTime *)dataPtr())->~QDateTime();
135  } else if (type == qMetaTypeId<QVariant>()) {
136  ((QVariant *)dataPtr())->~QVariant();
138  } else if (type == qMetaTypeId<QScriptValue>()) {
139  ((QScriptValue *)dataPtr())->~QScriptValue();
141  }
142 
143 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
The QDate class provides date functions.
Definition: qdatetime.h:55
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QTime class provides clock time functions.
Definition: qdatetime.h:148
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

◆ dataPtr() [1/2]

const void * QDeclarativeVMEVariant::dataPtr ( ) const
inline

◆ dataPtr() [2/2]

void * QDeclarativeVMEVariant::dataPtr ( )
inline

Definition at line 155 of file qdeclarativevmemetaobject.cpp.

156 {
157  return &data;
158 }

◆ dataType()

int QDeclarativeVMEVariant::dataType ( ) const
inline

Definition at line 145 of file qdeclarativevmemetaobject.cpp.

Referenced by QDeclarativeVMEMetaObject::writeVarProperty().

146 {
147  return type;
148 }

◆ setValue() [1/12]

void QDeclarativeVMEVariant::setValue ( QObject v)
inline

◆ setValue() [2/12]

void QDeclarativeVMEVariant::setValue ( const QVariant v)
inline

Definition at line 266 of file qdeclarativevmemetaobject.cpp.

267 {
268  if (type != qMetaTypeId<QVariant>()) {
269  cleanup();
270  type = qMetaTypeId<QVariant>();
271  new (dataPtr()) QVariant(v);
272  } else {
273  *(QVariant *)(dataPtr()) = v;
274  }
275 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92

◆ setValue() [3/12]

void QDeclarativeVMEVariant::setValue ( int  v)
inline

Definition at line 277 of file qdeclarativevmemetaobject.cpp.

278 {
279  if (type != QMetaType::Int) {
280  cleanup();
282  }
283  *(int *)(dataPtr()) = v;
284 }

◆ setValue() [4/12]

void QDeclarativeVMEVariant::setValue ( bool  v)
inline

Definition at line 286 of file qdeclarativevmemetaobject.cpp.

287 {
288  if (type != QMetaType::Bool) {
289  cleanup();
291  }
292  *(bool *)(dataPtr()) = v;
293 }

◆ setValue() [5/12]

void QDeclarativeVMEVariant::setValue ( double  v)
inline

Definition at line 295 of file qdeclarativevmemetaobject.cpp.

296 {
297  if (type != QMetaType::Double) {
298  cleanup();
300  }
301  *(double *)(dataPtr()) = v;
302 }

◆ setValue() [6/12]

void QDeclarativeVMEVariant::setValue ( const QString v)
inline

Definition at line 304 of file qdeclarativevmemetaobject.cpp.

305 {
306  if (type != QMetaType::QString) {
307  cleanup();
309  new (dataPtr()) QString(v);
310  } else {
311  *(QString *)(dataPtr()) = v;
312  }
313 }
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ setValue() [7/12]

void QDeclarativeVMEVariant::setValue ( const QUrl v)
inline

Definition at line 315 of file qdeclarativevmemetaobject.cpp.

316 {
317  if (type != QMetaType::QUrl) {
318  cleanup();
320  new (dataPtr()) QUrl(v);
321  } else {
322  *(QUrl *)(dataPtr()) = v;
323  }
324 }
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61

◆ setValue() [8/12]

void QDeclarativeVMEVariant::setValue ( const QColor v)
inline

Definition at line 326 of file qdeclarativevmemetaobject.cpp.

327 {
328  if (type != QMetaType::QColor) {
329  cleanup();
331  new (dataPtr()) QColor(v);
332  } else {
333  *(QColor *)(dataPtr()) = v;
334  }
335 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67

◆ setValue() [9/12]

void QDeclarativeVMEVariant::setValue ( const QTime v)
inline

Definition at line 337 of file qdeclarativevmemetaobject.cpp.

338 {
339  if (type != QMetaType::QTime) {
340  cleanup();
342  new (dataPtr()) QTime(v);
343  } else {
344  *(QTime *)(dataPtr()) = v;
345  }
346 }
The QTime class provides clock time functions.
Definition: qdatetime.h:148

◆ setValue() [10/12]

void QDeclarativeVMEVariant::setValue ( const QDate v)
inline

Definition at line 348 of file qdeclarativevmemetaobject.cpp.

349 {
350  if (type != QMetaType::QDate) {
351  cleanup();
353  new (dataPtr()) QDate(v);
354  } else {
355  *(QDate *)(dataPtr()) = v;
356  }
357 }
The QDate class provides date functions.
Definition: qdatetime.h:55

◆ setValue() [11/12]

void QDeclarativeVMEVariant::setValue ( const QDateTime v)
inline

Definition at line 359 of file qdeclarativevmemetaobject.cpp.

360 {
361  if (type != QMetaType::QDateTime) {
362  cleanup();
364  new (dataPtr()) QDateTime(v);
365  } else {
366  *(QDateTime *)(dataPtr()) = v;
367  }
368 }
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216

◆ setValue() [12/12]

void QDeclarativeVMEVariant::setValue ( const QScriptValue v)
inline

Definition at line 370 of file qdeclarativevmemetaobject.cpp.

371 {
372  if (type != qMetaTypeId<QScriptValue>()) {
373  cleanup();
374  type = qMetaTypeId<QScriptValue>();
375  new (dataPtr()) QScriptValue(v);
376  } else {
377  *(QScriptValue *)(dataPtr()) = v;
378  }
379 }
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

Properties

◆ data

void* QDeclarativeVMEVariant::data[4]
private

Definition at line 92 of file qdeclarativevmemetaobject.cpp.

Referenced by dataPtr().

◆ type

int QDeclarativeVMEVariant::type
private

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