\hypertarget{classkdb_1_1KDB}{\section{kdb\-:\-:K\-D\-B Class Reference}
\label{classkdb_1_1KDB}\index{kdb\-::\-K\-D\-B@{kdb\-::\-K\-D\-B}}
}


Opens the session with the \hyperlink{classkdb_1_1Key}{Key} database.    




{\ttfamily \#include $<$kdb.\-hpp$>$}

\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classkdb_1_1KDB_a7e0637995ce9f294cdbc6f167df6db40}{K\-D\-B} ()
\begin{DoxyCompactList}\small\item\em Opens the session with the \hyperlink{classkdb_1_1Key}{Key} database.  \end{DoxyCompactList}\item 
\hyperlink{classkdb_1_1KDB_a98e25c7fe2f47c5a90461676c6d219e7}{K\-D\-B} (\hyperlink{classkdb_1_1Key}{Key} \&error\-Key)
\begin{DoxyCompactList}\small\item\em Opens the session with the \hyperlink{classkdb_1_1Key}{Key} database.  \end{DoxyCompactList}\item 
\hyperlink{classkdb_1_1KDB_af61bf771d2b75df730226fcae57eaa25}{$\sim$\-K\-D\-B} ()  throw ()
\begin{DoxyCompactList}\small\item\em \end{DoxyCompactList}\item 
void \hyperlink{classkdb_1_1KDB_aee37484b06164eacc0cc11b7b40ab892}{open} (\hyperlink{classkdb_1_1Key}{Key} \&error\-Key)
\begin{DoxyCompactList}\small\item\em Opens the session with the \hyperlink{classkdb_1_1Key}{Key} database.  \end{DoxyCompactList}\item 
void \hyperlink{classkdb_1_1KDB_aa027a8f798a2cfee11ff712eb204c35d}{close} (\hyperlink{classkdb_1_1Key}{Key} \&error\-Key)  throw ()
\begin{DoxyCompactList}\small\item\em \end{DoxyCompactList}\item 
int \hyperlink{classkdb_1_1KDB_a0419ffbc273c89756bc523b4223ec25a}{get} (\hyperlink{classkdb_1_1KeySet}{Key\-Set} \&returned, std\-::string const \&keyname)
\begin{DoxyCompactList}\small\item\em Retrieve keys in an atomic and universal way, all other \hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdb\-Get()} Functions rely on that one.  \end{DoxyCompactList}\item 
int \hyperlink{classkdb_1_1KDB_a48770a7290699bf2b7529f3ab67e378f}{get} (\hyperlink{classkdb_1_1KeySet}{Key\-Set} \&returned, \hyperlink{classkdb_1_1Key}{Key} \&parent\-Key)
\begin{DoxyCompactList}\small\item\em Retrieve keys in an atomic and universal way, all other \hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdb\-Get()} Functions rely on that one.  \end{DoxyCompactList}\item 
int \hyperlink{classkdb_1_1KDB_a29087a6a1a7de334f4e5b62ffe5d6e6e}{set} (\hyperlink{classkdb_1_1KeySet}{Key\-Set} \&returned, std\-::string const \&keyname)
\begin{DoxyCompactList}\small\item\em \end{DoxyCompactList}\item 
int \hyperlink{classkdb_1_1KDB_a62a4fafbe21d9519b31a7868aa05f3e3}{set} (\hyperlink{classkdb_1_1KeySet}{Key\-Set} \&returned, \hyperlink{classkdb_1_1Key}{Key} \&parent\-Key)
\begin{DoxyCompactList}\small\item\em \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Opens the session with the \hyperlink{classkdb_1_1Key}{Key} database.   

Constructs a class \hyperlink{classkdb_1_1KDB}{K\-D\-B}.


\begin{DoxyExceptions}{Exceptions}
{\em K\-D\-B\-Exception} & if database could not be opened\\
\hline
\end{DoxyExceptions}
The first step is to open the default backend. With it system/elektra/mountpoints will be loaded and all needed libraries and mountpoints will be determined. These libraries for backends will be loaded and with it the {\ttfamily \hyperlink{classkdb_1_1KDB}{K\-D\-B}} datastructure will be initialized.

