Elektra
0.9.3
|
The Directory Value plugin converts
A directory key is a key that has children. For example in the key set:
the keys
represent directory keys, while the keys
are leaf keys. You can easily check this by drawing the key set in the form of a rooted tree:
. The Directory Value plugin converts all directory keys to leaf keys in the “set” direction by adding new keys with the postfix ___dirdata
. Theses keys then store the old value of their parent keys
. You might ask why we need the Directory Value plugin at all. The reason why we created this plugin is that some storage plugins like `yajl` or `yamlcpp` are only able to save values inside leaf keys. By loading the Directory Value plugin these storage plugins are also able to represent directory values properly.
The Directory value plugin also converts array values. Let us take a look at an example key set:
. The plugin does not convert this key set into:
, since then user/array
would not be an array any more. Instead the plugin inserts a new element at index 0 with the value prefix ___dirdata:
:
. This way a storage plugin such as YAJL or YAML CPP are still able to store user/array
as an array.
To mount the plugin use the command:
`` @section autotoc_md177 Mount plugin at
user/tests/directoryvalue` sudo kdb mount config.file user/tests/directoryvalue directoryvalue
sudo kdb umount user/tests/directoryvalue
sudo kdb mount config.file user/tests/directoryvalue directoryvalue
kdb set user/tests/directoryvalue/harold 'Father of SpongeBob SquarePants'
kdb set user/tests/directoryvalue/harold/spongebob 'I am ready!'
kdb set user/tests/directoryvalue/patrick Star kdb set user/tests/directoryvalue/patrick/#0 'Being grown-up is boring. Besides, I don’t get Jazz.'
kdb meta-set user/tests/directoryvalue/patrick array ''
kdb ls user/tests/directoryvalue #> user/tests/directoryvalue/harold #> user/tests/directoryvalue/harold/spongebob #> user/tests/directoryvalue/patrick #> user/tests/directoryvalue/patrick/#0
kdb get user/tests/directoryvalue/harold #> Father of SpongeBob SquarePants kdb get user/tests/directoryvalue/harold/spongebob #> I am ready!
kdb get user/tests/directoryvalue/patrick #> Star kdb get user/tests/directoryvalue/patrick/#0 #> Being grown-up is boring. Besides, I don’t get Jazz.
kdb meta-get user/tests/directoryvalue/patrick array #> #0
kdb rm -r user/tests/directoryvalue sudo kdb umount user/tests/directoryvalue ```
Escaping is currently not possible. If you use the Directory Value plugin you can not
___dirdata
as the last part of a normal key,___dirdata:
at the beginning of a normal value in the first array element!