Qt 4.8
Public Types | Public Functions | Properties | Friends | List of all members
QDeclarativeDomValue Class Reference

The QDeclarativeDomValue class represents a generic Qml value. More...

#include <qdeclarativedom_p.h>

Public Types

enum  Type {
  Invalid, Literal, PropertyBinding, ValueSource,
  ValueInterceptor, Object, List
}
 The type of the QDeclarativeDomValue node. More...
 

Public Functions

bool isBinding () const
 Returns true if this is a property binding value, otherwise false. More...
 
bool isInvalid () const
 Returns true if this is an invalid value, otherwise false. More...
 
bool isList () const
 Returns true if this is a list value, otherwise false. More...
 
bool isLiteral () const
 Returns true if this is a literal value, otherwise false. More...
 
bool isObject () const
 Returns true if this is an object value, otherwise false. More...
 
bool isValueInterceptor () const
 Returns true if this is a value interceptor value, otherwise false. More...
 
bool isValueSource () const
 Returns true if this is a value source value, otherwise false. More...
 
int length () const
 
Returns the length in the input data from where the property value started u

pto the end of it, or -1 if the value is invalid. More...

 
QDeclarativeDomValueoperator= (const QDeclarativeDomValue &)
 Assign other to this QDeclarativeDomValue. More...
 
int position () const
 Returns the position in the input data where the property value startd, or -1 if the value is invalid. More...
 
 QDeclarativeDomValue ()
 Construct an invalid QDeclarativeDomValue. More...
 
 QDeclarativeDomValue (const QDeclarativeDomValue &)
 Create a copy of other QDeclarativeDomValue. More...
 
QDeclarativeDomValueBinding toBinding () const
 Returns a QDeclarativeDomValueBinding if this value is a property binding type, otherwise returns an invalid QDeclarativeDomValueBinding. More...
 
QDeclarativeDomList toList () const
 Returns a QDeclarativeDomList if this value is a list type, otherwise returns an invalid QDeclarativeDomList. More...
 
QDeclarativeDomValueLiteral toLiteral () const
 Returns a QDeclarativeDomValueLiteral if this value is a literal type, otherwise returns an invalid QDeclarativeDomValueLiteral. More...
 
QDeclarativeDomObject toObject () const
 Returns a QDeclarativeDomObject if this value is an object assignment type, otherwise returns an invalid QDeclarativeDomObject. More...
 
QDeclarativeDomValueValueInterceptor toValueInterceptor () const
 Returns a QDeclarativeDomValueValueInterceptor if this value is a property value interceptor type, otherwise returns an invalid QDeclarativeDomValueValueInterceptor. More...
 
QDeclarativeDomValueValueSource toValueSource () const
 Returns a QDeclarativeDomValueValueSource if this value is a property value source type, otherwise returns an invalid QDeclarativeDomValueValueSource. More...
 
Type type () const
 Returns the type of this QDeclarativeDomValue. More...
 
 ~QDeclarativeDomValue ()
 Destroy the QDeclarativeDomValue. More...
 

Properties

QSharedDataPointer< QDeclarativeDomValuePrivated
 

Friends

class QDeclarativeDomList
 
class QDeclarativeDomProperty
 

Detailed Description

The QDeclarativeDomValue class represents a generic Qml value.

Warning
This function is not part of the public interface.
QDeclarativeDomValue's can be assigned to QML \link QDeclarativeDomProperty \endlink{properties}.  In
QML, properties can be assigned various different values, including basic
literals, property bindings, property value sources, objects and lists of
values.  The QDeclarativeDomValue class allows a programmer to determine the specific
value type being assigned and access more detailed information through a
corresponding value type class.

For example, in the following example,
text: "Hello World!"
y: Other.y
}

The text property is being assigned a literal, and the y property a property binding. To output the values assigned to the text and y properties in the above example from C++,

if (text.value().isLiteral()) {
qDebug() << literal.literal();
}
if (y.value().isBinding()) {
qDebug() << binding.binding();
}

