
\begin{DoxyItemize}
\item infos = Information about the directoryvalue plugin is in keys below
\item infos/author = René Schwaiger \href{mailto:sanssecours@me.com}{\texttt{ sanssecours@me.\+com}}
\item infos/licence = BSD
\item infos/needs =
\item infos/provides =
\item infos/recommends =
\item infos/placements = postgetstorage presetstorage
\item infos/status = unittest nodep preview
\item infos/metadata =
\item infos/description = This plugin converts directory keys to leaf keys in the set direction
\end{DoxyItemize}\hypertarget{md_src_plugins_directoryvalue_README_src_plugins_directoryvalue_README_md}{}\doxysection{Directory Value}\label{md_src_plugins_directoryvalue_README_src_plugins_directoryvalue_README_md}
\hypertarget{md_src_plugins_directoryvalue_README_autotoc_md170}{}\doxysubsection{Introduction}\label{md_src_plugins_directoryvalue_README_autotoc_md170}
The Directory Value plugin converts


\begin{DoxyEnumerate}
\item directory (non-\/leaf) keys to leaf keys in the “set” direction, and
\item converts them back to directory keys in the “get” direction.
\end{DoxyEnumerate}

A directory key is a key that has children. For example in the key set\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{user:/grandparent                = Grandparent}
\DoxyCodeLine{user:/grandparent/leaf           = Leaf}
\DoxyCodeLine{user:/grandparent/parent         = Parent}
\DoxyCodeLine{user:/grandparent/parent/child   = Child}
\DoxyCodeLine{user:/mother                     = Mother}
\DoxyCodeLine{user:/mother/daughter            = Daughter}
\DoxyCodeLine{user:/mother/son                 = Son}

\end{DoxyCode}


the keys


\begin{DoxyCode}{0}
\DoxyCodeLine{user:/grandparent}
\DoxyCodeLine{user:/grandparent/parent}
\DoxyCodeLine{user:/mother}

\end{DoxyCode}


represent directory keys, while the keys


\begin{DoxyCode}{0}
\DoxyCodeLine{user:/grandparent/leaf}
\DoxyCodeLine{user:/grandparent/parent/child}
\DoxyCodeLine{user:/mother/daughter}
\DoxyCodeLine{user:/mother/son}

\end{DoxyCode}


are leaf keys. You can easily check this by drawing the key set in the form of a rooted tree\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{             user}
\DoxyCodeLine{      /               \(\backslash\)}
\DoxyCodeLine{  granparent        mother}
\DoxyCodeLine{  /      |          /    \(\backslash\)}
\DoxyCodeLine{leaf  parent    daughter son}
\DoxyCodeLine{         |}
\DoxyCodeLine{       child}

\end{DoxyCode}


. The Directory Value plugin converts all directory keys to leaf keys in the “set” direction by adding new keys with the postfix {\ttfamily \+\_\+\+\_\+\+\_\+dirdata}. Theses keys then store the old value of their parent keys


\begin{DoxyCode}{0}
\DoxyCodeLine{user:/grandparent                    =}
\DoxyCodeLine{user:/grandparent/\_\_\_dirdata         = Grandparent}
\DoxyCodeLine{user:/grandparent/leaf               = Leaf}
\DoxyCodeLine{user:/grandparent/parent             =}
\DoxyCodeLine{user:/grandparent/parent/\_\_\_dirdata  = Parent}
\DoxyCodeLine{user:/grandparent/parent/child       = Child}
\DoxyCodeLine{user:/mother                         =}
\DoxyCodeLine{user:/mother/\_\_\_dirdata              = Mother}
\DoxyCodeLine{user:/mother/daughter                = Daughter}
\DoxyCodeLine{user:/mother/son                     = Son}

\end{DoxyCode}


