Elektra
0.9.7
|
The JNA dynamic proxy interface to libelektra. More...
Inherits Library.
Public Member Functions | |
Pointer | kdbOpen (@Nullable Pointer contractKeySet, Pointer errorKey) |
Opens the session with the Key database. More... | |
int | kdbClose (Pointer handle, Pointer errorKey) |
Closes the session with the Key database. More... | |
int | kdbGet (Pointer handle, Pointer returnKeySet, Pointer parentKey) |
Retrieve keys in an atomic and universal way. More... | |
int | kdbSet (Pointer handle, Pointer keySet, Pointer parentKey) |
Set keys in an atomic and universal way. More... | |
int | elektraGOptsContractFromStrings (Pointer contractKeySet, long argsSize, String args, long envSize, String env, Pointer parentKey, @Nullable Pointer goptsConfigKeySet) |
Sets up a contract for use with kdbOpen() that configures the. More... | |
Pointer | keyNew (@Nullable String name, @Nullable Object... args) |
A practical way to fully create a Key object in one step. More... | |
Public Attributes | |
Elektra | INSTANCE = Native.load ("elektra-kdb", Elektra.class) |
Singleton instance of the native library proxy. | |
The JNA dynamic proxy interface to libelektra.
This proxy is not intended to be used directly by libelektra API consumers. Please see KDB and its accompanying classes.
int org.libelektra.Elektra.elektraGOptsContractFromStrings | ( | Pointer | contractKeySet, |
long | argsSize, | ||
String | args, | ||
long | envSize, | ||
String | env, | ||
Pointer | parentKey, | ||
@Nullable Pointer | goptsConfigKeySet | ||
) |
Sets up a contract for use with kdbOpen() that configures the.
plugin.
contractKeySet | Pointer to a valid KeySet
|
argsSize | Size of the args
|
args | Continuous buffer containing all argv
|
envSize | Size of the env
|
env | Continuous buffer containing all environment variables separated (and terminated) by zero bytes The whole buffer is copied, so the pointer only has to be valid for this function call. |
parentKey | The parent key that should be used by gopts
|
goptsConfigKeySet | Configuration that is used to mount the gopts
user:/
|
int org.libelektra.Elektra.kdbClose | ( | Pointer | handle, |
Pointer | errorKey | ||
) |
Closes the session with the Key database.
You must call this method when you finished your affairs with the key database. You can still manipulate
and
objects after calling
, but you must not use any
call afterwards.
handle | Pointer to a valid KDB handle
|
errorKey | Pointer to a valid Key
|
int org.libelektra.Elektra.kdbGet | ( | Pointer | handle, |
Pointer | returnKeySet, | ||
Pointer | parentKey | ||
) |
Retrieve keys in an atomic and universal way.
The
may already contain some keys, e.g. from previous kdbGet() calls. The new retrieved keys will be appended using the native function underlying ksAppendKey().
@apiNote kdbGet() might retrieve more keys than requested (that are not below parentKey). These keys must be passed to when saving modifications via kdbSet(), otherwise they will be lost. This stems from the fact that the user has the only copy of the whole configuration and backends only write configuration that was passed to them. For example, if you get
you will not only get all keys below
, but also all keys below
(if
is a mountpoint as the name suggests, but
is not a mountpoint). Make sure to not touch or remove keys outside the keys of interest, because others may need them!
@implNote Optimization: In the first run of kdbGet() all requested (or more) keys are retrieved. On subsequent calls only the keys are retrieved where something was changed inside the key database. The other keys stay in the
returned as passed.
handle | Pointer to a valid KDB handle
|
returnKeySet | Pointer to a valid KeySet
|
parentKey | Pointer to a valid Key
|
Pointer org.libelektra.Elektra.kdbOpen | ( | @Nullable Pointer | contractKeySet, |
Pointer | errorKey | ||
) |
Opens the session with the Key database.
You must always call this method before retrieving or committing any keys to the database. In the end of the program, after using the key database, you must not forget to kdbClose().
Get a
for every thread using Elektra. Don't share the handle across threads, and also not the pointer accessing it.
You don't need kdbOpen() if you only want to manipulate plain in-memory
or
objects.
contractKeySet | TODO #3754 - documentation unclear - the contract that should be ensured before opening the KDB all data is copied and the KeySet can safely be used for e.g. kdbGet() later |
errorKey | Pointer to a valid Key
|
int org.libelektra.Elektra.kdbSet | ( | Pointer | handle, |
Pointer | keySet, | ||
Pointer | parentKey | ||
) |
Set keys in an atomic and universal way.
For the particularities of error handling, please see the documentation of the native library: TODO #3754 link to C API documentation
@apiNote kdbGet() must be called before kdbSet(): initially (after kdbOpen()) and also after conflict errors in kdbSet().
@implNote Optimization: Each key is checked using the native function underlying keyNeedSync() before being actually committed. If no key of a backend needs to be synced any affairs to backends are omitted and
is returned.
It is your responsibility to save the original keyset if you need it afterwards.
If you want to be sure to get a fresh keyset again, you need to open a second handle to the key database using kdbOpen().
handle | Pointer to a valid KDB handle
|
keySet | Pointer to a valid KeySet
|
parentKey | Pointer to a valid Key
With parentKey
KeySet
|
Pointer org.libelektra.Elektra.keyNew | ( | @Nullable String | name, |
@Nullable Object... | args | ||
) |
A practical way to fully create a Key object in one step.
For examples and further particularities, please see the documentation of the native library: TODO #3754 link to C API documentation
name | A valid name to the key, or KEY_NAME_SIMPLE_INITALIZED_BUT_EMPTY_OBJECT to get a simple initialized, but really empty, object. |
args | Argument flags, each followed by a corresponding value, if appropriate. |