Definition at line 273 of file qdeclarativedom_p.h.

Enumerations

◆ Type

The type of the QDeclarativeDomValue node.

Enumerator
Invalid 
Literal 
PropertyBinding 
ValueSource 
ValueInterceptor 
Object 
List 

Definition at line 276 of file qdeclarativedom_p.h.

Constructors and Destructors

◆ QDeclarativeDomValue() [1/2]

QDeclarativeDomValue::QDeclarativeDomValue ( )

Construct an invalid QDeclarativeDomValue.

Definition at line 1315 of file qdeclarativedom.cpp.

1317 {
1318 }
QSharedDataPointer< QDeclarativeDomValuePrivate > d

◆ QDeclarativeDomValue() [2/2]

QDeclarativeDomValue::QDeclarativeDomValue ( const QDeclarativeDomValue other)

Create a copy of other QDeclarativeDomValue.

Definition at line 1323 of file qdeclarativedom.cpp.

1324 : d(other.d)
1325 {
1326 }
QSharedDataPointer< QDeclarativeDomValuePrivate > d

◆ ~QDeclarativeDomValue()

QDeclarativeDomValue::~QDeclarativeDomValue ( )

Destroy the QDeclarativeDomValue.

Definition at line 1331 of file qdeclarativedom.cpp.

1332 {
1333 }

Functions

◆ isBinding()

bool QDeclarativeDomValue::isBinding ( ) const

Returns true if this is a property binding value, otherwise false.

Definition at line 1417 of file qdeclarativedom.cpp.

1418 {
1419  return type() == PropertyBinding;
1420 }
Type type() const
Returns the type of this QDeclarativeDomValue.

◆ isInvalid()

bool QDeclarativeDomValue::isInvalid ( ) const

Returns true if this is an invalid value, otherwise false.

Definition at line 1401 of file qdeclarativedom.cpp.

1402 {
1403  return type() == Invalid;
1404 }
Type type() const
Returns the type of this QDeclarativeDomValue.

◆ isList()

bool QDeclarativeDomValue::isList ( ) const

Returns true if this is a list value, otherwise false.

Definition at line 1449 of file qdeclarativedom.cpp.

1450 {
1451  return type() == List;
1452 }
Type type() const
Returns the type of this QDeclarativeDomValue.

◆ isLiteral()

bool QDeclarativeDomValue::isLiteral ( ) const

Returns true if this is a literal value, otherwise false.

Definition at line 1409 of file qdeclarativedom.cpp.

1410 {
1411  return type() == Literal;
1412 }
Type type() const
Returns the type of this QDeclarativeDomValue.

◆ isObject()

bool QDeclarativeDomValue::isObject ( ) const

Returns true if this is an object value, otherwise false.

Definition at line 1441 of file qdeclarativedom.cpp.

1442 {
1443  return type() == Object;
1444 }
Type type() const
Returns the type of this QDeclarativeDomValue.

◆ isValueInterceptor()

bool QDeclarativeDomValue::isValueInterceptor ( ) const

Returns true if this is a value interceptor value, otherwise false.

Definition at line 1433 of file qdeclarativedom.cpp.

1434 {
1435  return type() == ValueInterceptor;
1436 }
Type type() const
Returns the type of this QDeclarativeDomValue.

◆ isValueSource()

bool QDeclarativeDomValue::isValueSource ( ) const

Returns true if this is a value source value, otherwise false.

Definition at line 1425 of file qdeclarativedom.cpp.

1426 {
1427  return type() == ValueSource;
1428 }
Type type() const
Returns the type of this QDeclarativeDomValue.

◆ length()

int QDeclarativeDomValue::length ( ) const

Returns the length in the input data from where the property value started u

pto the end of it, or -1 if the value is invalid.

Definition at line 1565 of file qdeclarativedom.cpp.

