edelib
2.1.0
|
Dictionary container for D-Bus types. More...
#include <edelib/EdbusDict.h>
Public Types | |
typedef EdbusContainer < EdbusDictEntry > ::const_iterator | const_iterator |
Public Types inherited from EdbusContainer< EdbusDictEntry > | |
typedef list< EdbusDictEntry > ::iterator | iterator |
typedef list< EdbusDictEntry > ::const_iterator | const_iterator |
Public Member Functions | |
void | append (const EdbusData &key, const EdbusData &value) |
void | clear (void) |
void | remove (const EdbusData &key) |
EdbusData | find (const EdbusData &key) |
bool | operator== (const EdbusDict &other) |
bool | operator!= (const EdbusDict &other) |
EdbusDataType | key_type (void) |
EdbusDataType | value_type (void) |
bool | value_type_is_container (void) |
const_iterator | begin (void) const |
const_iterator | end (void) const |
unsigned int | size (void) const |
Additional Inherited Members | |
Protected Member Functions inherited from EdbusContainer< EdbusDictEntry > | |
void | dispose (void) |
void | unhook (void) |
EdbusContainer () | |
EdbusContainer (const EdbusContainer &other) | |
~EdbusContainer () | |
EdbusContainer & | operator= (const EdbusContainer &other) |
Protected Attributes inherited from EdbusContainer< EdbusDictEntry > | |
EdbusContainerPrivate * | impl |
Dictionary container for D-Bus types.
EdbusDict is a dictionary container (or map in STL). Data is stored in key//value pairs so data search and fetching is done via it's key association.
Stored data will be unique by key: if you add key//value pair and later add another pair with already added key (or to use better term: assign a new value with aleady known key), previous value will be overriden.
Class use implicit sharing.
EdbusDict uses EdbusData as base type which means you can put any type EdbusData can hold as value. On other hand, D-Bus specification restricts key types to be only basic D-Bus types (
If you try to add non-basic D-Bus type as key, it will be ignored.
Each instance of EdbusDict object will have the same types for the keys and the same types for the values. This means that if you add in freshly created EdbusDict object a key as int32_t and value as string, all further adding is expecting that types too. On other hand, if you try to add a key with different type (in dict that already have few keys with e.g. int32_t), entry (key and value) will be ignored.
This will summarize the thing:
Besides using find() to get a content, you can use iterator too.
This is a sample of listing dict content, without type checks:
Declares EdbusDict iterator
Assign value with the key and add it. If key already exists, previous value will be overriden with the new one.
key | is key in basic D-Bus type |
value | is any value EdbusData can hold |
const_iterator begin | ( | void | ) | const |
Returns iterator at the dict start. It points to the first element
void clear | ( | void | ) |
Clear content
const_iterator end | ( | void | ) | const |
Returns iterator at the dict end. It does not points to the last element, but element after the last, and you must not dereferce it
EdbusDataType key_type | ( | void | ) |
Returns type of keys stored in dict
|
inline |
Compares if two dicts are not equal
bool operator== | ( | const EdbusDict & | other | ) |
Compares if two dicts are equal
void remove | ( | const EdbusData & | key | ) |
Remove value and key for the dict. If key is not found, it will do nothing
key | is key to be removed with it's value |
unsigned int size | ( | void | ) | const |
Returns size of dict content. This is a constant operation
EdbusDataType value_type | ( | void | ) |
Returns type of values stored in dict
bool value_type_is_container | ( | void | ) |