Qt 4.8
Public Types | Public Functions | Properties | Related Functions | List of all members
QScriptDebuggerValue Class Reference

The QScriptDebuggerValue class represents a script value. More...

#include <qscriptdebuggervalue_p.h>

Public Types

enum  ValueType {
  NoValue, UndefinedValue, NullValue, BooleanValue,
  StringValue, NumberValue, ObjectValue
}
 

Public Functions

bool booleanValue () const
 Returns this value as a boolean. More...
 
double numberValue () const
 Returns this value as a number. More...
 
qint64 objectId () const
 Returns this value as an object ID. More...
 
bool operator!= (const QScriptDebuggerValue &other) const
 Returns true if this QScriptDebuggerValue is not equal to the other value, otherwise returns false. More...
 
QScriptDebuggerValueoperator= (const QScriptDebuggerValue &other)
 
bool operator== (const QScriptDebuggerValue &other) const
 Returns true if this QScriptDebuggerValue is equal to the other value, otherwise returns false. More...
 
 QScriptDebuggerValue ()
 
 QScriptDebuggerValue (const QScriptValue &value)
 
 QScriptDebuggerValue (double value)
 
 QScriptDebuggerValue (bool value)
 
 QScriptDebuggerValue (const QString &value)
 
 QScriptDebuggerValue (qint64 objectId)
 
 QScriptDebuggerValue (ValueType type)
 
 QScriptDebuggerValue (const QScriptDebuggerValue &other)
 
QString stringValue () const
 Returns this value as a string. More...
 
QScriptValue toScriptValue (QScriptEngine *engine) const
 Converts this QScriptDebuggerValue to a QScriptValue in the given engine and returns the resulting value. More...
 
QString toString () const
 Returns a string representation of this value. More...
 
ValueType type () const
 Returns the type of this value. More...
 
 ~QScriptDebuggerValue ()
 

Properties

QScopedSharedPointer< QScriptDebuggerValuePrivated_ptr
 

Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &stream, const QScriptDebuggerValue &value)
 Writes the given value to the specified stream. More...
 
QDataStreamoperator>> (QDataStream &stream, QScriptDebuggerValue &value)
 Reads a QScriptDebuggerValue from the specified stream into the given value. More...
 

Detailed Description

The QScriptDebuggerValue class represents a script value.

Since
4.5
Warning
This function is not part of the public interface.

Definition at line 67 of file qscriptdebuggervalue_p.h.

Enumerations

◆ ValueType

Constructors and Destructors

◆ QScriptDebuggerValue() [1/8]

QScriptDebuggerValue::QScriptDebuggerValue ( )

Definition at line 91 of file qscriptdebuggervalue.cpp.

Referenced by operator>>().

92  : d_ptr(0)
93 {
94 }
QScopedSharedPointer< QScriptDebuggerValuePrivate > d_ptr

◆ QScriptDebuggerValue() [2/8]

QScriptDebuggerValue::QScriptDebuggerValue ( const QScriptValue value)

Definition at line 96 of file qscriptdebuggervalue.cpp.

97  : d_ptr(0)
98 {
99  if (value.isValid()) {
101  if (value.isUndefined())
102  d_ptr->type = UndefinedValue;
103  else if (value.isNull())
104  d_ptr->type = NullValue;
105  else if (value.isNumber()) {
106  d_ptr->type = NumberValue;
107  d_ptr->numberValue = value.toNumber();
108  } else if (value.isBoolean()) {
109  d_ptr->type = BooleanValue;
110  d_ptr->booleanValue = value.toBoolean();
111  } else if (value.isString()) {
112  d_ptr->type = StringValue;
113  d_ptr->stringValue = new QString(value.toString());
114  } else {
115  Q_ASSERT(value.isObject());
116  d_ptr->type = ObjectValue;
117  d_ptr->objectId = value.objectId();
118  }
119  d_ptr->ref.ref();
120  }
121 }
bool isUndefined() const
Returns true if this QScriptValue is of the primitive type Undefined; otherwise returns false...
bool isNull() const
Returns true if this QScriptValue is of the primitive type Null; otherwise returns false...
QScopedSharedPointer< QScriptDebuggerValuePrivate > d_ptr
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
bool isBoolean() const
Use isBool() instead.
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
qint64 objectId() const
Returns the ID of this object, or -1 if this QScriptValue is not an object.
bool isString() const
Returns true if this QScriptValue is of the primitive type String; otherwise returns false...
bool toBoolean() const
Use toBool() instead.
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
qsreal toNumber() const
Returns the number value of this QScriptValue, as defined in ECMA-262 section 9.3, "ToNumber".
bool isNumber() const
Returns true if this QScriptValue is of the primitive type Number; otherwise returns false...
if(void) toggleToolbarShown
bool isValid() const
Returns true if this QScriptValue is valid; otherwise returns false.
bool isObject() const
Returns true if this QScriptValue is of the Object type; otherwise returns false. ...

