QDBusDataList Class Reference

Class to transport lists of D-Bus data types. More...

#include <qdbusdatalist.h>

List of all members.

Public Member Functions

 QDBusDataList ()
 Creates an empty and invalid list.
 QDBusDataList (QDBusData::Type simpleItemType)
 Creates an empty list with the given simple type for elements.
 QDBusDataList (const QDBusData &containerItemType)
 Creates an empty list with the given container type for elements.
 QDBusDataList (const QDBusDataList &other)
 Creates a list from the given other list.
 QDBusDataList (const QValueList< QDBusData > &other)
 Creates a list from the given QValueList of QDBusData objects.
 QDBusDataList (const QValueList< bool > &other)
 Creates a list from the given QValueList of boolean values.
 QDBusDataList (const QValueList< Q_UINT8 > &other)
 Creates a list from the given QValueList of byte (unsigned char) values.
 QDBusDataList (const QValueList< Q_INT16 > &other)
 Creates a list from the given QValueList of signed 16-bit integer values.
 QDBusDataList (const QValueList< Q_UINT16 > &other)
 Creates a list from the given QValueList of unsigned 16-bit integer values.
 QDBusDataList (const QValueList< Q_INT32 > &other)
 Creates a list from the given QValueList of signed 32-bit integer values.
 QDBusDataList (const QValueList< Q_UINT32 > &other)
 Creates a list from the given QValueList of unsigned 32-bit integer values.
 QDBusDataList (const QValueList< Q_INT64 > &other)
 Creates a list from the given QValueList of signed 64-bit integer values.
 QDBusDataList (const QValueList< Q_UINT64 > &other)
 Creates a list from the given QValueList of unsigned 64-bit integer values.
 QDBusDataList (const QValueList< double > &other)
 Creates a list from the given QValueList of double values.
 QDBusDataList (const QValueList< QDBusVariant > &other)
 Creates a list from the given QValueList of QDBusVariant values.
 QDBusDataList (const QStringList &other)
 Creates a list from the given QStringList's values.
 QDBusDataList (const QValueList< QDBusObjectPath > &other)
 Creates a list from the given QValueList of object path values.
 ~QDBusDataList ()
 Destroys the list object.
QDBusDataListoperator= (const QDBusDataList &other)
 Copies from the given other list.
QDBusDataListoperator= (const QValueList< QDBusData > &other)
 Copies from the given other list.
QDBusDataListoperator= (const QStringList &other)
 Copies from the given other list.
QDBusData::Type type () const
 Returns the element type of the list object.
bool hasContainerItemType () const
 Checks whether the element type is a data container itself.
QDBusData containerItemType () const
 Returns a container prototype for the list's element type.
bool isValid () const
 Checks whether this list object has a valid element type.
bool isEmpty () const
 Checks whether this list object has any elements.
uint count () const
 Returns the number of elements of this list object.
bool operator== (const QDBusDataList &other) const
 Checks whether the given other list is equal to this one.
bool operator!= (const QDBusDataList &other) const
 Checks whether the given other list is different from this one.
void clear ()
 Clears the list.
QDBusDataListoperator<< (const QDBusData &data)
 Appends a given value to the list.
QValueList< QDBusDatatoQValueList () const
 Converts the list object into a QValueList with QDBusData elements.
QStringList toQStringList (bool *ok=0) const
 Tries to get the list object's elements as a QStringList.
QValueList< bool > toBoolList (bool *ok=0) const
 Tries to get the list object's elements as a QValueList of bool.
QValueList< Q_UINT8 > toByteList (bool *ok=0) const
 Tries to get the list object's elements as a QValueList of Q_UINT8.
QValueList< Q_INT16 > toInt16List (bool *ok=0) const
 Tries to get the list object's elements as a QValueList of Q_INT16.
QValueList< Q_UINT16 > toUInt16List (bool *ok=0) const
 Tries to get the list object's elements as a QValueList of Q_UINT16.
QValueList< Q_INT32 > toInt32List (bool *ok=0) const
 Tries to get the list object's elements as a QValueList of Q_INT32.