You must always call this method before retrieving or commiting any keys to the database. In the end of the program, after using the key database, you must not forget to \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdb\-Close()}. You can use the atexit () handler for it.

The pointer to the {\ttfamily \hyperlink{classkdb_1_1KDB}{K\-D\-B}} structure returned will be initialized like described above, and it must be passed along on any kdb$\ast$() method your application calls.

Get a {\ttfamily \hyperlink{classkdb_1_1KDB}{K\-D\-B}} handle for every thread using elektra. Don't share the handle across threads, and also not the pointer accessing it\-: 
\begin{DoxyCode}
thread1
\{
        \hyperlink{classkdb_1_1KDB_a7e0637995ce9f294cdbc6f167df6db40}{KDB} * h;
        h = \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdbOpen}(0);
        \textcolor{comment}{// fetch keys and work with them}
        \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdbClose}(h, 0);
\}
thread2
\{
        \hyperlink{classkdb_1_1KDB_a7e0637995ce9f294cdbc6f167df6db40}{KDB} * h;
        h = \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdbOpen}(0);
        \textcolor{comment}{// fetch keys and work with them}
        \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdbClose}(h, 0);
\}
\end{DoxyCode}


You don't need to use the \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdb\-Open()} if you only want to manipulate plain in-\/memory \hyperlink{classkdb_1_1Key}{Key} or \hyperlink{classkdb_1_1KeySet}{Key\-Set} objects without any affairs with the backend key database or when your application loads plugins directly.


\begin{DoxyParams}{Parameters}
{\em error\-Key} & the key which holds errors and warnings which were issued must be given \\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdb\-Close()} to end all affairs to the \hyperlink{group__key}{Key} database. 
\end{DoxySeeAlso}
\begin{DoxyReturn}{Returns}
a \hyperlink{classkdb_1_1KDB}{K\-D\-B} pointer on success 

N\-U\-L\-L on failure 
\end{DoxyReturn}
 

Access to the key database.

\begin{DoxyInvariant}{Invariant}
the object holds an valid connection to the key database or is empty 
\end{DoxyInvariant}


\subsection{Constructor \& Destructor Documentation}
\hypertarget{classkdb_1_1KDB_a7e0637995ce9f294cdbc6f167df6db40}{\index{kdb\-::\-K\-D\-B@{kdb\-::\-K\-D\-B}!K\-D\-B@{K\-D\-B}}
\index{K\-D\-B@{K\-D\-B}!kdb::KDB@{kdb\-::\-K\-D\-B}}
\subsubsection[{K\-D\-B}]{\setlength{\rightskip}{0pt plus 5cm}kdb\-::\-K\-D\-B\-::\-K\-D\-B (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KDB_a7e0637995ce9f294cdbc6f167df6db40}


Opens the session with the \hyperlink{classkdb_1_1Key}{Key} database.  

Constructs a class \hyperlink{classkdb_1_1KDB}{K\-D\-B}.


\begin{DoxyExceptions}{Exceptions}
{\em K\-D\-B\-Exception} & if database could not be opened\\
\hline
\end{DoxyExceptions}
The first step is to open the default backend. With it system/elektra/mountpoints will be loaded and all needed libraries and mountpoints will be determined. These libraries for backends will be loaded and with it the {\ttfamily \hyperlink{classkdb_1_1KDB}{K\-D\-B}} datastructure will be initialized.

You must always call this method before retrieving or commiting any keys to the database. In the end of the program, after using the key database, you must not forget to \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdb\-Close()}. You can use the atexit () handler for it.

The pointer to the {\ttfamily \hyperlink{classkdb_1_1KDB}{K\-D\-B}} structure returned will be initialized like described above, and it must be passed along on any kdb$\ast$() method your application calls.

Get a {\ttfamily \hyperlink{classkdb_1_1KDB}{K\-D\-B}} handle for every thread using elektra. Don't share the handle across threads, and also not the pointer accessing it\-: 
\begin{DoxyCode}
thread1
\{
        \hyperlink{classkdb_1_1KDB_a7e0637995ce9f294cdbc6f167df6db40}{KDB} * h;
        h = \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdbOpen}(0);
        \textcolor{comment}{// fetch keys and work with them}
        \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdbClose}(h, 0);
\}
thread2
\{
        \hyperlink{classkdb_1_1KDB_a7e0637995ce9f294cdbc6f167df6db40}{KDB} * h;
        h = \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdbOpen}(0);
        \textcolor{comment}{// fetch keys and work with them}
        \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdbClose}(h, 0);
