It's composed of functions qdict_first() and qdict_next(), plus
functions to access QDictEntry values.
This API was suggested by Markus Armbruster <armbru@redhat.com> and
it offers full control over the iteration process.
The usage is simple, the following example prints all keys in 'qdict'
(it's hopefully better than any English description):
QDict *qdict;
const QDictEntry *ent;
[...]
for (ent = qdict_first(qdict); ent; ent = qdict_next(qdict, ent)) {
printf("%s ", qdict_entry_key(ent));
}
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Next commit will introduce a new QDict iteration API which
returns QDictEntry entries, but we don't want users to directly
access its members since QDictEntry should be private to QDict.
In the near future this kind of data type will be turned into a
forward reference.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Let's call a 'hash' only what is returned by our hash function,
anything else is a 'bucket'.
This helps avoiding confusion with regard to how we traverse
our table.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
- Change from GPL to LGPL
- Add license text when missing
- Minor cosmetic changes to make all headers look the same
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Helper function just like qdict_get_int(), just for QFloat/double.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
A helper to retrieve a QDict from a QDict.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
A helper function to get a QList from a QDict.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This is a helper function that does type checking before retrieving
a QBool from the dictionary.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This adds iterator support to QDict, it will be used by the
(to be introduced) QError module.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Problem: Our file sys-queue.h is a copy of the BSD file, but there are
some additions and it's not entirely compatible. Because of that, there have
been conflicts with system headers on BSD systems. Some hacks have been
introduced in the commits 15cc923584,
f40d753718,
96555a96d7 and
3990d09adf but the fixes were fragile.
Solution: Avoid the conflict entirely by renaming the functions and the
file. Revert the previous hacks.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
QDict is a high-level dictionary data type that can be used to store a
collection of QObjects. A unique key is associated with only one
QObject.
The following functions are available:
- qdict_new() Create a new QDict
- qdict_put() Add a new 'key:object' pair
- qdict_get() Get the QObject of a given key
- qdict_del() Delete a 'key:object' pair
- qdict_size() Return the size of the dictionary
- qdict_haskey() Check if a given 'key' exists
Some high-level helpers to operate on QStrings and QInts objects
are also provided.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>