QValueList< Q_UINT32 > toUInt32List (bool *ok=0) const
 Tries to get the list object's elements as a QValueList of Q_UINT32.
QValueList< Q_INT64 > toInt64List (bool *ok=0) const
 Tries to get the list object's elements as a QValueList of Q_INT64.
QValueList< Q_UINT64 > toUInt64List (bool *ok=0) const
 Tries to get the list object's elements as a QValueList of Q_UINT64.
QValueList< double > toDoubleList (bool *ok=0) const
 Tries to get the list object's elements as a QValueList of double.
QValueList< QString > toStringList (bool *ok=0) const
 Tries to get the list object's elements as a QValueList of QString.
QValueList< QDBusObjectPathtoObjectPathList (bool *ok=0) const
 Tries to get the list object's elements as a QValueList of object paths.
QValueList< QDBusVarianttoVariantList (bool *ok=0) const
 Tries to get the list object's elements as a QValueList of QDBusVariant.

Detailed Description

Class to transport lists of D-Bus data types.

Note:
while the D-Bus data type is actually called array this bindings use the term list since the behavior and characteristics of the implementation is more list like.

There are basically two ways to create QDBusDataList objects:

Example for creating a filled list from content

 QValueList<Q_INT16> intList;
 list << 2 << 3 << 5 << 7;

 QDBusDataList dbusList(intList);
 QDBusData data = QDBusData::fromList(dbusList);

 // or even shorter, using implicit conversion
 QDBusData other = QDBusData::fromList(intList);

Example for creating an empty list

 // empty list for a simple type
 QDBusDataList list(QDBusData::Double);

 // empty list for a list of string lists
 QDBusData elementType = QDBusData::fromList(QDBusDataList(QDBusData::String));
 QDBusDataList outerList(elementType);
See also:
QDBusDataMap
Examples:

example-client.cpp, and example-service.cpp.


Constructor & Destructor Documentation

QDBusDataList::QDBusDataList (  ) 

Creates an empty and invalid list.

See also:
QDBusData::Invalid
QDBusDataList::QDBusDataList ( QDBusData::Type  simpleItemType  )  [explicit]

Creates an empty list with the given simple type for elements.

The given type has be one of the non-container types, i.e. any other than QDBusData::Map, QDBusData::List or QDBusData::Struct

For creating a list with elements which are containers themselves, use QDBusDataList(const QDBusData&);

Parameters:
simpleItemType the type of the elements in the new list
QDBusDataList::QDBusDataList ( const QDBusData containerItemType  )  [explicit]

Creates an empty list with the given container type for elements.

For creating a list with simple elements you can also use QDBusDataList(QDBusData::Type);

Parameters:
containerItemType the type of the elements in the new list
See also:
hasContainerItemType()
QDBusDataList::QDBusDataList ( const QDBusDataList other  ) 

Creates a list from the given other list.

This behaves basically like copying a QValueList through its copy constructor, i.e. no value are actually copied at this time.

Parameters:
other the other list object to copy from
QDBusDataList::QDBusDataList ( const QValueList< QDBusData > &  other  ) 

Creates a list from the given QValueList of QDBusData objects.

If the other list is empty, this will behave like QDBusDataList(), i.e. create an empty and invalid list object.

Type information for the list object, i.e. element type and, if applicable, container item type, will be derived from the other list's elements.

Warning:
if the elements of the other list do not all have the same type, the list object will also be empty and invalid
Parameters:
other the QValueList of QDBusData objects to copy from
See also:
toQValueList()
QDBusDataList::QDBusDataList ( const QValueList< bool > &  other  ) 

Creates a list from the given QValueList of boolean values.

Type information for the list object will be set to QDBusData::Bool also when the other list is empty, i.e. this allows to create an empty but valid list object, comparable to using QDBusDataList(QDBusData::Type) with QDBusData::Bool

Parameters:
other the QValueList of boolean values to copy from
See also:
toBoolList()
QDBusDataList::QDBusDataList ( const QValueList< Q_UINT8 > &  other  ) 