\}
\end{DoxyCode}


You don't need to use the \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdb\-Open()} if you only want to manipulate plain in-\/memory \hyperlink{classkdb_1_1Key}{Key} or \hyperlink{classkdb_1_1KeySet}{Key\-Set} objects without any affairs with the backend key database or when your application loads plugins directly.


\begin{DoxyParams}{Parameters}
{\em error\-Key} & the key which holds errors and warnings which were issued must be given \\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdb\-Close()} to end all affairs to the \hyperlink{group__key}{Key} database. 
\end{DoxySeeAlso}
\begin{DoxyReturn}{Returns}
a \hyperlink{classkdb_1_1KDB}{K\-D\-B} pointer on success 

N\-U\-L\-L on failure 
\end{DoxyReturn}
 \hypertarget{classkdb_1_1KDB_a98e25c7fe2f47c5a90461676c6d219e7}{\index{kdb\-::\-K\-D\-B@{kdb\-::\-K\-D\-B}!K\-D\-B@{K\-D\-B}}
\index{K\-D\-B@{K\-D\-B}!kdb::KDB@{kdb\-::\-K\-D\-B}}
\subsubsection[{K\-D\-B}]{\setlength{\rightskip}{0pt plus 5cm}kdb\-::\-K\-D\-B\-::\-K\-D\-B (
\begin{DoxyParamCaption}
\item[{{\bf Key} \&}]{error\-Key}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KDB_a98e25c7fe2f47c5a90461676c6d219e7}


Opens the session with the \hyperlink{classkdb_1_1Key}{Key} database.  

Constructs a class \hyperlink{classkdb_1_1KDB}{K\-D\-B}.


\begin{DoxyParams}{Parameters}
{\em error\-Key} & is useful if you want to get the warnings in the successful case, when no exception is thrown.\\
\hline
\end{DoxyParams}

\begin{DoxyExceptions}{Exceptions}
{\em K\-D\-B\-Exception} & if database could not be opened\\
\hline
\end{DoxyExceptions}
The first step is to open the default backend. With it system/elektra/mountpoints will be loaded and all needed libraries and mountpoints will be determined. These libraries for backends will be loaded and with it the {\ttfamily \hyperlink{classkdb_1_1KDB}{K\-D\-B}} datastructure will be initialized.

You must always call this method before retrieving or commiting any keys to the database. In the end of the program, after using the key database, you must not forget to \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdb\-Close()}. You can use the atexit () handler for it.

The pointer to the {\ttfamily \hyperlink{classkdb_1_1KDB}{K\-D\-B}} structure returned will be initialized like described above, and it must be passed along on any kdb$\ast$() method your application calls.

Get a {\ttfamily \hyperlink{classkdb_1_1KDB}{K\-D\-B}} handle for every thread using elektra. Don't share the handle across threads, and also not the pointer accessing it\-: 
\begin{DoxyCode}
thread1
\{
        \hyperlink{classkdb_1_1KDB_a7e0637995ce9f294cdbc6f167df6db40}{KDB} * h;
        h = \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdbOpen}(0);
        \textcolor{comment}{// fetch keys and work with them}
        \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdbClose}(h, 0);
\}
thread2
\{
        \hyperlink{classkdb_1_1KDB_a7e0637995ce9f294cdbc6f167df6db40}{KDB} * h;
        h = \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdbOpen}(0);
        \textcolor{comment}{// fetch keys and work with them}
        \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdbClose}(h, 0);
\}
\end{DoxyCode}


