Main Page | Modules | Data Structures | File List | Data Fields

KeySet Class Methods

Methods to manipulate KeySets. A KeySet is a linked list to group a number of Keys. Key Sets have an internal cursor to help in the Key navigation. More...

Functions

int ksInit (KeySet *ks)
int ksClose (KeySet *ks)
size_t ksGetSize (KeySet *ks)
KeyksNext (KeySet *ks)
int ksRewind (KeySet *ks)
KeyksCurrent (const KeySet *ks)
size_t ksInsert (KeySet *ks, Key *toInsert)
size_t ksInsertKeys (KeySet *ks, KeySet *toInsert)
size_t ksAppend (KeySet *ks, Key *toAppend)
size_t ksAppendKeys (KeySet *ks, KeySet *toAppend)
int ksCompare (KeySet *ks1, KeySet *ks2, KeySet *removed)
size_t ksToStream (const KeySet *ks, FILE *stream, unsigned long options)

Detailed Description

Methods to manipulate KeySets. A KeySet is a linked list to group a number of Keys. Key Sets have an internal cursor to help in the Key navigation.

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 it:

#include <kdb.h>

Function Documentation

size_t ksAppend KeySet ks,
Key toAppend
 

Append a new Key to the end of the KeySet. You should not append Keys that are local variables to a KeySet, only dinamycally allocated ones, due to the future ksClose() you'll call on the KeySet. The KeySet internal cursor is not moved.

Do not ksAppend() Keys that are already members of other KeySets.

Returns:
the size of the KeySet after insertion
Parameters:
ks KeySet that will receive the key
toAppend Key that will be appended to ks
See also:
ksClose()

ksInsert()

ksInsertKeys()

ksAppendKeys()

Definition at line 2408 of file key.c.

References _KeySet::end, _Key::next, _KeySet::size, and _KeySet::start.

Referenced by commandEdit(), commandList(), kdbGetChildKeys(), kdbGetRootKeys(), ksCompare(), and processNode().

size_t ksAppendKeys KeySet ks,
KeySet toAppend
 

Transfers an entire KeySet to the end of the KeySet.

After this call, the toAppend KeySet will be empty.

Returns:
the size of the KeySet after transfer
Parameters:
ks the KeySet that will receive the keys
toAppend the KeySet that provides the keys that will be transfered
See also:
ksAppend()

ksInsert()

ksInsertKeys()

Definition at line 2431 of file key.c.

References _KeySet::cursor, _KeySet::end, _Key::next, _KeySet::size, and _KeySet::start.

Referenced by commandList(), kdbGetChildKeys(), and ksCompare().

int ksClose KeySet ks  ) 
 

KeySet destructor.

Will cause keyClose() destructor to be called for all contained keys, and then frees the key object. This is why you should not ksAppend() or ksInsert() a Key that is a local variable, only dinamycally allocated Keys.

After this call, ks object is ready to be freed by you.

See also:
ksInit()

keyClose()

ksAppend() for details on how keys are inserted in KeySets

Returns:
0

Definition at line 2253 of file key.c.

References _KeySet::cursor, _KeySet::end, keyClose(), _Key::next, _KeySet::size, and _KeySet::start.

Referenced by commandList().

int ksCompare KeySet ks1,
KeySet ks2,
KeySet removed
 

Compare 2 KeySets with the following behavior:

  • A key (by full name) that is present on ks1 and ks2, and has something different, will be transfered from ks2 to ks1, and ks1's (old) version deleted.
  • Keys that are in ks1, but aren't in ks2 will be trasnsfered from ks1 to removed.
  • Keys that are keyCompare() equal in ks1 and ks2 will be deleted from ks2.
  • Keys that are available in ks2 but don't exist in ks1 will be transfered to ks1.

In the end, ks1 will have all the keys that matter, and ks2 will be empty.

After ksCompare(), you should:

See also:
keyCompare()

commandEdit() at the KeyDB Class Methods command

Parameters:
ks1 first KeySet
ks2 second KeySet
removed empty KeySet that will be filled with keys removed from ks1

Definition at line 2483 of file key.c.