1566 {
1567  if (type() == Invalid)
1568  return -1;
1569  else
1570  return d->value->location.range.length;
1571 }
Type type() const
Returns the type of this QDeclarativeDomValue.
QSharedDataPointer< QDeclarativeDomValuePrivate > d
QDeclarativeParser::Value * value

◆ operator=()

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

Assign other to this QDeclarativeDomValue.

Definition at line 1338 of file qdeclarativedom.cpp.

1339 {
1340  d = other.d;
1341  return *this;
1342 }
QSharedDataPointer< QDeclarativeDomValuePrivate > d

◆ position()

int QDeclarativeDomValue::position ( ) const

Returns the position in the input data where the property value startd, or -1 if the value is invalid.

Definition at line 1553 of file qdeclarativedom.cpp.

1554 {
1555  if (type() == Invalid)
1556  return -1;
1557  else
1558  return d->value->location.range.offset;
1559 }
Type type() const
Returns the type of this QDeclarativeDomValue.
QSharedDataPointer< QDeclarativeDomValuePrivate > d
QDeclarativeParser::Value * value

◆ toBinding()

QDeclarativeDomValueBinding QDeclarativeDomValue::toBinding ( ) const

Returns a QDeclarativeDomValueBinding if this value is a property binding type, otherwise returns an invalid QDeclarativeDomValueBinding.

See also
QDeclarativeDomValue::type()

Definition at line 1476 of file qdeclarativedom.cpp.

1477 {
1479  if (type() == PropertyBinding) {
1480  rv.d->value = d->value;
1481  rv.d->value->addref();
1482  }
1483  return rv;
1484 }
QDeclarativeParser::Value * value
The QDeclarativeDomValueBinding class represents a property binding.
Type type() const
Returns the type of this QDeclarativeDomValue.
QSharedDataPointer< QDeclarativeDomValuePrivate > d
QSharedDataPointer< QDeclarativeDomBasicValuePrivate > d
QDeclarativeParser::Value * value

◆ toList()

QDeclarativeDomList QDeclarativeDomValue::toList ( ) const

Returns a QDeclarativeDomList if this value is a list type, otherwise returns an invalid QDeclarativeDomList.

See also
QDeclarativeDomValue::type()

Definition at line 1540 of file qdeclarativedom.cpp.

1541 {
1543  if (type() == List) {
1544  rv.d = d;
1545  }
1546  return rv;
1547 }
The QDeclarativeDomList class represents a list of values assigned to a QML property.
QSharedDataPointer< QDeclarativeDomValuePrivate > d
Type type() const
Returns the type of this QDeclarativeDomValue.
QSharedDataPointer< QDeclarativeDomValuePrivate > d

◆ toLiteral()

QDeclarativeDomValueLiteral QDeclarativeDomValue::toLiteral ( ) const

Returns a QDeclarativeDomValueLiteral if this value is a literal type, otherwise returns an invalid QDeclarativeDomValueLiteral.

See also
QDeclarativeDomValue::type()

Definition at line 1460 of file qdeclarativedom.cpp.

1461 {
1463  if (type() == Literal) {
1464  rv.d->value = d->value;
1465  rv.d->value->addref();
1466  }
1467  return rv;
1468 }
QDeclarativeParser::Value * value
Type type() const
Returns the type of this QDeclarativeDomValue.
QSharedDataPointer< QDeclarativeDomValuePrivate > d
QSharedDataPointer< QDeclarativeDomBasicValuePrivate > d
The QDeclarativeDomValueLiteral class represents a literal value.
QDeclarativeParser::Value * value

◆ toObject()

QDeclarativeDomObject QDeclarativeDomValue::toObject ( ) const

Returns a QDeclarativeDomObject if this value is an object assignment type, otherwise returns an invalid QDeclarativeDomObject.

See also
QDeclarativeDomValue::type()

Definition at line 1524 of file qdeclarativedom.cpp.