You don't need to use the \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdb\-Open()} if you only want to manipulate plain in-\/memory \hyperlink{classkdb_1_1Key}{Key} or \hyperlink{classkdb_1_1KeySet}{Key\-Set} objects without any affairs with the backend key database or when your application loads plugins directly.


\begin{DoxyParams}{Parameters}
{\em error\-Key} & the key which holds errors and warnings which were issued must be given \\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdb\-Close()} to end all affairs to the \hyperlink{group__key}{Key} database. 
\end{DoxySeeAlso}
\begin{DoxyReturn}{Returns}
a \hyperlink{classkdb_1_1KDB}{K\-D\-B} pointer on success 

N\-U\-L\-L on failure 
\end{DoxyReturn}
 \hypertarget{classkdb_1_1KDB_af61bf771d2b75df730226fcae57eaa25}{\index{kdb\-::\-K\-D\-B@{kdb\-::\-K\-D\-B}!$\sim$\-K\-D\-B@{$\sim$\-K\-D\-B}}
\index{$\sim$\-K\-D\-B@{$\sim$\-K\-D\-B}!kdb::KDB@{kdb\-::\-K\-D\-B}}
\subsubsection[{$\sim$\-K\-D\-B}]{\setlength{\rightskip}{0pt plus 5cm}kdb\-::\-K\-D\-B\-::$\sim$\-K\-D\-B (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)  throw ()\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KDB_af61bf771d2b75df730226fcae57eaa25}




The destructor closes the database.

Closes the session with the \hyperlink{classkdb_1_1Key}{Key} database.

You should call this method when you finished your affairs with the key database. You can manipulate \hyperlink{classkdb_1_1Key}{Key} and \hyperlink{classkdb_1_1KeySet}{Key\-Set} objects also after \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdb\-Close()}. You must not use any kdb$\ast$ call afterwards. You can implement \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdb\-Close()} in the atexit() handler.

This is the counterpart of \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdb\-Open()}.

The {\ttfamily handle} parameter will be finalized and all resources associated to it will be freed. After a \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdb\-Close()}, this {\ttfamily handle} can't be used anymore, unless it gets initialized again with another call to \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdb\-Open()}.

\begin{DoxySeeAlso}{See Also}
\hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdb\-Open()} 
\end{DoxySeeAlso}

\begin{DoxyParams}{Parameters}
{\em handle} & contains internal information of \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{opened } key database \\
\hline
{\em error\-Key} & the key which holds error information \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success 

-\/1 on N\-U\-L\-L pointer 
\end{DoxyReturn}
 

\subsection{Member Function Documentation}
\hypertarget{classkdb_1_1KDB_aa027a8f798a2cfee11ff712eb204c35d}{\index{kdb\-::\-K\-D\-B@{kdb\-::\-K\-D\-B}!close@{close}}
\index{close@{close}!kdb::KDB@{kdb\-::\-K\-D\-B}}
\subsubsection[{close}]{\setlength{\rightskip}{0pt plus 5cm}void kdb\-::\-K\-D\-B\-::close (
\begin{DoxyParamCaption}
\item[{{\bf Key} \&}]{error\-Key}
\end{DoxyParamCaption}
)  throw ()\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KDB_aa027a8f798a2cfee11ff712eb204c35d}




Open the database.

The return value does not matter because its only a null pointer check.


\begin{DoxyParams}{Parameters}
{\em error\-Key} & is useful if you want to get the warnings\\
\hline
\end{DoxyParams}
Closes the session with the \hyperlink{classkdb_1_1Key}{Key} database.

You should call this method when you finished your affairs with the key database. You can manipulate \hyperlink{classkdb_1_1Key}{Key} and \hyperlink{classkdb_1_1KeySet}{Key\-Set} objects also after \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdb\-Close()}. You must not use any kdb$\ast$ call afterwards. You can implement \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdb\-Close()} in the atexit() handler.

This is the counterpart of \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdb\-Open()}.

The {\ttfamily handle} parameter will be finalized and all resources associated to it will be freed. After a \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdb\-Close()}, this {\ttfamily handle} can't be used anymore, unless it gets initialized again with another call to \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdb\-Open()}.

