Functions | |
KeySet * | ksNew () |
Allocate, initialize and return a new KeySet object. | |
int | ksDel (KeySet *ks) |
A destructor for KeySet objects. | |
ssize_t | ksGetSize (KeySet *ks) |
Return the number of keys contained by ks . | |
int | ksRewind (KeySet *ks) |
Resets a KeySet internal cursor. | |
Key * | ksNext (KeySet *ks) |
Returns the next Key in a KeySet. | |
Key * | ksCurrent (const KeySet *ks) |
Return the current Key. | |
Key * | ksHead (KeySet *ks) |
Return the first key in the KeySet, whithout changing the KeySet's internal cursor. | |
Key * | ksTail (KeySet *ks) |
Return the last key in the KeySet, whithout changing the KeySet's internal cursor. | |
Key * | ksLookupByName (KeySet *ks, const char *name, unsigned long options) |
Look for a Key contained in ks that matches name , starting from ks' ksNext() position. | |
uint32_t | ksLookupRE (KeySet *ks, uint32_t where, const regex_t *regexp, unsigned long options) |
Lookup for a key which any of its where components matches the regex regular expression. | |
Key * | ksLookupByValue (KeySet *ks, const char *value, unsigned long options) |
Lookup for a Key contained in ks KeySet that matches value , starting from ks' ksNext() position. | |
Key * | ksLookupByBinaryValue (KeySet *ks, void *value, size_t size, unsigned long options) |
Lookup for a Key contained in ks KeySet that matches the binary value , starting from ks' ksNext() position. | |
ssize_t | ksInsert (KeySet *ks, Key *toInsert) |
Insert a new Key in the begining of the KeySet. | |
Key * | ksPop (KeySet *ks) |
Remove and return the first key of ks . | |
Key * | ksPopLast (KeySet *ks) |
Remove and return the last key of ks . | |
ssize_t | ksInsertKeys (KeySet *ks, KeySet *toInsert) |
Transfers all keys from toInsert to the begining of ks . | |
ssize_t | ksAppend (KeySet *ks, Key *toAppend) |
Appends a new Key to the end of ks . | |
ssize_t | ksAppendKeys (KeySet *ks, KeySet *toAppend) |
Transfers all toAppend contained keys to the end of the ks . | |
int | ksCompare (KeySet *ks1, KeySet *ks2, KeySet *removed) |
Compare 2 KeySets. | |
ssize_t | ksToStream (const KeySet *ks, FILE *stream, unsigned long options) |
Writes to stream an XML version of the ks object. | |
void | ksSort (KeySet *ks) |
Sorts a KeySet aphabetically by Key name, using qsort(). | |
int | ksInit (KeySet *ks) |
KeySet object initializer. | |
int | ksClose (KeySet *ks) |
KeySet object cleaner. |
These are the methods to make various manipulations in the objects of class KeySet. Methods for sorting , merging , comparing , and internal cursor manipulation are provided. To use them:
#include <kdb.h>
|
Allocate, initialize and return a new KeySet object. Objects created with ksNew() must be destroyed with ksDel().
Due to ABI compatibility, the
Definition at line 70 of file keyset.c. References ksInit(). Referenced by commandEdit(), commandImport(), and commandList(). |
|
A destructor for KeySet objects.
Cleans all internal dynamic attributes, keyDel() all contained Keys, and free()s the release the KeySet object memory (that was previously allocated by ksNew()). There is the
Definition at line 89 of file keyset.c. References ksClose(). Referenced by commandEdit(), and commandList(). |
|
Resets a KeySet internal cursor. Use it to set the cursor to the begining of the KeySet
Definition at line 127 of file keyset.c. References _KeySet::cursor. Referenced by commandEdit(), commandImport(), and commandList(). |
|
Returns the next Key in a KeySet. KeySets have an internal cursor that can be reset with ksRewind(). Every time ksNext() is called the cursor is incremented and the new current Key is returned. You'll get a NULL pointer if the end of KeySet was reached. After that, if ksNext() is called again, it will set the cursor to the begining of the KeySet and the first key is returned.
Definition at line 147 of file keyset.c. References _KeySet::cursor, _Key::next, and _KeySet::start. Referenced by commandEdit(), commandImport(), commandList(), kdbMonitorKeys_default(), kdbSetKeys_default(), ksLookupByBinaryValue(), ksLookupByName(), ksLookupByValue(), and ksLookupRE(). |
|
Return the current Key.
Definition at line 163 of file keyset.c. References _KeySet::cursor. Referenced by commandEdit(), commandImport(), kdbMonitorKeys_default(), and kdbSetKeys_default(). |
|
Return the first key in the KeySet, whithout changing the KeySet's internal cursor.
Definition at line 176 of file keyset.c. References _KeySet::start. Referenced by commandList(). |
|
Return the last key in the KeySet, whithout changing the KeySet's internal cursor.
Definition at line 188 of file keyset.c. References _KeySet::end. |
|
Look for a Key contained in
If found, Cascading is done if the first character is a /. This leads to ignoring the prefix like system/ and user/. if (kdbGetChildKeys("user/myapp", myConfig, 0 ) == -1) BailOut ("Could not get Keys"); if (kdbGetChildKeys("system/myapp", myConfig, 0 ) == -1) BailOut ("Could not get Keys"); if ((myKey = ksLookupByName (myConfig, "/myapp/key", 0)) == NULL) BailOut ("Could not Lookup Key");
The
This "optimization" makes comparing keys double when equals currentNameSize=current->key?strblen(current->key):0; if (currentNameSize != nameSize) continue; Definition at line 247 of file keyset.c. References _KeySet::cursor, _Key::key, keyStealName(), ksNext(), and strblen(). |
|
Lookup for a key which any of its
Definition at line 378 of file keyset.c. References _Key::comment, _KeySet::cursor, _Key::data, _Key::key, KEY_TYPE_BINARY, keyGetNameSize(), keyGetParentName(), keyGetParentNameSize(), keyIsUser(), ksNext(), _Key::type, and _Key::userDomain. |
|
Lookup for a Key contained in
If found,
This method jumps binary keys, unless
Definition at line 470 of file keyset.c. References _KeySet::cursor, _Key::data, _Key::dataSize, KEY_TYPE_BINARY, ksNext(), strblen(), and _Key::type. |
|
Lookup for a Key contained in
If found,
Definition at line 519 of file keyset.c. References _KeySet::cursor, _Key::data, _Key::dataSize, and ksNext(). |
|
Insert a new Key in the begining of the KeySet.
A reference to the key will be stored, and not a copy of the key. So a future ksClose() or ksDel() on Do not ksInsert() Keys that are already members of other KeySets.
Definition at line 566 of file keyset.c. References _KeySet::end, _Key::next, _KeySet::size, and _KeySet::start. Referenced by kdbGetRootKeys(). |
|
Remove and return the first key of
If ksInsert() provides the 'push' bahavior.
Definition at line 586 of file keyset.c. References _KeySet::cursor, _KeySet::end, _Key::next, _KeySet::size, and _KeySet::start. Referenced by commandList(). |
|
Remove and return the last key of
If ksAppend() provides the 'push' bahavior.
Definition at line 613 of file keyset.c. References _KeySet::cursor, _KeySet::end, _Key::next, _KeySet::size, and _KeySet::start. |
|
Transfers all keys from
After this call,
Definition at line 653 of file keyset.c. References _KeySet::cursor, _KeySet::end, _Key::next, _KeySet::size, and _KeySet::start. |
|
Appends a new Key to the end of
A reference to the key will be stored, and not a private copy. So a future ksClose() or ksDel() on Do not ksAppend() Keys that are already contained by other KeySets.
Definition at line 683 of file keyset.c. References _KeySet::end, _Key::next, _KeySet::size, and _KeySet::start. Referenced by commandEdit(), commandList(), and ksCompare(). |
|
Transfers all
After this call, the
Definition at line 705 of file keyset.c. References _KeySet::cursor, _KeySet::end, _Key::next, _KeySet::size, and _KeySet::start. Referenced by commandList(), and ksCompare(). |
|
Compare 2 KeySets. This method behavior is the following:
In the end, After ksCompare(), you should, in this order:
Definition at line 798 of file keyset.c. References _KeySet::end, KEY_SWITCH_NAME, keyCompare(), keyDel(), ksAppend(), ksAppendKeys(), _Key::next, _KeySet::size, and _KeySet::start. Referenced by commandEdit(). |
|
Writes to String generated is of the form: <?xml version="1.0" encoding="UTF-8"?> <!-- Generated by Elektra API. Total of n keys. --> <keyset xmlns="http://www.libelektra.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.libelektra.org elektra.xsd"> <key name=...>...</key> <key name=...>...</key> <key name=...>...</key> </keyset> OR, if KDBOptions::KDB_O_HIER is used, the form will be: <?xml version="1.0" encoding="UTF-8"?> <!-- Generated by Elektra API. Total of n keys. --> <keyset xmlns="http://www.libelektra.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.libelektra.org elektra.xsd" parent="smallest/parent/name"> <key basename=...>...</key> <key name=...>...</key> <!-- a key thats not under this keyset's parent --> <key basename=...>...</key> </keyset>
Definition at line 942 of file keyset.c. References _Key::key, keyGetFullName(), keyIsUser(), keyToStream(), keyToStreamBasename(), _Key::next, _KeySet::size, _KeySet::start, and strblen(). Referenced by commandEdit(), and commandList(). |
|
Sorts a KeySet aphabetically by Key name, using qsort().
Definition at line 1022 of file keyset.c. References _KeySet::end, _Key::next, _KeySet::size, and _KeySet::start. |
|
KeySet object initializer. You should always use ksNew() instead of ksInit(). Every KeySet object that will be used must be initialized first, to setup pointers, counters, etc. After use, all ksInit()ialized KeySets must be cleaned with ksClose().
Definition at line 1063 of file keyset.c. References _KeySet::cursor, _KeySet::end, _KeySet::size, and _KeySet::start. Referenced by ksNew(). |
|
KeySet object cleaner. Will keyDel() all contained keys, reset internal pointers and counters.
After this call, the
Definition at line 1082 of file keyset.c. References _KeySet::cursor, _KeySet::end, keyDel(), _Key::next, _KeySet::size, and _KeySet::start. Referenced by commandList(), and ksDel(). |