Creates a list from the given QValueList of byte (unsigned char) values.

Type information for the list object will be set to QDBusData::Byte also when the other list is empty, i.e. this allows to create an empty but valid list object, comparable to using QDBusDataList(QDBusData::Type) with QDBusData::Byte

Parameters:
other the QValueList of byte (unsigned char) values to copy from
See also:
toByteList()
QDBusDataList::QDBusDataList ( const QValueList< Q_INT16 > &  other  ) 

Creates a list from the given QValueList of signed 16-bit integer values.

Type information for the list object will be set to QDBusData::Int16 also when the other list is empty, i.e. this allows to create an empty but valid list object, comparable to using QDBusDataList(QDBusData::Type) with QDBusData::Int16

Parameters:
other the QValueList of signed 16-bit integer values to copy from
See also:
toInt16List()
QDBusDataList::QDBusDataList ( const QValueList< Q_UINT16 > &  other  ) 

Creates a list from the given QValueList of unsigned 16-bit integer values.

Type information for the list object will be set to QDBusData::UInt16 also when the other list is empty, i.e. this allows to create an empty but valid list object, comparable to using QDBusDataList(QDBusData::Type) with QDBusData::UInt16

Parameters:
other the QValueList of unsigned 16-bit integer values to copy from
See also:
toUInt16List()
QDBusDataList::QDBusDataList ( const QValueList< Q_INT32 > &  other  ) 

Creates a list from the given QValueList of signed 32-bit integer values.

Type information for the list object will be set to QDBusData::Int32 also when the other list is empty, i.e. this allows to create an empty but valid list object, comparable to using QDBusDataList(QDBusData::Type) with QDBusData::Int32

Parameters:
other the QValueList of signed 32-bit integer values to copy from
See also:
toInt32List()
QDBusDataList::QDBusDataList ( const QValueList< Q_UINT32 > &  other  ) 

Creates a list from the given QValueList of unsigned 32-bit integer values.

Type information for the list object will be set to QDBusData::UInt16 also when the other list is empty, i.e. this allows to create an empty but valid list object, comparable to using QDBusDataList(QDBusData::Type) with QDBusData::UInt32

Parameters:
other the QValueList of unsigned 32-bit integer values to copy from
See also:
toUInt32List()
QDBusDataList::QDBusDataList ( const QValueList< Q_INT64 > &  other  ) 

Creates a list from the given QValueList of signed 64-bit integer values.

Type information for the list object will be set to QDBusData::Int64 also when the other list is empty, i.e. this allows to create an empty but valid list object, comparable to using QDBusDataList(QDBusData::Type) with QDBusData::Int64

Parameters:
other the QValueList of signed 64-bit integer values to copy from
See also:
toInt64List()
QDBusDataList::QDBusDataList ( const QValueList< Q_UINT64 > &  other  ) 

Creates a list from the given QValueList of unsigned 64-bit integer values.

Type information for the list object will be set to QDBusData::UInt64 also when the other list is empty, i.e. this allows to create an empty but valid list object, comparable to using QDBusDataList(QDBusData::Type) with QDBusData::UInt64

Parameters:
other the QValueList of unsigned 64-bit integer values to copy from
See also:
toUInt64List()
QDBusDataList::QDBusDataList ( const QValueList< double > &  other  ) 

Creates a list from the given QValueList of double values.

Type information for the list object will be set to QDBusData::Double also when the other list is empty, i.e. this allows to create an empty but valid list object, comparable to using QDBusDataList(QDBusData::Type) with QDBusData::Double

Parameters:
other the QValueList of double values to copy from
See also:
toDoubleList()
QDBusDataList::QDBusDataList ( const QValueList< QDBusVariant > &  other  ) 

Creates a list from the given QValueList of QDBusVariant values.

Type information for the list object will be set to QDBusData::Variant also when the other list is empty, i.e. this allows to create an empty but valid list object, comparable to using QDBusDataList(QDBusData::Type) with QDBusData::Variant

