
\begin{DoxyItemize}
\item infos = Information about rename plugin is in keys below
\item infos/author = Felix Berlakovich \href{mailto:elektra@berlakovich.net}{\texttt{ elektra@berlakovich.\+net}}
\item infos/licence = BSD
\item infos/provides = filter
\item infos/needs =
\item infos/placements = presetstorage postgetstorage
\item infos/status = maintained unittest nodep libc configurable
\item infos/metadata = rename/to rename/toupper rename/tolower rename/cut origname
\item infos/description = renaming of keys
\end{DoxyItemize}\hypertarget{md_src_plugins_rename_README_src_plugins_rename_README_md}{}\doxysection{Introduction}\label{md_src_plugins_rename_README_src_plugins_rename_README_md}
This plugin can be used to perform rename operations on keys. This is useful if a backend does not provide keys with the required names or case.

If keys are renamed, their original name is stored in the {\ttfamily origname} Meta\+Key.

There are 2 types of transformations\+:


\begin{DoxyItemize}
\item basic
\item advanced
\end{DoxyItemize}\hypertarget{md_src_plugins_rename_README_autotoc_md451}{}\doxysection{Basic Transformations}\label{md_src_plugins_rename_README_autotoc_md451}
are applied before and after the advanced transformations.\hypertarget{md_src_plugins_rename_README_autotoc_md452}{}\doxysubsection{Get}\label{md_src_plugins_rename_README_autotoc_md452}
first transformation to be applied to all keys on kdb\+Get.

{\ttfamily get/case}


\begin{DoxyItemize}
\item toupper
\item tolower
\item unchanged // this is the default value if no configuration is given
\end{DoxyItemize}

converts the whole keyname below the parent\+Key to upper-\/ or lowercase. if no configuration or {\ttfamily unchanged} is used no transformation is done here.\hypertarget{md_src_plugins_rename_README_autotoc_md453}{}\doxysubsection{Set}\label{md_src_plugins_rename_README_autotoc_md453}
last transformation to be applied to all keys on kdb\+Set.

{\ttfamily set/case}


\begin{DoxyItemize}
\item toupper
\item tolower
\item keyname
\item unchanged // this is the default value if no configuration is given
\end{DoxyItemize}

{\ttfamily toupper} or {\ttfamily tolower} tells the rename plugin to convert the whole keyname below the parent\+Key to lower or uppercase.

{\ttfamily unchanged} returns the key to its original name

{\ttfamily keyname} tells the plugin to keep the name of the advanced transformation\hypertarget{md_src_plugins_rename_README_autotoc_md454}{}\doxysection{Advanced Transformations}\label{md_src_plugins_rename_README_autotoc_md454}
\hypertarget{md_src_plugins_rename_README_autotoc_md455}{}\doxysubsection{Cut}\label{md_src_plugins_rename_README_autotoc_md455}
\hypertarget{md_src_plugins_rename_README_autotoc_md456}{}\doxysubsubsection{Operation}\label{md_src_plugins_rename_README_autotoc_md456}
The cut operation can be used to strip parts of a key’s name. The cut operation is able to cut anything below the path of the parent key. A renamed key may even replace the parent key. For example consider a Key\+Set with the parent key {\ttfamily user\+:/config}. If the Key\+Set contained a key with the name {\ttfamily user\+:/config/with/long/path/key1}, the cut operation would be able to strip the following key name parts\+:


\begin{DoxyItemize}
\item with
\item with/long
\item with/long/path
\item with/long/path/key1
\end{DoxyItemize}\hypertarget{md_src_plugins_rename_README_autotoc_md457}{}\doxysubsubsection{Configuration}\label{md_src_plugins_rename_README_autotoc_md457}
The cut operation takes as its only configuration parameter the key name part to strip. This configuration can be supplied in two different ways. First, the global configuration key {\ttfamily cut} can be used. Second, keys to be stripped can be tagged with the Meta\+Key {\ttfamily rename/cut}. If both options are given, the Meta\+Key takes precedence. For example, consider the following setup\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{config/cut = will/be}
\DoxyCodeLine{parent key = user:/config}
\DoxyCodeLine{}
\DoxyCodeLine{user:/config/will/be/stripped/key1              <-\/ meta rename/cut = will/be/stripped}
\DoxyCodeLine{user:/config/will/be/stripped/key2              <-\/ meta rename/cut = will/be/stripped}
\DoxyCodeLine{user:/config/will/be/stripped/key3}
\DoxyCodeLine{user:/config/will/not/be/stripped/key4}

\end{DoxyCode}


The result of the cut operation would be the following Key\+Set\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{user:/config/key1}
\DoxyCodeLine{user:/config/key2}
\DoxyCodeLine{user:/config/stripped/key3}
\DoxyCodeLine{user:/config/will/not/be/stripped/key4}

\end{DoxyCode}


The cut operation is agnostic to a single trailing slash in the configuration. This means that it makes no difference whether {\ttfamily cut = will/be/stripped} or {\ttfamily cut = will/be/stripped/}. However, the cut operation refuses cut paths with leading slash. This is to clarify that key name parts can only be stripped after the parent key path.