References _KeySet::end, KEY_FLAG_HASDOMAIN, KEY_FLAG_HASKEY, keyClose(), keyCompare(), ksAppend(), ksAppendKeys(), _Key::next, _KeySet::size, and _KeySet::start.

Referenced by commandEdit().

Key* ksCurrent const KeySet ks  ) 
 

Return the current Key

See also:
ksNext()

ksRewind()

kdbMonitorKeys() for an example

Returns:
pointer to the Key pointed by ks's cursor

Definition at line 2328 of file key.c.

References _KeySet::cursor.

Referenced by commandEdit(), commandImport(), kdbMonitorKeys(), and kdbSetKeys().

size_t ksGetSize KeySet ks  ) 
 

Returns:
the number of keys in the ks.

Definition at line 2275 of file key.c.

References _KeySet::size.

int ksInit KeySet ks  ) 
 

KeySet object constructor.

Every KeySet object that will be used must be initialized first, to setup pointers, counters, etc.

See also:
ksClose()

keyInit()

Definition at line 2231 of file key.c.

References _KeySet::cursor, _KeySet::end, _KeySet::size, and _KeySet::start.

Referenced by commandEdit(), commandImport(), commandList(), and kdbGetChildKeys().

size_t ksInsert KeySet ks,
Key toInsert
 

Insert a new Key in the begining of the KeySet. A reference to key will be stored, and not a copy of the key. So a future ksClose() on ks will keyClose() toInsert and free() the toInsert object. The KeySet internal cursor is not moved.

Do not ksInsert() Keys that are already members of other KeySets.

Returns:
the size of the KeySet after insertion
Parameters:
ks KeySet that will receive the key
toInsert Key that will be inserted into ks
See also:
ksAppend()

ksInsertKeys()

ksAppendKeys()

ksClose()

Definition at line 2352 of file key.c.

References _KeySet::end, _Key::next, _KeySet::size, and _KeySet::start.

Referenced by kdbGetRootKeys().

size_t ksInsertKeys KeySet ks,
KeySet toInsert
 

Transfers an entire KeySet to the begining of the KeySet.

After this call, the toInsert KeySet will be empty.

Returns:
the size of the KeySet after insertion
Parameters:
ks the KeySet that will receive the keys
toInsert the KeySet that provides the keys that will be transfered
See also:
ksAppend()

ksInsert()

ksAppendKeys()

Definition at line 2375 of file key.c.

References _KeySet::cursor, _KeySet::end, _Key::next, _KeySet::size, and _KeySet::start.

Key* ksNext KeySet ks  ) 
 

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.

See also:
ksRewind()

ksCurrent()

Returns:
the new current Key

Definition at line 2294 of file key.c.

References _KeySet::cursor, _Key::next, and _KeySet::start.

Referenced by commandEdit(), commandList(), kdbMonitorKeys(), and kdbSetKeys().

int ksRewind KeySet ks  ) 
 

Resets a KeySet internal cursor. Use it to set the cursor to the begining of the KeySet

See also:
ksNext()

ksCurrent()

kdbMonitorKeys() for an example

Returns:
allways 0

Definition at line 2313 of file key.c.

References _KeySet::cursor.

Referenced by commandEdit(), commandImport(), and commandList().

size_t ksToStream const KeySet ks,
FILE *  stream,
unsigned long  options
 

Prints an XML version of a KeySet object.

Accepted options:

  • KDB_O_NUMBERS: Do not convert UID and GID into user and group names
  • KDB_O_CONDENSED: Less human readable, more condensed output
  • KDB_O_XMLHEADERS: Include the correct XML headers in the output. Use it.

Parameters:
stream where to write output: a file or stdout
options ORed of KDB_O_* options
See also:
keyToStream()

KDBOptions

Returns:
number of bytes written to output

Definition at line 2581 of file key.c.

References KDB_O_XMLHEADERS, keyToStream(), _Key::next, _KeySet::size, and _KeySet::start.

Referenced by commandEdit(), and commandList().


Generated on Mon Oct 10 11:41:17 2005 for Elektra Project by  doxygen 1.4.4