Parameters:
other the QValueList of variant values to copy from
See also:
toVariantList()
QDBusDataList::QDBusDataList ( const QStringList &  other  ) 

Creates a list from the given QStringList's values.

Type information for the list object will be set to QDBusData::String also when the other list is empty, i.e. this allows to create an empty but valid list object, comparable to using QDBusDataList(QDBusData::Type) with QDBusData::String

Parameters:
other the QStringList to copy from
See also:
toQStringList()
QDBusDataList::QDBusDataList ( const QValueList< QDBusObjectPath > &  other  ) 

Creates a list from the given QValueList of object path values.

Type information for the list object will be set to QDBusData::ObjectPath also when the other list is empty, i.e. this allows to create an empty but valid list object, comparable to using QDBusDataList(QDBusData::Type) with QDBusData::ObjectPath

Parameters:
other the QValueList of object path values to copy from
See also:
toObjectPathList()
QDBusDataList::~QDBusDataList (  ) 

Destroys the list object.


Member Function Documentation

void QDBusDataList::clear (  ) 

Clears the list.

Type and, if applicable, container element type will stay untouched.

QDBusData QDBusDataList::containerItemType (  )  const

Returns a container prototype for the list's element type.

Lists which have containers as their elements, i.e. hasContainerItemType() returns true this will actually specify the details for the use container, i.e. the returned data object can be queried for type and possible further subtypes.

Returns:
a data object detailing the element type or an invalid data object if the list does not have a container as its element type
See also:
QDBusDataList(const QDBusData&);
type()
QDBusData::Invalid
uint QDBusDataList::count (  )  const

Returns the number of elements of this list object.

Returns:
the number of elements
See also:
isEmpty()
Examples:
example-service.cpp.
bool QDBusDataList::hasContainerItemType (  )  const

Checks whether the element type is a data container itself.

If the elements of the list are containers as well, this will return true In this case containerItemType() will return a prototype for such a container.

Returns:
true if the element type is either QDBusData::Map, QDBusData::List or QDBusData::Struct, otherwise false
See also:
QDBusDataList(const QDBusData&)
bool QDBusDataList::isEmpty (  )  const

Checks whether this list object has any elements.

Returns:
true if there are no elements in this list, otherwise false
See also:
count()
bool QDBusDataList::isValid (  )  const [inline]

Checks whether this list object has a valid element type.

This is equal to checking type() for not being QDBusData::Invalid

Returns:
true if the list object is valid, otherwise false

References QDBusData::Invalid.

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

Checks whether the given other list is different from this one.

Two lists are considered different when they have the different type (or different container item type if the have one) or the element lists are equal are different.

Parameters:
other the other list object to compare with
Returns:
true if the lists are different, otherwise false
See also:
QDBusData::operator!=()
QDBusDataList& QDBusDataList::operator<< ( const QDBusData data  ) 

Appends a given value to the list.

Basically works like the respective QValueList operator, but checks if type of the new value matches the type of the list. Lists that are invalid will accept any new type and will then be typed accordingly.

If data is invalid itself, it will not be appended at any time.

Note:
the more common use case is to work with a QValueList and then use the respective constructor to create the QDBusDataList object
Parameters:
data the data item to append to the list
Returns:
a reference to this list object
QDBusDataList& QDBusDataList::operator= ( const QStringList &  other  ) 

Copies from the given other list.

Convenience overload as QStringList is a very common data type in Qt and D-Bus methods also use "arrays of strings" quite often.

The list object's type will be set to QDBusData::String. If the object previously had a container as its element type, this will be reset, i.e. hasContainerItemType() will return false

Parameters:
other the stringlist to copy from
Returns:
a reference to this list object
QDBusDataList& QDBusDataList::operator= ( const QValueList< QDBusData > &  other  ) 

Copies from the given other list.

This behaves basically like copying a QValueList through its assignment operator, i.e. no value are actually copied at this time.

Warning:
the elements of the given other list have to be of the same type. If they aren't this list's content will cleared and the type will be set to QDBusData::Invalid
Parameters:
other the other list object to copy from
Returns:
a reference to this list object
QDBusDataList& QDBusDataList::operator= ( const QDBusDataList other  ) 