If an invalid configuration is given or the cut operation would cause a parent key duplicate, the affected keys are simply skipped and not renamed.\hypertarget{md_src_plugins_rename_README_autotoc_md458}{}\doxysubsection{Replace}\label{md_src_plugins_rename_README_autotoc_md458}
Using the {\ttfamily /replacewith} global key or {\ttfamily rename/to} Meta\+Key the rename plugin will replace the part removed by {\ttfamily cut} with the supplied String\hypertarget{md_src_plugins_rename_README_autotoc_md459}{}\doxysubsubsection{To upper/lower}\label{md_src_plugins_rename_README_autotoc_md459}
Using the {\ttfamily /toupper} or {\ttfamily /tolower} global configuration key, or the {\ttfamily rename/toupper} or {\ttfamily rename/tolower} metakey the rename plugin will convert the keynames to uppercase or lowercase. The supplied values tell the plugin how many levels starting from the right will be converted. {\ttfamily toupper} and {\ttfamily tolower} can be combined. When no value or \char`\"{}0\char`\"{} is supplied with the keys the whole name below the parentkey will be converted.

The toupper/tolower conversions are applied after cut/replace.

Note that the names refer to the representation as Key\+Set. For example, if you have a configuration file where every name is uppercase\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{KEY=value}
\DoxyCodeLine{OTHER/KEY=otherval}

\end{DoxyCode}


you can use {\ttfamily tolower=0} to get the keys {\ttfamily key} and {\ttfamily other/key}.\hypertarget{md_src_plugins_rename_README_autotoc_md460}{}\doxysubsubsection{Examples}\label{md_src_plugins_rename_README_autotoc_md460}

\begin{DoxyCode}{0}
\DoxyCodeLine{sudo kdb mount caseconversion.ini user:/tests/rename mini rename toupper=1,tolower=3}
\DoxyCodeLine{}
\DoxyCodeLine{kdb set user:/tests/rename/MIXED/CASE/conversion 1}
\DoxyCodeLine{}
\DoxyCodeLine{kdb ls user:/tests/rename}
\DoxyCodeLine{\#> user:/tests/rename/mixed/case/CONVERSION}
\DoxyCodeLine{}
\DoxyCodeLine{\# Undo modifications}
\DoxyCodeLine{kdb rm -\/r user:/tests/rename}
\DoxyCodeLine{sudo kdb umount user:/tests/rename}

\end{DoxyCode}



\begin{DoxyCode}{0}
\DoxyCodeLine{sudo kdb mount renameTest.ini user:/tests/rename mini rename get/case=toupper,set/case=keyname,/cut=REMOVED}
\DoxyCodeLine{}
\DoxyCodeLine{printf 'removed/key=test' > `kdb file user:/tests/rename`}
\DoxyCodeLine{}
\DoxyCodeLine{kdb ls user:/tests/rename}
\DoxyCodeLine{\#> user:/tests/rename/KEY}
\DoxyCodeLine{}
\DoxyCodeLine{kdb set user:/tests/rename "{}"{}}
\DoxyCodeLine{}
\DoxyCodeLine{cat "{}`kdb file user:/tests/rename`"{} | tail -\/n1}
\DoxyCodeLine{\#> KEY=test}
\DoxyCodeLine{}
\DoxyCodeLine{\# Undo modifications}
\DoxyCodeLine{kdb rm -\/r user:/tests/rename}
\DoxyCodeLine{sudo kdb umount user:/tests/rename}

\end{DoxyCode}



\begin{DoxyCode}{0}
\DoxyCodeLine{\# If you always want the keys in the configuration file upper case,}
\DoxyCodeLine{\# but for your application lower case you would use:}
\DoxyCodeLine{sudo kdb mount caseconversion.ini user:/tests/rename mini rename get/case=tolower,set/case=toupper}
\DoxyCodeLine{}
\DoxyCodeLine{kdb set user:/tests/rename/section/key value}
\DoxyCodeLine{kdb get user:/tests/rename/section/key}
\DoxyCodeLine{\#> value}
\DoxyCodeLine{}
\DoxyCodeLine{cat "{}`kdb file user:/tests/rename`"{}}
\DoxyCodeLine{\#> SECTION/KEY=value}
\DoxyCodeLine{}
\DoxyCodeLine{\# Undo modifications}
\DoxyCodeLine{kdb rm -\/r user:/tests/rename}
\DoxyCodeLine{sudo kdb umount user:/tests/rename}

\end{DoxyCode}
\hypertarget{md_src_plugins_rename_README_autotoc_md461}{}\doxysection{Planned Operations}\label{md_src_plugins_rename_README_autotoc_md461}
Additional rename operations are planned for future versions of the rename plugin\+:


\begin{DoxyItemize}
\item trim\+: remove spaces in the name (that are not part of parent\+Key)
\item ranges for toupper, tolower
\item allow one to specify the case in configuration files (\#485) 
\end{DoxyItemize}