◆ QScriptDebuggerValue() [3/8]

QScriptDebuggerValue::QScriptDebuggerValue ( double  value)

Definition at line 123 of file qscriptdebuggervalue.cpp.

125 {
126  d_ptr->type = NumberValue;
127  d_ptr->numberValue = value;
128  d_ptr->ref.ref();
129 }
QScopedSharedPointer< QScriptDebuggerValuePrivate > d_ptr

◆ QScriptDebuggerValue() [4/8]

QScriptDebuggerValue::QScriptDebuggerValue ( bool  value)

Definition at line 131 of file qscriptdebuggervalue.cpp.

133 {
134  d_ptr->type = BooleanValue;
135  d_ptr->booleanValue = value;
136  d_ptr->ref.ref();
137 }
QScopedSharedPointer< QScriptDebuggerValuePrivate > d_ptr

◆ QScriptDebuggerValue() [5/8]

QScriptDebuggerValue::QScriptDebuggerValue ( const QString value)

Definition at line 139 of file qscriptdebuggervalue.cpp.

141 {
142  d_ptr->type = StringValue;
143  d_ptr->stringValue = new QString(value);
144  d_ptr->ref.ref();
145 }
QScopedSharedPointer< QScriptDebuggerValuePrivate > d_ptr
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ QScriptDebuggerValue() [6/8]

QScriptDebuggerValue::QScriptDebuggerValue ( qint64  objectId)

Definition at line 147 of file qscriptdebuggervalue.cpp.

149 {
150  d_ptr->type = ObjectValue;
151  d_ptr->objectId = objectId;
152  d_ptr->ref.ref();
153 }
QScopedSharedPointer< QScriptDebuggerValuePrivate > d_ptr
qint64 objectId() const
Returns this value as an object ID.

◆ QScriptDebuggerValue() [7/8]

QScriptDebuggerValue::QScriptDebuggerValue ( ValueType  type)

Definition at line 155 of file qscriptdebuggervalue.cpp.

157 {
158  d_ptr->type = type;
159  d_ptr->ref.ref();
160 }
QScopedSharedPointer< QScriptDebuggerValuePrivate > d_ptr
ValueType type() const
Returns the type of this value.

◆ QScriptDebuggerValue() [8/8]

QScriptDebuggerValue::QScriptDebuggerValue ( const QScriptDebuggerValue other)

Definition at line 162 of file qscriptdebuggervalue.cpp.

163  : d_ptr(other.d_ptr.data())
164 {
165  if (d_ptr)
166  d_ptr->ref.ref();
167 }
QScopedSharedPointer< QScriptDebuggerValuePrivate > d_ptr
T * data() const
Returns the value of the pointer referenced by this object.

◆ ~QScriptDebuggerValue()

QScriptDebuggerValue::~QScriptDebuggerValue ( )

Definition at line 169 of file qscriptdebuggervalue.cpp.

170 {
171 }

Functions

◆ booleanValue()

bool QScriptDebuggerValue::booleanValue ( ) const

Returns this value as a boolean.

Definition at line 205 of file qscriptdebuggervalue.cpp.

Referenced by operator<<().