\begin{DoxySeeAlso}{See Also}
\hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdb\-Open()} 
\end{DoxySeeAlso}

\begin{DoxyParams}{Parameters}
{\em handle} & contains internal information of \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{opened } key database \\
\hline
{\em error\-Key} & the key which holds error information \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success 

-\/1 on N\-U\-L\-L pointer 
\end{DoxyReturn}
 \hypertarget{classkdb_1_1KDB_a0419ffbc273c89756bc523b4223ec25a}{\index{kdb\-::\-K\-D\-B@{kdb\-::\-K\-D\-B}!get@{get}}
\index{get@{get}!kdb::KDB@{kdb\-::\-K\-D\-B}}
\subsubsection[{get}]{\setlength{\rightskip}{0pt plus 5cm}int kdb\-::\-K\-D\-B\-::get (
\begin{DoxyParamCaption}
\item[{{\bf Key\-Set} \&}]{returned, }
\item[{std\-::string const \&}]{keyname}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KDB_a0419ffbc273c89756bc523b4223ec25a}


Retrieve keys in an atomic and universal way, all other \hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdb\-Get()} Functions rely on that one.  

Get all keys below keyname inside returned.

The {\ttfamily returned} \hyperlink{classkdb_1_1KeySet}{Key\-Set} must be initialized. The {\ttfamily returned} \hyperlink{classkdb_1_1KeySet}{Key\-Set} may already contain some keys. The new retrieved keys will be appended using \hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ks\-Append\-Key()}.

It will fully retrieve all keys under the {\ttfamily parent\-Key} folder, with all subfolders and their children.


\begin{DoxyCodeInclude}
\textcolor{preprocessor}{#include <kdb.hpp>}

\textcolor{preprocessor}{#include <keyio.hpp>}

\textcolor{keyword}{using namespace }kdb;

\textcolor{keywordtype}{int} main()
\{
        \hyperlink{classkdb_1_1KeySet}{KeySet} config;
        \hyperlink{classkdb_1_1KDB}{KDB} kdb;
        kdb.\hyperlink{classkdb_1_1KDB_a0419ffbc273c89756bc523b4223ec25a}{get}(config, \textcolor{stringliteral}{"/sw/MyApp"});

        \hyperlink{classkdb_1_1Key}{Key} k = config.\hyperlink{classkdb_1_1KeySet_a816e7468abe296f8352e090738c215cc}{lookup}(\textcolor{stringliteral}{"/sw/MyApp/mykey"});
        \textcolor{keywordflow}{if} (k)
        \{
                std::cout << k << \textcolor{stringliteral}{" is "} << k.\hyperlink{classkdb_1_1Key_ae8f4cf386b825c8efc29ce0db977f0d2}{get}<\textcolor{keywordtype}{int}>() << std::endl;
        \}
        \textcolor{keywordflow}{else}
        \{
                std::cerr << \textcolor{stringliteral}{"No key found"} << std::endl;
                \textcolor{keywordflow}{return} 1;
        \}
\}
\end{DoxyCodeInclude}



\begin{DoxyParams}{Parameters}
{\em returned} & the keyset where the keys will be in \\
\hline
{\em keyname} & the root keyname which should be used to get keys below it\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 0} & if no key was updated \\
\hline
{\em 1} & if user or system keys were updated \\
\hline
{\em 2} & if user and system keys were updated \\
\hline
\end{DoxyRetVals}



\begin{DoxyExceptions}{Exceptions}
{\em K\-D\-B\-Exception} & if there were problems with the database\\
\hline
\end{DoxyExceptions}
\begin{DoxySeeAlso}{See Also}
\hyperlink{classkdb_1_1KDB_a0419ffbc273c89756bc523b4223ec25a}{K\-D\-B\-::get} (\hyperlink{classkdb_1_1KeySet}{Key\-Set} \& returned, \hyperlink{classkdb_1_1Key}{Key} \& parent\-Key) 
\end{DoxySeeAlso}
\hypertarget{classkdb_1_1KDB_a48770a7290699bf2b7529f3ab67e378f}{\index{kdb\-::\-K\-D\-B@{kdb\-::\-K\-D\-B}!get@{get}}
\index{get@{get}!kdb::KDB@{kdb\-::\-K\-D\-B}}
\subsubsection[{get}]{\setlength{\rightskip}{0pt plus 5cm}int kdb\-::\-K\-D\-B\-::get (
\begin{DoxyParamCaption}
\item[{{\bf Key\-Set} \&}]{returned, }
\item[{{\bf Key} \&}]{parent\-Key}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KDB_a48770a7290699bf2b7529f3ab67e378f}


Retrieve keys in an atomic and universal way, all other \hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdb\-Get()} Functions rely on that one.  

Get all keys below parent\-Key inside returned.

The {\ttfamily returned} \hyperlink{classkdb_1_1KeySet}{Key\-Set} must be initialized. The {\ttfamily returned} \hyperlink{classkdb_1_1KeySet}{Key\-Set} may already contain some keys. The new retrieved keys will be appended using \hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ks\-Append\-Key()}.

It will fully retrieve all keys under the {\ttfamily parent\-Key} folder, with all subfolders and their children.


\begin{DoxyParams}{Parameters}
{\em returned} & the keyset where the keys will be in \\
\hline
{\em parent\-Key} & the parent\-Key of returned\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 0} & if no key was updated \\
\hline
{\em 1} & if user or system keys were updated \\
\hline
{\em 2} & if user and system keys were updated \\
\hline
\end{DoxyRetVals}