. 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 \mbox{\hyperlink{md_src_plugins_yajl_README_src_plugins_yajl_README_md}{\`{}yajl\`{}}} or \mbox{\hyperlink{md_src_plugins_yajl_README_src_plugins_yajl_README_md}{\`{}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.\hypertarget{md_src_plugins_directoryvalue_README_autotoc_md171}{}\doxysubsubsection{Array Values}\label{md_src_plugins_directoryvalue_README_autotoc_md171}
The Directory value plugin also converts array values. Let us take a look at an example key set\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{user:/array    = Array Value}
\DoxyCodeLine{user:/array/\#0 = Firt Value}
\DoxyCodeLine{user:/array/\#1 = Second Value}
\DoxyCodeLine{user:/array/\#2 = Third Value}

\end{DoxyCode}


. The plugin {\bfseries{does not}} convert this key set into\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{user:/array            =}
\DoxyCodeLine{user:/array/\_\_\_dirdata = Array Value}
\DoxyCodeLine{user:/array/\#0         = First Value}
\DoxyCodeLine{user:/array/\#1         = Second Value}
\DoxyCodeLine{user:/array/\#2         = Third Value}

\end{DoxyCode}


, since then {\ttfamily user\+:/array} {\bfseries{would not be an array}} any more. Instead the plugin inserts a new element at index 0 with the {\bfseries{value prefix}} {\ttfamily \+\_\+\+\_\+\+\_\+dirdata\+:}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{user:/array            =}
\DoxyCodeLine{user:/array/\#0         = \_\_\_dirdata: Array Value}
\DoxyCodeLine{user:/array/\#1         = First Value}
\DoxyCodeLine{user:/array/\#2         = Second Value}
\DoxyCodeLine{user:/array/\#3         = Third Value}

\end{DoxyCode}


. This way a storage plugin such as YAJL or YAML CPP are still able to store {\ttfamily user\+:/array} as an array.\hypertarget{md_src_plugins_directoryvalue_README_autotoc_md172}{}\doxyparagraph{Remarks}\label{md_src_plugins_directoryvalue_README_autotoc_md172}

\begin{DoxyItemize}
\item The plugin only converts array parents that store {\bfseries{string values}}
\item The \mbox{\hyperlink{doc_decisions_array_md}{array metakey}} of the array parent (increased by one) will still be stored in the original parent key after conversion. This is important, since otherwise the storage plugin would lose information about which key represents an array.
\end{DoxyItemize}\hypertarget{md_src_plugins_directoryvalue_README_autotoc_md173}{}\doxysubsection{Usage}\label{md_src_plugins_directoryvalue_README_autotoc_md173}
To mount the plugin use the command\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\# Mount plugin at `user:/tests/directoryvalue`}
\DoxyCodeLine{sudo kdb mount config.file user:/tests/directoryvalue directoryvalue}

\end{DoxyCode}


. To unmount the plugin use the command


\begin{DoxyCode}{0}
\DoxyCodeLine{sudo kdb umount user:/tests/directoryvalue}

\end{DoxyCode}
\hypertarget{md_src_plugins_directoryvalue_README_autotoc_md174}{}\doxysubsection{Example}\label{md_src_plugins_directoryvalue_README_autotoc_md174}

\begin{DoxyCode}{0}
\DoxyCodeLine{\# Mount plugin}
\DoxyCodeLine{sudo kdb mount config.file user:/tests/directoryvalue directoryvalue}
\DoxyCodeLine{}
\DoxyCodeLine{\# Add a directory value}
\DoxyCodeLine{kdb set user:/tests/directoryvalue/harold 'Father of SpongeBob SquarePants'}
\DoxyCodeLine{\# Add a leaf value}
\DoxyCodeLine{kdb set user:/tests/directoryvalue/harold/spongebob 'I am ready!'}
\DoxyCodeLine{}
\DoxyCodeLine{\# Add an array}
\DoxyCodeLine{kdb set user:/tests/directoryvalue/patrick Star}
\DoxyCodeLine{kdb set user:/tests/directoryvalue/patrick/\#0 'Being grown-\/up is boring. Besides, I don’t get Jazz.'}
\DoxyCodeLine{\# Elektra requires that the array parent contains the metakey `array`.}
\DoxyCodeLine{\# If this key is not present, then `user:/tests/directoryvalue/patrick`}
\DoxyCodeLine{\# is **not an array**.}
\DoxyCodeLine{kdb meta-\/set user:/tests/directoryvalue/patrick array ''}
\DoxyCodeLine{}
\DoxyCodeLine{\# Since the plugin converts values back in the get direction}
\DoxyCodeLine{\# a user of the database will not notice any changes.}
\DoxyCodeLine{}
\DoxyCodeLine{kdb ls user:/tests/directoryvalue}
\DoxyCodeLine{\#> user:/tests/directoryvalue/harold}
\DoxyCodeLine{\#> user:/tests/directoryvalue/harold/spongebob}
\DoxyCodeLine{\#> user:/tests/directoryvalue/patrick}
\DoxyCodeLine{\#> user:/tests/directoryvalue/patrick/\#0}
\DoxyCodeLine{}
\DoxyCodeLine{kdb get user:/tests/directoryvalue/harold}
\DoxyCodeLine{\#> Father of SpongeBob SquarePants}
\DoxyCodeLine{kdb get user:/tests/directoryvalue/harold/spongebob}
\DoxyCodeLine{\#> I am ready!}
\DoxyCodeLine{}
\DoxyCodeLine{kdb get user:/tests/directoryvalue/patrick}
\DoxyCodeLine{\#> Star}
\DoxyCodeLine{kdb get user:/tests/directoryvalue/patrick/\#0}
\DoxyCodeLine{\#> Being grown-\/up is boring. Besides, I don’t get Jazz.}
\DoxyCodeLine{}
\DoxyCodeLine{\# Retrieve index of last element in array.}
\DoxyCodeLine{\# This also works if the storage plugin does not store this index.}
\DoxyCodeLine{kdb meta-\/get user:/tests/directoryvalue/patrick array}
\DoxyCodeLine{\#> \#0}
\DoxyCodeLine{}
\DoxyCodeLine{\# Undo changes to the key database}
\DoxyCodeLine{kdb rm -\/r user:/tests/directoryvalue}
\DoxyCodeLine{sudo kdb umount user:/tests/directoryvalue}

\end{DoxyCode}
\hypertarget{md_src_plugins_directoryvalue_README_autotoc_md175}{}\doxysection{Limitations}\label{md_src_plugins_directoryvalue_README_autotoc_md175}

\begin{DoxyItemize}
\item {\bfseries{Escaping}} is currently {\bfseries{not possible}}. If you use the Directory Value plugin you can not
\begin{DoxyItemize}
\item use the name {\ttfamily \+\_\+\+\_\+\+\_\+dirdata} as the last part of a normal key,
\item use {\ttfamily \+\_\+\+\_\+\+\_\+dirdata\+:} at the beginning of a normal value in the first array element
\end{DoxyItemize}

! 
\end{DoxyItemize}