206 {
207  Q_D(const QScriptDebuggerValue);
208  if (!d)
209  return false;
210  Q_ASSERT(d->type == BooleanValue);
211  return d->booleanValue;
212 }
double d
Definition: qnumeric_p.h:62
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerValue class represents a script value.

◆ numberValue()

double QScriptDebuggerValue::numberValue ( ) const

Returns this value as a number.

Definition at line 193 of file qscriptdebuggervalue.cpp.

Referenced by operator<<().

194 {
195  Q_D(const QScriptDebuggerValue);
196  if (!d)
197  return 0;
198  Q_ASSERT(d->type == NumberValue);
199  return d->numberValue;
200 }
double d
Definition: qnumeric_p.h:62
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerValue class represents a script value.

◆ objectId()

qint64 QScriptDebuggerValue::objectId ( ) const

Returns this value as an object ID.

Definition at line 229 of file qscriptdebuggervalue.cpp.

Referenced by operator<<(), and QScriptDebuggerValue().

230 {
231  Q_D(const QScriptDebuggerValue);
232  if (!d)
233  return -1;
234  Q_ASSERT(d->type == ObjectValue);
235  return d->objectId;
236 }
double d
Definition: qnumeric_p.h:62
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerValue class represents a script value.

◆ operator!=()

bool QScriptDebuggerValue::operator!= ( const QScriptDebuggerValue other) const

Returns true if this QScriptDebuggerValue is not equal to the other value, otherwise returns false.

Definition at line 331 of file qscriptdebuggervalue.cpp.

332 {
333  return !(*this == other);
334 }

◆ operator=()

QScriptDebuggerValue & QScriptDebuggerValue::operator= ( const QScriptDebuggerValue other)

Definition at line 173 of file qscriptdebuggervalue.cpp.

174 {
175  d_ptr.assign(other.d_ptr.data());
176  return *this;
177 }
QScopedSharedPointer< QScriptDebuggerValuePrivate > d_ptr
T * data() const
Returns the value of the pointer referenced by this object.

◆ operator==()

bool QScriptDebuggerValue::operator== ( const QScriptDebuggerValue other) const

Returns true if this QScriptDebuggerValue is equal to the other value, otherwise returns false.

Definition at line 300 of file qscriptdebuggervalue.cpp.