\begin{DoxyExceptions}{Exceptions}
{\em K\-D\-B\-Exception} & if there were problems with the database \\
\hline
\end{DoxyExceptions}
\hypertarget{classkdb_1_1KDB_aee37484b06164eacc0cc11b7b40ab892}{\index{kdb\-::\-K\-D\-B@{kdb\-::\-K\-D\-B}!open@{open}}
\index{open@{open}!kdb::KDB@{kdb\-::\-K\-D\-B}}
\subsubsection[{open}]{\setlength{\rightskip}{0pt plus 5cm}void kdb\-::\-K\-D\-B\-::open (
\begin{DoxyParamCaption}
\item[{{\bf Key} \&}]{error\-Key}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KDB_aee37484b06164eacc0cc11b7b40ab892}


Opens the session with the \hyperlink{classkdb_1_1Key}{Key} database.  

Open the database


\begin{DoxyParams}{Parameters}
{\em error\-Key} & is useful if you want to get the warnings in the successful case, when no exception is thrown.\\
\hline
\end{DoxyParams}
The first step is to open the default backend. With it system/elektra/mountpoints will be loaded and all needed libraries and mountpoints will be determined. These libraries for backends will be loaded and with it the {\ttfamily \hyperlink{classkdb_1_1KDB}{K\-D\-B}} datastructure will be initialized.

You must always call this method before retrieving or commiting any keys to the database. In the end of the program, after using the key database, you must not forget to \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdb\-Close()}. You can use the atexit () handler for it.

The pointer to the {\ttfamily \hyperlink{classkdb_1_1KDB}{K\-D\-B}} structure returned will be initialized like described above, and it must be passed along on any kdb$\ast$() method your application calls.

Get a {\ttfamily \hyperlink{classkdb_1_1KDB}{K\-D\-B}} handle for every thread using elektra. Don't share the handle across threads, and also not the pointer accessing it\-: 
\begin{DoxyCode}
thread1
\{
        \hyperlink{classkdb_1_1KDB_a7e0637995ce9f294cdbc6f167df6db40}{KDB} * h;
        h = \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdbOpen}(0);
        \textcolor{comment}{// fetch keys and work with them}
        \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdbClose}(h, 0);
\}
thread2
\{
        \hyperlink{classkdb_1_1KDB_a7e0637995ce9f294cdbc6f167df6db40}{KDB} * h;
        h = \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdbOpen}(0);
        \textcolor{comment}{// fetch keys and work with them}
        \hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdbClose}(h, 0);
\}
\end{DoxyCode}


