Class to transport maps of D-Bus data types. More...
#include <qdbusdatamap.h>
Public Types | |
typedef QMapConstIterator< T, QDBusData > | const_iterator |
Public Member Functions | |
QDBusDataMap () | |
Creates an empty and invalid map. | |
QDBusDataMap (QDBusData::Type simpleValueType) | |
Creates an empty map with the given simple type for values. | |
QDBusDataMap (const QDBusData &containerValueType) | |
Creates an empty map with the given container type for values. | |
QDBusDataMap (const QDBusDataMap< T > &other) | |
Creates a map from the given other map. | |
QDBusDataMap (const QMap< T, QDBusData > &other) | |
Creates a map from the given QMap of QDBusData objects. | |
QDBusDataMap (const QMap< T, bool > &other) | |
Creates a list from the given QMap of boolean values. | |
QDBusDataMap (const QMap< T, Q_UINT8 > &other) | |
Creates a map from the given QMap of byte (unsigned char) values. | |
QDBusDataMap (const QMap< T, Q_INT16 > &other) | |
Creates a map from the given QMap of signed 16-bit integer values. | |
QDBusDataMap (const QMap< T, Q_UINT16 > &other) | |
Creates a map from the given QMap of unsigned 16-bit integer values. | |
QDBusDataMap (const QMap< T, Q_INT32 > &other) | |
Creates a map from the given QMap of signed 32-bit integer values. | |
QDBusDataMap (const QMap< T, Q_UINT32 > &other) | |
Creates a map from the given QMap of unsigned 32-bit integer values. | |
QDBusDataMap (const QMap< T, Q_INT64 > &other) | |
Creates a map from the given QMap of signed 64-bit integer values. | |
QDBusDataMap (const QMap< T, Q_UINT64 > &other) | |
Creates a map from the given QMap of unsigned 64-bit integer values. | |
QDBusDataMap (const QMap< T, double > &other) | |
Creates a map from the given QMap of double values. | |
QDBusDataMap (const QMap< T, QString > &other) | |
Creates a map from the given QMap of QString values. | |
QDBusDataMap (const QMap< T, QDBusObjectPath > &other) | |
Creates a map from the given QMap of object path values. | |
QDBusDataMap (const QMap< T, QDBusVariant > &other) | |
Creates a map from the given QMap of QDBusVariant values. | |
QDBusDataMap< T > & | operator= (const QDBusDataMap< T > &other) |
Copies from the given other map. | |
QDBusDataMap< T > & | operator= (const QMap< T, QDBusData > &other) |
Copies from the given other map. | |
QDBusData::Type | keyType () const |
Returns the key type of the map object. | |
QDBusData::Type | valueType () const |
Returns the value type of the map object. | |
bool | hasContainerValueType () const |
Checks whether the value type is a data container itself. | |
QDBusData | containerValueType () const |
Returns a container prototype for the map's value type. | |
bool | isValid () const |
Checks whether this map object has a valid value type. | |
bool | isEmpty () const |
Checks whether this map object has any key/value pairs. | |
uint | count () const |
Returns the number of key/value pairs of this map object. | |
bool | operator== (const QDBusDataMap< T > &other) const |
Checks whether the given other map is equal to this one. | |
void | clear () |
Clears the map. | |
const_iterator | begin () const |
Returns an iterator to the first item according to the key sort order. | |
const_iterator | end () const |
Returns an iterator to an invalid position. | |
bool | insert (const T &key, const QDBusData &data) |
Inserts a given value for a given key. | |
QMap< T, QDBusData > | toQMap () const |
Converts the map object into a QMap with QDBusData elements. | |
QMap< T, bool > | toBoolMap (bool *ok=0) const |
Tries to get the map object's pairs as a QMap of bool. | |
QMap< T, Q_UINT8 > | toByteMap (bool *ok=0) const |
Tries to get the map object's pairs as a QMap of Q_UINT8. | |
QMap< T, Q_INT16 > | toInt16Map (bool *ok=0) const |
Tries to get the map object's pairs as a QMap of Q_INT16. | |
QMap< T, Q_UINT16 > | toUInt16Map (bool *ok=0) const |
Tries to get the map object's pairs as a QMap of Q_UINT16. | |
QMap< T, Q_INT32 > | toInt32Map (bool *ok=0) const |
Tries to get the map object's pairs as a QMap of Q_INT32. | |
QMap< T, Q_UINT32 > | toUInt32Map (bool *ok=0) const |
Tries to get the map object's pairs as a QMap of Q_UINT32. | |
QMap< T, Q_INT64 > | toInt64Map (bool *ok=0) const |
Tries to get the map object's pairs as a QMap of Q_INT64. | |
QMap< T, Q_UINT64 > | toUInt64Map (bool *ok=0) const |
Tries to get the map object's pairs as a QMap of Q_UINT64. | |
QMap< T, double > | toDoubleMap (bool *ok=0) const |
Tries to get the map object's pairs as a QMap of double. | |
QMap< T, QString > | toStringMap (bool *ok=0) const |
Tries to get the map object's pairs as a QMap of QString. | |
QMap< T, QDBusObjectPath > | toObjectPathMap (bool *ok=0) const |
Tries to get the map object's pairs as a QMap of object paths. | |
QMap< T, QDBusVariant > | toVariantMap (bool *ok=0) const |
Tries to get the map object's pairs as a QMap of QDBusVariant. | |
Friends | |
class | QDBusData |
Class to transport maps of D-Bus data types.
dict
this bindings use the term map
since QDBusDataMap is essentially a QMapThere are basically two ways to create QDBusDataMap objects:
Example for creating a filled map from content
QMap<Q_INT16, QString> intToStringMap; map.insert(2, "two"); map.insert(3, "three"); map.insert(5, "five"); map.insert(7, "seven"); QDBusDataMap<Q_INT16> dbusMap(intToStringMap); QDBusData data = QDBusData::fromInt16KeyMap(dbusMap); // or even shorter, using implicit conversion QDBusData other = QDBusData::fromInt16KeyMap(intList);
Example for creating an empty map
// empty map for a simple type, mapping from QString to double QDBusDataMap<QString> list(QDBusData::Double); // empty map for value type string lists QDBusData valueType = QDBusData::fromList(QDBusDataList(QDBusData::String)); QDBusDataMap<QString> map(valueType);
typedef QMapConstIterator<T, QDBusData> QDBusDataMap< T >::const_iterator |
Constant iterator. A QMapConstIterator with value type specified as QDBusData
QDBusDataMap< T >::QDBusDataMap | ( | ) | [inline] |
Creates an empty and invalid map.
QDBusDataMap< T >::QDBusDataMap | ( | QDBusData::Type | simpleValueType | ) | [inline, explicit] |
Creates an empty map with the given simple type for values.
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 map with elements which are containers themselves, use QDBusDataMap<T>(const QDBusData&);
simpleValueType | the type of the values in the new map |
QDBusDataMap< T >::QDBusDataMap | ( | const QDBusData & | containerValueType | ) | [inline, explicit] |
Creates an empty map with the given container type for values.
For creating a map with simple values you can also use QDBusDataMap<T>(QDBusData::Type);
containerValueType | the type of the values in the new map |
QDBusDataMap< T >::QDBusDataMap | ( | const QDBusDataMap< T > & | other | ) | [inline] |
Creates a map from the given other
map.
This behaves basically like copying a QMap through its copy constructor, i.e. no value are actually copied at this time.
other | the other map object to copy from |
QDBusDataMap< T >::QDBusDataMap | ( | const QMap< T, QDBusData > & | other | ) | [inline] |
Creates a map from the given QMap of QDBusData objects.
If the other
map is empty, this will behave like QDBusDataMap<T>(), i.e. create an empty and invalid map object.
Type information for the map object, i.e. value type and, if applicable, container value type, will be derived from the other
map's elements.
other
map do not all have the same type, the map object will also be empty and invalidother | the QMap of QDBusData objects to copy from |
QDBusDataMap< T >::QDBusDataMap | ( | const QMap< T, bool > & | other | ) | [inline] |
Creates a list from the given QMap of boolean values.
Type information for the map object will be set to QDBusData::Bool also when the other
map is empty, i.e. this allows to create an empty but valid map object, comparable to using QDBusDataMap<T>(QDBusData::Type) with QDBusData::Bool
other | the QMap of boolean values to copy from |
QDBusDataMap< T >::QDBusDataMap | ( | const QMap< T, Q_UINT8 > & | other | ) | [inline] |
Creates a map from the given QMap of byte (unsigned char) values.
Type information for the map object will be set to QDBusData::Byte also when the other
map is empty, i.e. this allows to create an empty but valid map object, comparable to using QDBusDataMap<T>(QDBusData::Type) with QDBusData::Byte
other | the QMap of byte (unsigned char) values to copy from |
QDBusDataMap< T >::QDBusDataMap | ( | const QMap< T, Q_INT16 > & | other | ) | [inline] |
Creates a map from the given QMap of signed 16-bit integer values.
Type information for the map object will be set to QDBusData::Int16 also when the other
map is empty, i.e. this allows to create an empty but valid map object, comparable to using QDBusDataMap<T>(QDBusData::Type) with QDBusData::Int16
other | the QMap of signed 16-bit integer values to copy from |
QDBusDataMap< T >::QDBusDataMap | ( | const QMap< T, Q_UINT16 > & | other | ) | [inline] |
Creates a map from the given QMap of unsigned 16-bit integer values.
Type information for the map object will be set to QDBusData::UInt16 also when the other
map is empty, i.e. this allows to create an empty but valid map object, comparable to using QDBusDataMap<T>(QDBusData::Type) with QDBusData::UInt16
other | the QMap of unsigned 16-bit integer values to copy from |
QDBusDataMap< T >::QDBusDataMap | ( | const QMap< T, Q_INT32 > & | other | ) | [inline] |
Creates a map from the given QMap of signed 32-bit integer values.
Type information for the map object will be set to QDBusData::Int32 also when the other
map is empty, i.e. this allows to create an empty but valid map object, comparable to using QDBusDataMap<T>(QDBusData::Type) with QDBusData::Int32
other | the QMap of signed 32-bit integer values to copy from |
QDBusDataMap< T >::QDBusDataMap | ( | const QMap< T, Q_UINT32 > & | other | ) | [inline] |
Creates a map from the given QMap of unsigned 32-bit integer values.
Type information for the map object will be set to QDBusData::UInt16 also when the other
map is empty, i.e. this allows to create an empty but valid map object, comparable to using QDBusDataMap<T>(QDBusData::Type) with QDBusData::UInt32
other | the QMap of unsigned 32-bit integer values to copy from |
QDBusDataMap< T >::QDBusDataMap | ( | const QMap< T, Q_INT64 > & | other | ) | [inline] |
Creates a map from the given QMap of signed 64-bit integer values.
Type information for the map object will be set to QDBusData::Int64 also when the other
map is empty, i.e. this allows to create an empty but valid map object, comparable to using QDBusDataMap<T>(QDBusData::Type) with QDBusData::Int64
other | the QMap of signed 64-bit integer values to copy from |
QDBusDataMap< T >::QDBusDataMap | ( | const QMap< T, Q_UINT64 > & | other | ) | [inline] |
Creates a map from the given QMap of unsigned 64-bit integer values.
Type information for the map object will be set to QDBusData::UInt64 also when the other
map is empty, i.e. this allows to create an empty but valid map object, comparable to using QDBusDataMap<T>(QDBusData::Type) with QDBusData::UInt64
other | the QMap of unsigned 64-bit integer values to copy from |
QDBusDataMap< T >::QDBusDataMap | ( | const QMap< T, double > & | other | ) | [inline] |
Creates a map from the given QMap of double values.
Type information for the map object will be set to QDBusData::Double also when the other
map is empty, i.e. this allows to create an empty but valid map object, comparable to using QDBusDataMap<T>(QDBusData::Type) with QDBusData::Double
other | the QMap of double values to copy from |
QDBusDataMap< T >::QDBusDataMap | ( | const QMap< T, QString > & | other | ) | [inline] |
Creates a map from the given QMap of QString values.
Type information for the map object will be set to QDBusData::String also when the other
map is empty, i.e. this allows to create an empty but valid map object, comparable to using QDBusDataMap<T>(QDBusData::Type) with QDBusData::String
other | the QMap of QString values to copy from |
QDBusDataMap< T >::QDBusDataMap | ( | const QMap< T, QDBusObjectPath > & | other | ) | [inline] |
Creates a map from the given QMap of object path values.
Type information for the map object will be set to QDBusData::ObjectPath also when the other
map is empty, i.e. this allows to create an empty but valid map object, comparable to using QDBusDataMap<T>(QDBusData::Type) with QDBusData::ObjectPath
other | the QMap of object path values to copy from |
QDBusDataMap< T >::QDBusDataMap | ( | const QMap< T, QDBusVariant > & | other | ) | [inline] |
Creates a map from the given QMap of QDBusVariant values.
Type information for the map object will be set to QDBusData::Variant also when the other
map is empty, i.e. this allows to create an empty but valid map object, comparable to using QDBusDataMap<T>(QDBusData::Type) with QDBusData::Variant
other | the QMap of variant values to copy from |
const_iterator QDBusDataMap< T >::begin | ( | ) | const [inline] |
Returns an iterator to the first item according to the key sort order.
Referenced by QDBusDataMap< T >::operator==().
void QDBusDataMap< T >::clear | ( | ) | [inline] |
Clears the map.
Value type and, if applicable, container value type will stay untouched.
QDBusData QDBusDataMap< T >::containerValueType | ( | ) | const [inline] |
Returns a container prototype for the map's value type.
Lists which have containers as their elements, i.e. hasContainerValueType() 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 QDBusDataMap< T >::count | ( | ) | const [inline] |
Returns the number of key/value pairs of this map object.
Referenced by QDBusDataMap< T >::operator==().
const_iterator QDBusDataMap< T >::end | ( | ) | const [inline] |
Returns an iterator to an invalid position.
Referenced by QDBusDataMap< T >::operator==().
bool QDBusDataMap< T >::hasContainerValueType | ( | ) | const [inline] |
Checks whether the value type is a data container itself.
If the value of the map are containers as well, this will return true
In this case containerValueType() will return a prototype for such a container.
true
if the value type is either QDBusData::Map, QDBusData::List or QDBusData::Struct, otherwise false
References QDBusData::List, QDBusData::Map, and QDBusData::Struct.
Referenced by QDBusDataMap< T >::operator==().
bool QDBusDataMap< T >::insert | ( | const T & | key, | |
const QDBusData & | data | |||
) | [inline] |
Inserts a given value for a given key.
Basically works like the respective QMap method, but checks if type of the new value matches the value type of the list. Maps that are invalid will accept any new type and will then be typed accordingly.
If data
is invalid itself, it will not be inserted at any time.
key | the key were to insert into the map | |
data | the data item to insert into the map |
true
on successfull insert, otherwise false
References QDBusData::buildDBusSignature(), QDBusData::Invalid, QDBusData::type(), and QDBusData::typeName().
bool QDBusDataMap< T >::isEmpty | ( | ) | const [inline] |
Checks whether this map object has any key/value pairs.
true
if there are no key/values in this map, otherwise false
bool QDBusDataMap< T >::isValid | ( | ) | const [inline] |
Checks whether this map object has a valid value type.
This is equal to checking valueType() for not being QDBusData::Invalid
true
if the map object is valid, otherwise false
References QDBusData::Invalid.
QDBusData::Type QDBusDataMap< T >::keyType | ( | ) | const [inline] |
Returns the key type of the map object.
QDBusDataMap<T>& QDBusDataMap< T >::operator= | ( | const QMap< T, QDBusData > & | other | ) | [inline] |
Copies from the given other
map.
This behaves basically like copying a QMap through its assignment operator, i.e. no value are actually copied at this time.
other
map have to be of the same type. If they aren't this maps's content will cleared and the value type will be set to QDBusData::Invalidother | the other map object to copy from |
References QDBusData::Invalid, QDBusData::operator=(), and QDBusData::QDBusData().
QDBusDataMap<T>& QDBusDataMap< T >::operator= | ( | const QDBusDataMap< T > & | other | ) | [inline] |
Copies from the given other
map.
This behaves basically like copying a QMap through its assignment operator, i.e. no value are actually copied at this time.
other | the other map object to copy from |
References QDBusData::operator=().
bool QDBusDataMap< T >::operator== | ( | const QDBusDataMap< T > & | other | ) | const [inline] |
Checks whether the given other
map is equal to this one.
Two maps are considered equal when they have the same value type (and same container value type if the have one) and the key/value pairs are equal as well.
other | the other map object to compare with |
true
if the maps are equal, otherwise false
References QDBusDataMap< T >::begin(), QDBusData::buildDBusSignature(), QDBusDataMap< T >::count(), QDBusDataMap< T >::end(), and QDBusDataMap< T >::hasContainerValueType().
QMap<T, bool> QDBusDataMap< T >::toBoolMap | ( | bool * | ok = 0 |
) | const [inline] |
Tries to get the map object's pairs as a QMap of bool.
This is a convenience overload for the case when the map is of value 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 value type QDBusData::Bool) |
References QDBusData::Bool.
QMap<T, Q_UINT8> QDBusDataMap< T >::toByteMap | ( | bool * | ok = 0 |
) | const [inline] |
Tries to get the map object's pairs as a QMap of Q_UINT8.
This is a convenience overload for the case when the map is of value 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 value type QDBusData::Byte) |
References QDBusData::Byte.
QMap<T, double> QDBusDataMap< T >::toDoubleMap | ( | bool * | ok = 0 |
) | const [inline] |
Tries to get the map object's pairs as a QMap of double.
This is a convenience overload for the case when the map is of value 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 value type QDBusData::Double) |
References QDBusData::Double.
QMap<T, Q_INT16> QDBusDataMap< T >::toInt16Map | ( | bool * | ok = 0 |
) | const [inline] |
Tries to get the map object's pairs as a QMap of Q_INT16.
This is a convenience overload for the case when the map is of value 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 value type QDBusData::Int16) |
References QDBusData::Int16.
QMap<T, Q_INT32> QDBusDataMap< T >::toInt32Map | ( | bool * | ok = 0 |
) | const [inline] |
Tries to get the map object's pairs as a QMap of Q_INT32.
This is a convenience overload for the case when the map is of value 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 value type QDBusData::Int32) |
References QDBusData::Int32.
QMap<T, Q_INT64> QDBusDataMap< T >::toInt64Map | ( | bool * | ok = 0 |
) | const [inline] |
Tries to get the map object's pairs as a QMap of Q_INT64.
This is a convenience overload for the case when the map is of value 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 value type QDBusData::Int64) |
References QDBusData::Int64.
QMap<T, QDBusObjectPath> QDBusDataMap< T >::toObjectPathMap | ( | bool * | ok = 0 |
) | const [inline] |
Tries to get the map object's pairs as a QMap 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 value type QDBusData::ObjectPath) |
References QDBusData::ObjectPath.
QMap<T, QDBusData> QDBusDataMap< T >::toQMap | ( | ) | const [inline] |
Converts the map object into a QMap with QDBusData elements.
QMap<T, QString> QDBusDataMap< T >::toStringMap | ( | bool * | ok = 0 |
) | const [inline] |
Tries to get the map object's pairs as a QMap of QString.
This is a convenience overload for the case when the map is of value 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 value type QDBusData::String) |
References QDBusData::String.
QMap<T, Q_UINT16> QDBusDataMap< T >::toUInt16Map | ( | bool * | ok = 0 |
) | const [inline] |
Tries to get the map object's pairs as a QMap of Q_UINT16.
This is a convenience overload for the case when the map is of value 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 value type QDBusData::UInt16) |
References QDBusData::UInt16.
QMap<T, Q_UINT32> QDBusDataMap< T >::toUInt32Map | ( | bool * | ok = 0 |
) | const [inline] |
Tries to get the map object's pairs as a QMap of Q_UINT32.
This is a convenience overload for the case when the map is of value 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 value type QDBusData::UInt32) |
References QDBusData::UInt32.
QMap<T, Q_UINT64> QDBusDataMap< T >::toUInt64Map | ( | bool * | ok = 0 |
) | const [inline] |
Tries to get the map object's pairs as a QMap of Q_UINT64.
This is a convenience overload for the case when the map is of value 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 value type QDBusData::UInt64) |
References QDBusData::UInt64.
QMap<T, QDBusVariant> QDBusDataMap< T >::toVariantMap | ( | bool * | ok = 0 |
) | const [inline] |
Tries to get the map object's pairs as a QMap of QDBusVariant.
This is a convenience overload for the case when the map is of value 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 value type QDBusData::Variant) |
References QDBusData::Variant.
QDBusData::Type QDBusDataMap< T >::valueType | ( | ) | const [inline] |
Returns the value type of the map object.