301 {
302  Q_D(const QScriptDebuggerValue);
303  const QScriptDebuggerValuePrivate *od = other.d_func();
304  if (d == od)
305  return true;
306  if (!d || !od)
307  return false;
308  if (d->type != od->type)
309  return false;
310  switch (d->type) {
311  case NoValue:
312  case UndefinedValue:
313  case NullValue:
314  return true;
315  case BooleanValue:
316  return d->booleanValue == od->booleanValue;
317  case StringValue:
318  return *d->stringValue == *od->stringValue;
319  case NumberValue:
320  return d->numberValue == od->numberValue;
321  case ObjectValue:
322  return d->objectId == od->objectId;
323  }
324  return false;
325 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerValue class represents a script value.
QScriptDebuggerValue::ValueType type

◆ stringValue()

QString QScriptDebuggerValue::stringValue ( ) const

Returns this value as a string.

Definition at line 217 of file qscriptdebuggervalue.cpp.

Referenced by operator<<().

218 {
219  Q_D(const QScriptDebuggerValue);
220  if (!d)
221  return QString();
222  Q_ASSERT(d->type == StringValue);
223  return *d->stringValue;
224 }
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerValue class represents a script value.

◆ toScriptValue()

QScriptValue QScriptDebuggerValue::toScriptValue ( QScriptEngine engine) const

Converts this QScriptDebuggerValue to a QScriptValue in the given engine and returns the resulting value.

Definition at line 242 of file qscriptdebuggervalue.cpp.

Referenced by QScriptDebuggerCommandExecutor::execute().

243 {
244  Q_D(const QScriptDebuggerValue);
245  if (!d)
246  return QScriptValue();
247  switch (d->type) {
248  case NoValue:
249  return QScriptValue();
250  case UndefinedValue:
251  return engine->undefinedValue();
252  case NullValue:
253  return engine->nullValue();
254  case BooleanValue:
255  return QScriptValue(engine, d->booleanValue);
256  case StringValue:
257  return QScriptValue(engine, *d->stringValue);
258  case NumberValue:
259  return QScriptValue(engine, d->numberValue);
260  case ObjectValue:
261  return engine->objectById(d->objectId);
262  }
263  return QScriptValue();
264 }
double d
Definition: qnumeric_p.h:62
QScriptValue objectById(qint64 id) const
Returns the object with the given id, or an invalid QScriptValue if there is no object with that id...
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerValue class represents a script value.
QScriptValue undefinedValue()
Returns a QScriptValue of the primitive type Undefined.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.

◆ toString()

QString QScriptDebuggerValue::toString ( ) const

Returns a string representation of this value.

Definition at line 269 of file qscriptdebuggervalue.cpp.

270 {
271  Q_D(const QScriptDebuggerValue);
272  if (!d)
273  return QString();
274  switch (d->type) {
275  case NoValue:
276  return QString();
277  case UndefinedValue:
278  return QString::fromLatin1("undefined");
279  case NullValue:
280  return QString::fromLatin1("null");
281  case BooleanValue:
282  if (d->booleanValue)
283  return QString::fromLatin1("true");
284  else
285  return QString::fromLatin1("false");
286  case StringValue:
287  return *d->stringValue;
288  case NumberValue:
289  return QString::number(d->numberValue); // ### qScriptNumberToString()
290  case ObjectValue:
291  return QString::fromLatin1("[object Object]");
292  }
293  return QString();
294 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
The QScriptDebuggerValue class represents a script value.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188

◆ type()

QScriptDebuggerValue::ValueType QScriptDebuggerValue::type ( ) const

Friends and Related Functions

◆ operator<<()

QDataStream & operator<< ( QDataStream stream,
const QScriptDebuggerValue value 
)
related

Writes the given value to the specified stream.

Definition at line 345 of file qscriptdebuggervalue.cpp.

346 {
347  out << (quint32)value.type();
348  switch (value.type()) {
352  break;
354  out << value.booleanValue();
355  break;
357  out << value.stringValue();
358  break;
360  out << value.numberValue();
361  break;
363  out << value.objectId();
364  break;
365  }
366  return out;
367 }
QString stringValue() const
Returns this value as a string.
ValueType type() const
Returns the type of this value.
double numberValue() const
Returns this value as a number.
bool booleanValue() const
Returns this value as a boolean.
unsigned int quint32
Definition: qglobal.h:938
qint64 objectId() const
Returns this value as an object ID.

◆ operator>>()

QDataStream & operator>> ( QDataStream stream,
QScriptDebuggerValue value 
)
related

Reads a QScriptDebuggerValue from the specified stream into the given value.

Definition at line 379 of file qscriptdebuggervalue.cpp.

380 {
381  quint32 type;
382  in >> type;
383  switch (QScriptDebuggerValue::ValueType(type)) {
387  break;
389  bool b;
390  in >> b;
391  value = QScriptDebuggerValue(b);
392  } break;
394  QString s;
395  in >> s;
396  value = QScriptDebuggerValue(s);
397  } break;
399  double d;
400  in >> d;
401  value = QScriptDebuggerValue(d);
402  } break;
404  qint64 id;
405  in >> id;
406  value = QScriptDebuggerValue(id);
407  } break;
409  default:
410  value = QScriptDebuggerValue();
411  break;
412  }
413  return in;
414 }
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
__int64 qint64
Definition: qglobal.h:942
ValueType type() const
Returns the type of this value.
unsigned int quint32
Definition: qglobal.h:938

Properties

◆ d_ptr

QScopedSharedPointer<QScriptDebuggerValuePrivate> QScriptDebuggerValue::d_ptr
private

Definition at line 106 of file qscriptdebuggervalue_p.h.

Referenced by operator=(), and QScriptDebuggerValue().


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