Copies from the given other list.

This behaves basically like copying a QValueList through its assignment operator, i.e. no value are actually copied at this time.

Parameters:
other the other list object to copy from
Returns:
a reference to this list object
bool QDBusDataList::operator== ( const QDBusDataList other  )  const

Checks whether the given other list is equal to this one.

Two lists are considered equal when they have the same type (and same container item type if the have one) and the element lists are equal as well.

Parameters:
other the other list object to compare with
Returns:
true if the lists are equal, otherwise false
See also:
QDBusData::operator==()
QValueList<bool> QDBusDataList::toBoolList ( bool *  ok = 0  )  const

Tries to get the list object's elements as a QValueList of bool.

This is a convenience overload for the case when the list is of type QDBusData::Bool.

Parameters:
ok optional pointer to a bool variable to store the success information in, i.e. will be set to true on success and to false if the conversion failed (not of type QDBusData::Bool)
Returns:
a QValueList of bool containing the list object's boolean elements or an empty list when converting fails
See also:
QDBusData::toBool()
QValueList<Q_UINT8> QDBusDataList::toByteList ( bool *  ok = 0  )  const

Tries to get the list object's elements as a QValueList of Q_UINT8.

This is a convenience overload for the case when the list is of type QDBusData::Byte.

Parameters:
ok optional pointer to a bool variable to store the success information in, i.e. will be set to true on success and to false if the conversion failed (not of type QDBusData::Byte)
Returns:
a QValueList of Q_UINT8 containing the list object's byte elements or an empty list when converting fails
See also:
QDBusData::toByte()
QValueList<double> QDBusDataList::toDoubleList ( bool *  ok = 0  )  const

Tries to get the list object's elements as a QValueList of double.

This is a convenience overload for the case when the list is of type QDBusData::Double.

Parameters:
ok optional pointer to a bool variable to store the success information in, i.e. will be set to true on success and to false if the conversion failed (not of type QDBusData::Double)
Returns:
a QValueList of double containing the list object's double elements or an empty list when converting fails
See also:
QDBusData::toDouble()
QValueList<Q_INT16> QDBusDataList::toInt16List ( bool *  ok = 0  )  const

Tries to get the list object's elements as a QValueList of Q_INT16.

This is a convenience overload for the case when the list is of type QDBusData::Int16.

Parameters:
ok optional pointer to a bool variable to store the success information in, i.e. will be set to true on success and to false if the conversion failed (not of type QDBusData::Int16)
Returns:
a QValueList of Q_INT16 containing the list object's signed 16-bit integer elements or an empty list when converting fails
See also:
QDBusData::toInt16()
QValueList<Q_INT32> QDBusDataList::toInt32List ( bool *  ok = 0  )  const

Tries to get the list object's elements as a QValueList of Q_INT32.

This is a convenience overload for the case when the list is of type QDBusData::Int32.

Parameters:
ok optional pointer to a bool variable to store the success information in, i.e. will be set to true on success and to false if the conversion failed (not of type QDBusData::Int32)
Returns:
a QValueList of Q_INT32 containing the list object's signed 32-bit integer elements or an empty list when converting fails
See also:
QDBusData::toInt32()
QValueList<Q_INT64> QDBusDataList::toInt64List ( bool *  ok = 0  )  const

Tries to get the list object's elements as a QValueList of Q_INT64.

This is a convenience overload for the case when the list is of type QDBusData::Int64.

Parameters:
ok optional pointer to a bool variable to store the success information in, i.e. will be set to true on success and to false if the conversion failed (not of type QDBusData::Int64)
Returns:
a QValueList of Q_INT64 containing the list object's signed 64-bit integer elements or an empty list when converting fails
See also:
QDBusData::toInt64()
QValueList<QDBusObjectPath> QDBusDataList::toObjectPathList ( bool *  ok = 0  )  const

Tries to get the list object's elements as a QValueList of object paths.