1525 {
1527  if (type() == Object) {
1528  rv.d->object = d->value->object;
1529  rv.d->object->addref();
1530  }
1531  return rv;
1532 }
QDeclarativeParser::Object * object
QSharedDataPointer< QDeclarativeDomObjectPrivate > d
Type type() const
Returns the type of this QDeclarativeDomValue.
QSharedDataPointer< QDeclarativeDomValuePrivate > d
The QDeclarativeDomObject class represents an object instantiation.
QDeclarativeParser::Value * value

◆ toValueInterceptor()

QDeclarativeDomValueValueInterceptor QDeclarativeDomValue::toValueInterceptor ( ) const

Returns a QDeclarativeDomValueValueInterceptor if this value is a property value interceptor type, otherwise returns an invalid QDeclarativeDomValueValueInterceptor.

See also
QDeclarativeDomValue::type()

Definition at line 1508 of file qdeclarativedom.cpp.

1509 {
1511  if (type() == ValueInterceptor) {
1512  rv.d->value = d->value;
1513  rv.d->value->addref();
1514  }
1515  return rv;
1516 }
QDeclarativeParser::Value * value
Type type() const
Returns the type of this QDeclarativeDomValue.
QSharedDataPointer< QDeclarativeDomValuePrivate > d
The QDeclarativeDomValueValueInterceptor class represents a value interceptor assignment value...
QSharedDataPointer< QDeclarativeDomBasicValuePrivate > d
QDeclarativeParser::Value * value

◆ toValueSource()

QDeclarativeDomValueValueSource QDeclarativeDomValue::toValueSource ( ) const

Returns a QDeclarativeDomValueValueSource if this value is a property value source type, otherwise returns an invalid QDeclarativeDomValueValueSource.

See also
QDeclarativeDomValue::type()

Definition at line 1492 of file qdeclarativedom.cpp.

1493 {
1495  if (type() == ValueSource) {
1496  rv.d->value = d->value;
1497  rv.d->value->addref();
1498  }
1499  return rv;
1500 }
QDeclarativeParser::Value * value
Type type() const
Returns the type of this QDeclarativeDomValue.
QSharedDataPointer< QDeclarativeDomValuePrivate > d
The QDeclarativeDomValueValueSource class represents a value source assignment value.
QDeclarativeParser::Value * value
QSharedDataPointer< QDeclarativeDomBasicValuePrivate > d

◆ type()

QDeclarativeDomValue::Type QDeclarativeDomValue::type ( ) const

Returns the type of this QDeclarativeDomValue.

Definition at line 1364 of file qdeclarativedom.cpp.

Referenced by isBinding(), isInvalid(), isList(), isLiteral(), isObject(), isValueInterceptor(), isValueSource(), length(), position(), toBinding(), toList(), toLiteral(), toObject(), toValueInterceptor(), and toValueSource().

1365 {
1366  if (d->property)
1368  (d->property && (d->property->values.count() + d->property->onValues.count()) > 1))
1369  return List;
1370 
1371  QDeclarativeParser::Value *value = d->value;
1372  if (!value && !d->property)
1373  return Invalid;
1374 
1375  switch(value->type) {
1377  return Invalid;
1379  return Literal;
1381  return PropertyBinding;
1383  return ValueSource;
1385  return ValueInterceptor;
1387  return Object;
1389  return Invalid;
1391  return Literal;
1393  return Literal;
1394  }
1395  return Invalid;
1396 }
QSharedDataPointer< QDeclarativeDomValuePrivate > d
QDeclarativeParser::Property * property
QDeclarativeParser::Value * value

Friends and Related Functions

◆ QDeclarativeDomList

friend class QDeclarativeDomList
friend

Definition at line 313 of file qdeclarativedom_p.h.

◆ QDeclarativeDomProperty

Definition at line 312 of file qdeclarativedom_p.h.

Properties

◆ d

QSharedDataPointer<QDeclarativeDomValuePrivate> QDeclarativeDomValue::d
private

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