You don't need to use the \hyperlink{group__kdb_ga6808defe5870f328dd17910aacbdc6ca}{kdb\-Open()} if you only want to manipulate plain in-\/memory \hyperlink{classkdb_1_1Key}{Key} or \hyperlink{classkdb_1_1KeySet}{Key\-Set} objects without any affairs with the backend key database or when your application loads plugins directly.


\begin{DoxyParams}{Parameters}
{\em error\-Key} & the key which holds errors and warnings which were issued must be given \\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See Also}
\hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdb\-Close()} to end all affairs to the \hyperlink{group__key}{Key} database. 
\end{DoxySeeAlso}
\begin{DoxyReturn}{Returns}
a \hyperlink{classkdb_1_1KDB}{K\-D\-B} pointer on success 

N\-U\-L\-L on failure 
\end{DoxyReturn}
 \hypertarget{classkdb_1_1KDB_a29087a6a1a7de334f4e5b62ffe5d6e6e}{\index{kdb\-::\-K\-D\-B@{kdb\-::\-K\-D\-B}!set@{set}}
\index{set@{set}!kdb::KDB@{kdb\-::\-K\-D\-B}}
\subsubsection[{set}]{\setlength{\rightskip}{0pt plus 5cm}int kdb\-::\-K\-D\-B\-::set (
\begin{DoxyParamCaption}
\item[{{\bf Key\-Set} \&}]{returned, }
\item[{std\-::string const \&}]{keyname}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KDB_a29087a6a1a7de334f4e5b62ffe5d6e6e}




Set all keys below keyname.

If the keyname of the parent\-Key is invalid (e.\-g. empty) all keys will be set.

Set keys in an atomic and universal way.

All other kdb\-Set Functions rely on that one.


\begin{DoxyRetVals}{Return values}
{\em 0} & if no key was updated \\
\hline
{\em 1} & if user or system keys were updated \\
\hline
{\em 2} & if user and system keys were updated \\
\hline
\end{DoxyRetVals}



\begin{DoxyParams}{Parameters}
{\em returned} & the keyset where the keys will be in \\
\hline
{\em keyname} & the keyname below the names should be set\\
\hline
\end{DoxyParams}

\begin{DoxyExceptions}{Exceptions}
{\em K\-D\-B\-Exception} & if there were problems with the database \\
\hline
\end{DoxyExceptions}
\hypertarget{classkdb_1_1KDB_a62a4fafbe21d9519b31a7868aa05f3e3}{\index{kdb\-::\-K\-D\-B@{kdb\-::\-K\-D\-B}!set@{set}}
\index{set@{set}!kdb::KDB@{kdb\-::\-K\-D\-B}}
\subsubsection[{set}]{\setlength{\rightskip}{0pt plus 5cm}int kdb\-::\-K\-D\-B\-::set (
\begin{DoxyParamCaption}
\item[{{\bf Key\-Set} \&}]{returned, }
\item[{{\bf Key} \&}]{parent\-Key}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [inline]}}}\label{classkdb_1_1KDB_a62a4fafbe21d9519b31a7868aa05f3e3}




Set all keys below parent\-Key.

If the keyname of the parent\-Key is invalid (e.\-g. empty) all keys will be set.

Set keys in an atomic and universal way.

All other kdb\-Set Functions rely on that one.


\begin{DoxyRetVals}{Return values}
{\em 0} & if no key was updated \\
\hline
{\em 1} & if user or system keys were updated \\
\hline
{\em 2} & if user and system keys were updated \\
\hline
\end{DoxyRetVals}



\begin{DoxyParams}{Parameters}
{\em returned} & the keyset where the keys are passed to the user \\
\hline
{\em parent\-Key} & the parent\-Key of returned\\
\hline
\end{DoxyParams}

\begin{DoxyExceptions}{Exceptions}
{\em K\-D\-B\-Exception} & if there were problems with the database \\
\hline
\end{DoxyExceptions}


The documentation for this class was generated from the following file\-:\begin{DoxyCompactItemize}
\item 
src/bindings/cpp/include/kdb.\-hpp\end{DoxyCompactItemize}