Parameters:
ok optional pointer to a bool variable to store the success information in, i.e. will be set to true on success and to false if the conversion failed (not of type QDBusData::ObjectPath)
Returns:
a QValueList of object paths containing the list object's object path elements or an empty list when converting fails
See also:
QDBusData::toObjectPath()
QStringList QDBusDataList::toQStringList ( bool *  ok = 0  )  const

Tries to get the list object's elements as a QStringList.

This is a convenience overload for the case when the list is of type QDBusData::String.

Parameters:
ok optional pointer to a bool variable to store the success information in, i.e. will be set to true on success and to false if the conversion failed (not of type QDBusData::String)
Returns:
a QStringList containing the list object's string elements or an empty list when converting fails
See also:
toStringList()
QDBusData::toString()
Examples:
example-client.cpp, and example-service.cpp.
QValueList<QDBusData> QDBusDataList::toQValueList (  )  const

Converts the list object into a QValueList with QDBusData elements.

Returns:
the values of the list object as a QValueList
QValueList<QString> QDBusDataList::toStringList ( bool *  ok = 0  )  const

Tries to get the list object's elements as a QValueList of QString.

This is a convenience overload for the case when the list is of type QDBusData::String, see also toQStringList().

Parameters:
ok optional pointer to a bool variable to store the success information in, i.e. will be set to true on success and to false if the conversion failed (not of type QDBusData::String)
Returns:
a QValueList of QString containing the list object's string elements or an empty list when converting fails
See also:
QDBusData::toString()
QValueList<Q_UINT16> QDBusDataList::toUInt16List ( bool *  ok = 0  )  const

Tries to get the list object's elements as a QValueList of Q_UINT16.

This is a convenience overload for the case when the list is of type QDBusData::UInt16.

Parameters:
ok optional pointer to a bool variable to store the success information in, i.e. will be set to true on success and to false if the conversion failed (not of type QDBusData::UInt16)
Returns:
a QValueList of Q_UINT16 containing the list object's unsigned 16-bit integer elements or an empty list when converting fails
See also:
QDBusData::toUInt16()
QValueList<Q_UINT32> QDBusDataList::toUInt32List ( bool *  ok = 0  )  const

Tries to get the list object's elements as a QValueList of Q_UINT32.

This is a convenience overload for the case when the list is of type QDBusData::UInt32.

Parameters:
ok optional pointer to a bool variable to store the success information in, i.e. will be set to true on success and to false if the conversion failed (not of type QDBusData::UInt32)
Returns:
a QValueList of Q_UINT32 containing the list object's unsigned 32-bit integer elements or an empty list when converting fails
See also:
QDBusData::toUInt32()
QValueList<Q_UINT64> QDBusDataList::toUInt64List ( bool *  ok = 0  )  const

Tries to get the list object's elements as a QValueList of Q_UINT64.

This is a convenience overload for the case when the list is of type QDBusData::UInt64.

Parameters:
ok optional pointer to a bool variable to store the success information in, i.e. will be set to true on success and to false if the conversion failed (not of type QDBusData::UInt64)
Returns:
a QValueList of Q_UINT64 containing the list object's unsigned 64-bit integer elements or an empty list when converting fails
See also:
QDBusData::toUInt64()
QValueList<QDBusVariant> QDBusDataList::toVariantList ( bool *  ok = 0  )  const

Tries to get the list object's elements as a QValueList of QDBusVariant.

This is a convenience overload for the case when the list is of type QDBusData::Variant.

Parameters:
ok optional pointer to a bool variable to store the success information in, i.e. will be set to true on success and to false if the conversion failed (not of type QDBusData::Variant)
Returns:
a QValueList of QDBusVariant containing the list object's QDBusVariant elements or an empty list when converting fails
See also:
QDBusData::toVariant()
QDBusData::Type QDBusDataList::type (  )  const

Returns the element type of the list object.

Returns:
one of the values of the QDBusData::Type enum
See also:
hasContainerItemType()
containerItemType()
Examples:
example-client.cpp, and example-service.cpp.

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

Generated by  doxygen 1.6.2