Scroll to navigation

proposal.c(3elektra) Elektra proposal.c(3elektra)

NAME

proposal.c - Implementation of proposed API enhancements.

SYNOPSIS

#include <string.h>
#include <kdbprivate.h>

Functions


Key * elektraKsPrev (KeySet *ks)
Returns the previous Key in a KeySet. KeySet * elektraRenameKeys (KeySet *config, const char *name)
Takes the first key and cuts off this common part for all other keys, instead name will be prepended. int elektraKeyLock (Key *key, enum elektraLockOptions what)
Permanently locks a part of the key. Key * elektraKsPopAtCursor (KeySet *ks, cursor_t pos)
Pop key at given cursor position.

Detailed Description

Implementation of proposed API enhancements.

Copyright:

BSD License (see LICENSE.md or https://www.libelektra.org)

Function Documentation

int elektraKeyLock (Key * key, enum elektraLockOptions what)

Permanently locks a part of the key. This can be:

  • KEY_FLAG_LOCK_NAME to lock the name
  • KEY_FLAG_LOCK_VALUE to lock the value
  • KEY_FLAG_LOCK_META to lock the metadata

To unlock the key, duplicate it.

It is also possible to lock when the key is created with keyNew().

Some data structures need to lock the key (most likely its name), so that the ordering does not get confused.

Parameters:

key which name should be locked

See also:

keyNew(), keyDup(), ksAppendKey()

Return values:

>0 the bits that were successfully locked
0 if everything was locked before
-1 if it could not be locked (nullpointer)

Key* elektraKsPopAtCursor (KeySet * ks, cursor_t pos)

Pop key at given cursor position.

Parameters:

ks the keyset to pop key from
c where to pop

The internal cursor will be rewinded using ksRewind(). You can use ksGetCursor() and ksSetCursor() jump back to the previous position. e.g. to pop at current position within ksNext() loop:

cursor_t c = ksGetCursor(ks);
keyDel (ksPopAtCursor(ks, c));
ksSetCursor(ks, c);
ksPrev(ks); // to have correct key after next ksNext()

Warning:

do not use, will be superseded by external iterator API

Returns:

the popped key

Return values:

0 if ks is 0

Key* elektraKsPrev (KeySet * ks)

Returns the previous Key in a KeySet. KeySets have an internal cursor that can be reset with ksRewind(). Every time ksPrev() is called the cursor is decremented and the new current Key is returned.

You'll get a NULL pointer if the key before begin of the KeySet was reached.

Don't delete the key, use ksPop() if you want to delete it.

Returns:

the new current Key

See also:

ksRewind(), ksCurrent()

KeySet* elektraRenameKeys (KeySet * config, const char * name)

Takes the first key and cuts off this common part for all other keys, instead name will be prepended.

Returns:

a new allocated keyset with keys in user namespace.

The first key is removed in the resulting keyset.

Author

Generated automatically by Doxygen for Elektra from the source code.

Mon Jan 15 2018 Version 0.8.20