Functions | |
ssize_t | keyGetDataSize (const Key *key) |
An alias to keyGetValueSize(). | |
ssize_t | keyGetValueSize (const Key *key) |
Returns the number of bytes needed to store the key value, including the NULL terminator. | |
ssize_t | keySetString (Key *key, const char *newStringValue) |
Set the value for key as newStringValue . | |
ssize_t | keyGetString (const Key *key, char *returnedString, size_t maxSize) |
Get the value of a key as a string. | |
void * | keyStealValue (const Key *key) |
Return a pointer to the real internal key value. | |
ssize_t | keySetLink (Key *key, const char *target) |
Set key as type KeyType::KEY_TYPE_LINK with target target . | |
ssize_t | keyGetLink (const Key *key, char *returnedTarget, size_t maxSize) |
Get the target key pointed by key . | |
ssize_t | keyGetBinary (const Key *key, void *returnedValue, size_t maxSize) |
Get the binary or string value of key . | |
ssize_t | keySetBinary (Key *key, const void *newBinary, size_t dataSize) |
Set the value of a key as a binary. | |
uint8_t | keyGetType (const Key *key) |
Returns the key data type. | |
uint8_t | keySetType (Key *key, uint8_t newType) |
Force a key type. | |
ssize_t | keySetRaw (Key *key, const void *newBinary, size_t dataSize) |
Set raw data as the value of a key. |
A key can contain a value in different format. The most likely situation is, that the value is interpreted as text. Use keyGetString() for that. You can save any Unicode Symbols and Elektra will take care that you get the same back, independent of your current Environment.
In some situations this idea fails. When you need exactly the same value back without any interpretation of the characters, there is keySetBinary(). If you use that, its very likely that your Configuration is not according to the standard. Also for Numbers, Booleans and Date you should use keyGetString(). To do so, you might use strtod() strtol() and then atol() or atof() to convert back.
A key may also be just a Link. Here you will also find the manipulation methods for keyGetLink().
To use them:
#include <kdb.h>
|
Returns the number of bytes needed to store the key value, including the NULL terminator. This method is used with malloc() before a keyGetString() or keyGetBinary().
Definition at line 1398 of file key.c. References _Key::dataSize. Referenced by commandGet(), and keyGetDataSize(). |
|
Set the value for
The function will allocate and save a private copy of String values will be saved in backend storage, when kdbSetKey() will be called, in UTF-8 universal encoding,regardeless of the program's current encoding.
Definition at line 1426 of file key.c. References KEY_TYPE_STRING, keySetRaw(), keySetType(), and strblen(). Referenced by commandSet(), kdbSetValue(), and keyNew(). |
|
Get the value of a key as a string.
If the value can't be represented as a text string (binary value, see keyIsBin()),
Definition at line 1463 of file key.c. References _Key::data, _Key::dataSize, and _Key::type. Referenced by commandGet(), and kdbGetValue(). |
|
Return a pointer to the real internal This is a much more efficient version of keyGetString(), keyGetLink(), keyGetBinary(), and you should use it if you are responsible enough to not mess up things.
If Note that the Key structure also has as data size field that is calculated by library internal calls to keySetRaw(), so to avoid inconsistencies, you must never used the pointer returned by keyStealValue() method to set a new value. Use keySetString(), keySetBinary(), keySetLink(), keySetRaw() instead.
Definition at line 1543 of file key.c. References _Key::data. Referenced by commandMonitor(). |
|
Set
Definition at line 1563 of file key.c. References KEY_TYPE_LINK, keySetRaw(), keySetType(), and strblen(). Referenced by commandSet(), and kdbLink(). |
|
Get the target key pointed by
TODO: Remove or:
Definition at line 1586 of file key.c. References _Key::data, _Key::dataSize, and _Key::type. |
|
Get the binary or string value of
Definition at line 1694 of file key.c. References _Key::data, and _Key::dataSize. Referenced by commandGet(). |
|
Set the value of a key as a binary.
A private copy of
The UNIX sysadmins don't like to deal with binary sand box data. Consider using a string key instead.
Definition at line 1735 of file key.c. References KEY_TYPE_BINARY, keySetRaw(), and keySetType(). |
|
Returns the key data type.
Definition at line 1769 of file key.c. References _Key::type. Referenced by commandGet(), and commandSet(). |
|
Force a key type. See the KeyType documentation to understand the concepts behind Elektra key's value types. This method is usually not needed, unless you are working with more semantic value types, or want to force a specific value type for a key. It is not usually needed because the data type is automatically set when setting the key value. The KeyType::KEY_TYPE_DIR is the only type that has no value, so when using this method to set to this type, the key value will be freed.
Definition at line 1848 of file key.c. References _Key::access, _Key::flags, KEY_TYPE_DIR, keySetRaw(), and _Key::type. Referenced by commandSet(), keyNew(), keySetBinary(), keySetLink(), and keySetString(). |
|
Set raw data as the value of a key. If NULL pointers are passed, key value is cleaned. This method will not change or set the key type, and should not be used unless working with user-defined value types.
Definition at line 1888 of file key.c. References _Key::data, _Key::dataSize, _Key::flags, and KEY_SWITCH_VALUE. Referenced by commandSet(), keyDup(), keyNew(), keySetBinary(), keySetLink(), keySetString(), and keySetType(). |