Class to transport lists of D-Bus data types. More...
#include <qdbusdatalist.h>
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. | |
QDBusDataList & | operator= (const QDBusDataList &other) |
Copies from the given other list. | |
QDBusDataList & | operator= (const QValueList< QDBusData > &other) |
Copies from the given other list. | |
QDBusDataList & | operator= (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. | |
QDBusDataList & | operator<< (const QDBusData &data) |
Appends a given value to the list. | |
QValueList< QDBusData > | toQValueList () 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< QDBusObjectPath > | toObjectPathList (bool *ok=0) const |
Tries to get the list object's elements as a QValueList of object paths. | |
QValueList< QDBusVariant > | toVariantList (bool *ok=0) const |
Tries to get the list object's elements as a QValueList of QDBusVariant. |
Class to transport lists of D-Bus data types.
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);
QDBusDataList::QDBusDataList | ( | ) |
Creates an empty and invalid list.
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&);
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);
containerItemType | the type of the elements in the new list |
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.
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.
other
list do not all have the same type, the list object will also be empty and invalidother | the QValueList of QDBusData objects to copy from |
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
other | the QValueList of boolean values to copy from |
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
other | the QValueList of byte (unsigned char) values to copy from |
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
other | the QValueList of signed 16-bit integer values to copy from |
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
other | the QValueList of unsigned 16-bit integer values to copy from |
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
other | the QValueList of signed 32-bit integer values to copy from |
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
other | the QValueList of unsigned 32-bit integer values to copy from |
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
other | the QValueList of signed 64-bit integer values to copy from |
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
other | the QValueList of unsigned 64-bit integer values to copy from |
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
other | the QValueList of double values to copy from |
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
other | the QValueList of variant values to copy from |
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
other | the QStringList to copy from |
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
other | the QValueList of object path values to copy from |
QDBusDataList::~QDBusDataList | ( | ) |
Destroys the list object.
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.
uint QDBusDataList::count | ( | ) | const |
Returns the number of elements of this list object.
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.
true
if the element type is either QDBusData::Map, QDBusData::List or QDBusData::Struct, otherwise false
bool QDBusDataList::isEmpty | ( | ) | const |
Checks whether this list object has any elements.
true
if there are no elements in this list, otherwise false
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
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.
other | the other list object to compare with |
true
if the lists are different, otherwise false
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.
data | the data item to append to the list |
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
other | the stringlist to copy from |
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.
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::Invalidother | the other list object to copy from |
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.
other | the other list object to copy from |
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.
other | the other list object to compare with |
true
if the lists are equal, otherwise false
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.
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) |
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.
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) |
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.
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) |
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.
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) |
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.
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) |
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.
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) |
QValueList<QDBusObjectPath> QDBusDataList::toObjectPathList | ( | bool * | ok = 0 |
) | const |
Tries to get the list object's elements as a QValueList of object paths.
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) |
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.
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) |
QValueList<QDBusData> QDBusDataList::toQValueList | ( | ) | const |
Converts the list object into a QValueList with QDBusData elements.
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().
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) |
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.
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) |
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.
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) |
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.
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) |
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.
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) |
QDBusData::Type QDBusDataList::type | ( | ) | const |
Returns the element type of the list object.