<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\hypertarget{classkdb_1_1KeySet}{}\doxysection{kdb\+::Key\+Set Class Reference}
\label{classkdb_1_1KeySet}\index{kdb::KeySet@{kdb::KeySet}}


A keyset holds together a set of keys.  




{\ttfamily \#include $&lt;$keyset.\+hpp$&gt;$}

\doxysubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{Key\+Set}} ()
\begin{DoxyCompactList}\small\item\em Creates a new empty keyset with no keys. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classkdb_1_1KeySet_a21f651ff310178951402038e590743e0}{Key\+Set}} (ckdb\+::\+Key\+Set $\ast$k)
\begin{DoxyCompactList}\small\item\em Take ownership of a {\ttfamily ckdb\+::\+Key\+Set $\ast$}. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classkdb_1_1KeySet_ad8d6df839ab852fded1739ff3398d0b1}{Key\+Set}} (const \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} \&amp;other)
\begin{DoxyCompactList}\small\item\em Duplicate a keyset. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classkdb_1_1KeySet_a6191e93cdd67bbca63df934498d191ba}{Key\+Set}} (size\+\_\+t alloc,...) ELEKTRA\+\_\+\+SENTINEL
\begin{DoxyCompactList}\small\item\em Create a new keyset. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classkdb_1_1KeySet_ae0b2996803b9c9124cf791a1d738855c}{Key\+Set}} (\mbox{\hyperlink{structkdb_1_1VaAlloc}{Va\+Alloc}} alloc, va\+\_\+list ap)
\begin{DoxyCompactList}\small\item\em Create a new keyset. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classkdb_1_1KeySet_ade654f92bddec24abad1b651e828f2b8}{$\sim$\+Key\+Set}} ()
\begin{DoxyCompactList}\small\item\em Deconstruct a keyset. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{classkdb_1_1KeySet_a2987b3fb1b12196399650726f1c18f02}\label{classkdb_1_1KeySet_a2987b3fb1b12196399650726f1c18f02}} 
ckdb\+::\+Key\+Set $\ast$ \mbox{\hyperlink{classkdb_1_1KeySet_a2987b3fb1b12196399650726f1c18f02}{release}} ()
\begin{DoxyCompactList}\small\item\em If you don\textquotesingle{}t want destruction of keyset at the end you can release the pointer. \end{DoxyCompactList}\item 
ckdb\+::\+Key\+Set $\ast$ \mbox{\hyperlink{classkdb_1_1KeySet_a4e9a3906e0b18a783f8a6e8bdbec9ed0}{get\+Key\+Set}} () const
\begin{DoxyCompactList}\small\item\em Passes out the raw keyset pointer. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} \&amp; \mbox{\hyperlink{classkdb_1_1KeySet_a1c54736b7206bc2253d02a5bf4b3ccfb}{operator=}} (\mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} const \&amp;other)
\begin{DoxyCompactList}\small\item\em Duplicate a keyset. \end{DoxyCompactList}\item 
ssize\+\_\+t \mbox{\hyperlink{classkdb_1_1KeySet_ab01c5c46e4c0802560b8f15886af89c4}{size}} () const
\begin{DoxyCompactList}\small\item\em The size of the keyset. \end{DoxyCompactList}\item 
ckdb\+::\+Key\+Set $\ast$ \mbox{\hyperlink{classkdb_1_1KeySet_ad3f2b936d66729690e8a8a45b5074baa}{dup}} () const
\begin{DoxyCompactList}\small\item\em Duplicate a keyset. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classkdb_1_1KeySet_a28fd33fdaecf1d57d4dddac7058f5d38}{copy}} (const \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} \&amp;other)
\begin{DoxyCompactList}\small\item\em Copy a keyset. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{classkdb_1_1KeySet_a38f5159e39758aa632421d2fe7440633}{clear}} ()
\begin{DoxyCompactList}\small\item\em Clear the keyset. \end{DoxyCompactList}\item 
ssize\+\_\+t \mbox{\hyperlink{classkdb_1_1KeySet_a0d4b2f3aa9f58d10053561135b50233e}{append}} (const \mbox{\hyperlink{classkdb_1_1Key}{Key}} \&amp;to\+Append)
\begin{DoxyCompactList}\small\item\em append a key \end{DoxyCompactList}\item 
ssize\+\_\+t \mbox{\hyperlink{classkdb_1_1KeySet_ac9cbdc933d7171037d47c6d4d78595d1}{append}} (const \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} \&amp;to\+Append)
\begin{DoxyCompactList}\small\item\em append a keyset \end{DoxyCompactList}\item 
\mbox{\hyperlink{classkdb_1_1Key}{Key}} \mbox{\hyperlink{classkdb_1_1KeySet_a7f207457a1c12633a1a5301a3a1bbaed}{pop}} ()
\begin{DoxyCompactList}\small\item\em Remove and return the last \mbox{\hyperlink{classkdb_1_1Key}{Key}} of {\ttfamily ks}. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classkdb_1_1Key}{Key}} \mbox{\hyperlink{classkdb_1_1KeySet_a40e32f2d9f34f03fa8ec85945f49b630}{at}} (elektra\+Cursor pos) const
\begin{DoxyCompactList}\small\item\em Lookup a key by index. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} \mbox{\hyperlink{classkdb_1_1KeySet_ab283da798a7670d5c3f0e1a5b821e666}{cut}} (\mbox{\hyperlink{classkdb_1_1Key}{Key}} k)
\begin{DoxyCompactList}\small\item\em Cuts out all Keys from \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} {\ttfamily ks} that are below or at {\ttfamily cutpoint}. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classkdb_1_1Key}{Key}} \mbox{\hyperlink{classkdb_1_1KeySet_a2b8537e388edfbb6941d771106c0ae3a}{lookup}} (const \mbox{\hyperlink{classkdb_1_1Key}{Key}} \&amp;k, const \mbox{\hyperlink{group__keyset_gada05f4bbf46fde81d0d57df86e73d914}{elektra\+Lookup\+Flags}} options=\mbox{\hyperlink{group__keyset_ggada05f4bbf46fde81d0d57df86e73d914a00738455e0ae843c8720809d8287f370}{KDB\+\_\+\+O\+\_\+\+NONE}}) const
\begin{DoxyCompactList}\small\item\em Look for a \mbox{\hyperlink{classkdb_1_1Key}{Key}} contained in {\ttfamily ks} that matches the name of the {\ttfamily key}. \end{DoxyCompactList}\item 
\mbox{\hyperlink{classkdb_1_1Key}{Key}} \mbox{\hyperlink{classkdb_1_1KeySet_a0ef071747608900be478219e4a040612}{lookup}} (std\+::string const \&amp;name, const \mbox{\hyperlink{group__keyset_gada05f4bbf46fde81d0d57df86e73d914}{elektra\+Lookup\+Flags}} options=\mbox{\hyperlink{group__keyset_ggada05f4bbf46fde81d0d57df86e73d914a00738455e0ae843c8720809d8287f370}{KDB\+\_\+\+O\+\_\+\+NONE}}) const
\begin{DoxyCompactList}\small\item\em Lookup a key by name. \end{DoxyCompactList}\item 
{\footnotesize template$&lt;$typename T $&gt;$ }\\T \mbox{\hyperlink{classkdb_1_1KeySet_a65208974b44da0162ef70dd7a173748f}{get}} (std\+::string const \&amp;name, const \mbox{\hyperlink{group__keyset_gada05f4bbf46fde81d0d57df86e73d914}{elektra\+Lookup\+Flags}} options=\mbox{\hyperlink{group__keyset_ggada05f4bbf46fde81d0d57df86e73d914a00738455e0ae843c8720809d8287f370}{KDB\+\_\+\+O\+\_\+\+NONE}}) const
\begin{DoxyCompactList}\small\item\em Generic lookup+get for keysets. \end{DoxyCompactList}\item 
ssize\+\_\+t \mbox{\hyperlink{classkdb_1_1KeySet_a38abda394a4acf2267d5fe718e272759}{search}} (const \mbox{\hyperlink{classkdb_1_1Key}{Key}} \&amp;to\+Search) const
\begin{DoxyCompactList}\small\item\em Search in a key set, either yielding the actual index of the key, if the ley has been found within the key set, or a negative value indicating the insertion index of the key, if the key would be inserted. \end{DoxyCompactList}\item 
ssize\+\_\+t \mbox{\hyperlink{classkdb_1_1KeySet_af7478af835e648219b11a3e0268b8eaf}{search}} (std\+::string const \&amp;name) const
\begin{DoxyCompactList}\small\item\em Search in a key set, either yielding the actual index of the key, if the ley has been found within the key set, or a negative value indicating the insertion index of the key, if the key would be inserted. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
A keyset holds together a set of keys. 

Methods to manipulate Key\+Sets. A \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} is a set of keys.

Most important properties of a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}\+:


\begin{DoxyItemize}
\item Allows us to iterate over all keys (in any depth)
\item Iteration is always sorted
\item Fast key lookup
\item A \mbox{\hyperlink{classkdb_1_1Key}{Key}} may be shared among many Key\+Sets.
\end{DoxyItemize}

The most important methods of \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}\+:


\begin{DoxyItemize}
\item With \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ks\+New()}} you can create a new \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}.
\item You can append keys with \mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ks\+Append\+Key()}} or with \mbox{\hyperlink{group__keyset_ga21eb9c3a14a604ee3a8bdc779232e7b7}{ks\+Append()}} you can append a whole keyset.
\item Using \mbox{\hyperlink{group__keyset_ga60f1ddcf23272f2b29b90e92ebe9b56f}{ks\+Lookup()}} you can lookup (or pop with \mbox{\hyperlink{group__keyset_ggada05f4bbf46fde81d0d57df86e73d914a52fb5f2cc86773d393da62bebebf7984}{KDB\+\_\+\+O\+\_\+\+POP}}) a key.
\item With \mbox{\hyperlink{group__keyset_ga7474ad6b0a0fa969dbdf267ba5770eee}{ks\+Get\+Size()}} and \mbox{\hyperlink{group__keyset_gab3fb5e067c672d9fd60a4022b2ae9dd1}{ks\+At\+Cursor()}} you can iterate through the keyset. Be assured that you will get every key of the set in a stable order (parents before children).
\end{DoxyItemize}

\mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} is the most important data structure in Elektra. It makes it possible to get and store many keys at once inside the database. In addition to that, the class can be used as high level datastructure in applications and it can be used in plugins to manipulate or check configuration.

With \mbox{\hyperlink{group__keyset_gad65d2cdcbb5381194a1688e169af8a83}{ks\+Lookup\+By\+Name()}} it is possible to fetch easily specific keys out of the list of keys.

You can easily create and iterate keys\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{// create a new keyset with 3 keys}}
\DoxyCodeLine{\textcolor{comment}{// with a hint that about 20 keys will be inside}}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * myConfig = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (20, \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/name1"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}), \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/name2"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}), \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/name3"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}), \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{\textcolor{comment}{// append a key in the keyset}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ksAppendKey}} (myConfig, \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/name4"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}));}
\DoxyCodeLine{}
\DoxyCodeLine{Key * current;}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordflow}{for} (elektraCursor it = 0; it &lt; \mbox{\hyperlink{group__keyset_ga7474ad6b0a0fa969dbdf267ba5770eee}{ksGetSize}} (myConfig); ++it)}
\DoxyCodeLine{\{}
\DoxyCodeLine{        current = \mbox{\hyperlink{group__keyset_gab3fb5e067c672d9fd60a4022b2ae9dd1}{ksAtCursor}} (myConfig, it);}
\DoxyCodeLine{        printf (\textcolor{stringliteral}{"{}Key name is \%s.\(\backslash\)n"{}}, \mbox{\hyperlink{group__keyname_ga8e805c726a60da921d3736cda7813513}{keyName}} (current));}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (myConfig); \textcolor{comment}{// delete keyset and all keys appended}}

\end{DoxyCodeInclude}
 \begin{DoxyParagraph}{Copy-\/on-\/\+Write}

\end{DoxyParagraph}
Keysets employ copy-\/on-\/write techniques to minimize memory footprint. If you create a copy or a duplication of a keyset, the resulting keyset initially references the same data as the source keyset. Only if add or remove keys from a keyset additional memory is allocated.

\begin{DoxyInvariant}{Invariant}
always holds an underlying elektra keyset.
\end{DoxyInvariant}
\begin{DoxyNote}{Note}
that the cursor is mutable, so it might be changed even in const functions as described. 
\end{DoxyNote}


\doxysubsection{Constructor \&amp; Destructor Documentation}
\mbox{\Hypertarget{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}\label{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}} 
\index{kdb::KeySet@{kdb::KeySet}!KeySet@{KeySet}}
\index{KeySet@{KeySet}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{KeySet()}{KeySet()}\hspace{0.1cm}{\footnotesize\ttfamily [1/5]}}
{\footnotesize\ttfamily kdb\+::\+Key\+Set\+::\+Key\+Set (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Creates a new empty keyset with no keys. 

Allocate, initialize and return a new \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} object. Objects created with \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ks\+New()}} must be destroyed with \mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\+Del()}}.

You can use an arbitrary long list of parameters to preload the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} with a list of Keys. Either your first and only parameter is 0 or your last parameter must be KS\+\_\+\+END.

So, terminate with ks\+New(0, KS\+\_\+\+END) or ks\+New(20, ..., KS\+\_\+\+END)

\begin{DoxyWarning}{Warning}
Never use ks\+New(0, key\+New(...), KS\+\_\+\+END). If the first parameter is 0, other arguments are ignored.
\end{DoxyWarning}
The first parameter {\ttfamily alloc} defines how many Keys can be added without reallocation. If you pass any alloc size greater than 0, but less than 16, it will default to 16.

For most uses


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * keys = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (1, \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{\textcolor{comment}{// enough memory for up to 16 keys, without needing reallocation}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (keys);}

\end{DoxyCodeInclude}
 will be fine. The alloc size will be 16 and will double whenever size reaches alloc size, so it also performs well with large Key\+Sets.

You can defer the allocation of the internal array that holds the Keys, by passing 0 as the alloc size. This is useful if it is unclear whether your \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} will actually hold any Keys and you want to avoid a malloc call.


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{// Create KeySet without allocating memory for keys}}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * keys = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (0, \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{\textcolor{comment}{// The first allocation will happen in ksAppendKey}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ksAppendKey}}(keys, \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key02"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value02"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}));}
\DoxyCodeLine{\textcolor{comment}{// work with the KeySet}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (keys);}

\end{DoxyCodeInclude}
 If the size of the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} is known in advance, use the {\ttfamily alloc} parameter to hint the size of the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}.

If your application only needs up to 15 Keys you can request a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} of size 15\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * keys = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (15, \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key01"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value01"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                       \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key02"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value02"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                       \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key03"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value03"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                       \textcolor{comment}{// ...}}
\DoxyCodeLine{                       \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key15"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value15"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}), \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{\textcolor{comment}{// work with it}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (keys);}

\end{DoxyCodeInclude}
 If you start having 3 Keys, and your application needs approximately 200 up to 500 Keys, you can use\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * config = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (500, \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key1"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value1"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                         \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key2"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value2"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                         \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key3"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value3"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                         \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}}); \textcolor{comment}{// don't forget the KS\_END at the end!}}
\DoxyCodeLine{\textcolor{comment}{// work with it}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (config);}

\end{DoxyCodeInclude}
 Alloc size is 500, the size of the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} will be 3 after ks\+New. This means the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} will reallocate when appending more than 497 keys.

The main benefit of taking a list of variant length parameters is to be able to have one C-\/\+Statement for any possible \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}. If you prefer, you can always create an empty \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} and use \mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ks\+Append\+Key()}}.

\begin{DoxyPostcond}{Postcondition}
the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} is rewinded properly
\end{DoxyPostcond}

\begin{DoxyParams}{Parameters}
{\em alloc} &amp; gives a hint for how many Keys may be stored initially\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a ready to use \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} object 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 0} &amp; on memory error\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0 
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\+Del()}} to free the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} afterwards 

\mbox{\hyperlink{group__keyset_gac59e4b328245463f1451f68d5106151c}{ks\+Dup()}} to duplicate an existing \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} 

\mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ks\+Append\+Key()}} to \mbox{\hyperlink{classkdb_1_1KeySet_a0d4b2f3aa9f58d10053561135b50233e}{append}} individual Keys to a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{classkdb_1_1KeySet_a21f651ff310178951402038e590743e0}\label{classkdb_1_1KeySet_a21f651ff310178951402038e590743e0}} 
\index{kdb::KeySet@{kdb::KeySet}!KeySet@{KeySet}}
\index{KeySet@{KeySet}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{KeySet()}{KeySet()}\hspace{0.1cm}{\footnotesize\ttfamily [2/5]}}
{\footnotesize\ttfamily kdb\+::\+Key\+Set\+::\+Key\+Set (\begin{DoxyParamCaption}\item[{ckdb\+::\+Key\+Set $\ast$}]{keyset }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Take ownership of a {\ttfamily ckdb\+::\+Key\+Set $\ast$}. 

// TODO\+: use ks\+Inc\+Ref/ks\+Dec\+Ref


\begin{DoxyParams}{Parameters}
{\em keyset} &amp; the {\ttfamily \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} $\ast$} to take the ownership of \\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{classkdb_1_1KeySet_a2987b3fb1b12196399650726f1c18f02}{release()}} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{classkdb_1_1KeySet_ad8d6df839ab852fded1739ff3398d0b1}\label{classkdb_1_1KeySet_ad8d6df839ab852fded1739ff3398d0b1}} 
\index{kdb::KeySet@{kdb::KeySet}!KeySet@{KeySet}}
\index{KeySet@{KeySet}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{KeySet()}{KeySet()}\hspace{0.1cm}{\footnotesize\ttfamily [3/5]}}
{\footnotesize\ttfamily kdb\+::\+Key\+Set\+::\+Key\+Set (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} \&amp;}]{other }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Duplicate a keyset. 

This keyset will be a duplicate of the other afterwards.

\begin{DoxyNote}{Note}
that they still reference to the same Keys, so if you change key values also the keys in the original keyset will be changed.
\end{DoxyNote}
So it is shallow copy, to create a deep copy you have to \mbox{\hyperlink{classkdb_1_1KeySet_ad3f2b936d66729690e8a8a45b5074baa}{dup()}} every key (it still won\textquotesingle{}t copy metadata, but they are COW)\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet}{kdb::KeySet}} ksDeepCopy (\mbox{\hyperlink{classkdb_1_1KeySet}{kdb::KeySet}} orig)}
\DoxyCodeLine{\{}
\DoxyCodeLine{        \mbox{\hyperlink{classkdb_1_1KeySet}{kdb::KeySet}} deepCopy;}
\DoxyCodeLine{}
\DoxyCodeLine{        \textcolor{keywordflow}{for} (ssize\_t it = 0; it &lt; orig.\mbox{\hyperlink{classkdb_1_1KeySet_ab01c5c46e4c0802560b8f15886af89c4}{size}} (); ++it)}
\DoxyCodeLine{        \{}
\DoxyCodeLine{                deepCopy.\mbox{\hyperlink{classkdb_1_1KeySet_a0d4b2f3aa9f58d10053561135b50233e}{append}} (orig.\mbox{\hyperlink{classkdb_1_1KeySet_a40e32f2d9f34f03fa8ec85945f49b630}{at}} (it).\mbox{\hyperlink{classkdb_1_1Key_a51d5873239ba67ffd3b475522e647434}{dup}} ());}
\DoxyCodeLine{        \}}
\DoxyCodeLine{        \textcolor{keywordflow}{return} deepCopy;}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 \begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{classkdb_1_1KeySet_ad3f2b936d66729690e8a8a45b5074baa}{dup}} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{classkdb_1_1KeySet_a6191e93cdd67bbca63df934498d191ba}\label{classkdb_1_1KeySet_a6191e93cdd67bbca63df934498d191ba}} 
\index{kdb::KeySet@{kdb::KeySet}!KeySet@{KeySet}}
\index{KeySet@{KeySet}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{KeySet()}{KeySet()}\hspace{0.1cm}{\footnotesize\ttfamily [4/5]}}
{\footnotesize\ttfamily kdb\+::\+Key\+Set\+::\+Key\+Set (\begin{DoxyParamCaption}\item[{size\+\_\+t}]{alloc,  }\item[{}]{... }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [explicit]}}



Create a new keyset. 


\begin{DoxyParams}{Parameters}
{\em alloc} &amp; minimum number of keys to allocate \\
\hline
{\em ...} &amp; variable argument list\\
\hline
\end{DoxyParams}
Allocate, initialize and return a new \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} object. Objects created with \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ks\+New()}} must be destroyed with \mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\+Del()}}.

You can use an arbitrary long list of parameters to preload the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} with a list of Keys. Either your first and only parameter is 0 or your last parameter must be KS\+\_\+\+END.

So, terminate with ks\+New(0, KS\+\_\+\+END) or ks\+New(20, ..., KS\+\_\+\+END)

\begin{DoxyWarning}{Warning}
Never use ks\+New(0, key\+New(...), KS\+\_\+\+END). If the first parameter is 0, other arguments are ignored.
\end{DoxyWarning}
The first parameter {\ttfamily alloc} defines how many Keys can be added without reallocation. If you pass any alloc size greater than 0, but less than 16, it will default to 16.

For most uses


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * keys = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (1, \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{\textcolor{comment}{// enough memory for up to 16 keys, without needing reallocation}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (keys);}

\end{DoxyCodeInclude}
 will be fine. The alloc size will be 16 and will double whenever size reaches alloc size, so it also performs well with large Key\+Sets.

You can defer the allocation of the internal array that holds the Keys, by passing 0 as the alloc size. This is useful if it is unclear whether your \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} will actually hold any Keys and you want to avoid a malloc call.


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{// Create KeySet without allocating memory for keys}}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * keys = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (0, \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{\textcolor{comment}{// The first allocation will happen in ksAppendKey}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ksAppendKey}}(keys, \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key02"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value02"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}));}
\DoxyCodeLine{\textcolor{comment}{// work with the KeySet}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (keys);}

\end{DoxyCodeInclude}
 If the size of the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} is known in advance, use the {\ttfamily alloc} parameter to hint the size of the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}.

If your application only needs up to 15 Keys you can request a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} of size 15\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * keys = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (15, \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key01"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value01"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                       \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key02"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value02"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                       \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key03"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value03"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                       \textcolor{comment}{// ...}}
\DoxyCodeLine{                       \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key15"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value15"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}), \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{\textcolor{comment}{// work with it}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (keys);}

\end{DoxyCodeInclude}
 If you start having 3 Keys, and your application needs approximately 200 up to 500 Keys, you can use\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * config = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (500, \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key1"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value1"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                         \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key2"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value2"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                         \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key3"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value3"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                         \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}}); \textcolor{comment}{// don't forget the KS\_END at the end!}}
\DoxyCodeLine{\textcolor{comment}{// work with it}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (config);}

\end{DoxyCodeInclude}
 Alloc size is 500, the size of the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} will be 3 after ks\+New. This means the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} will reallocate when appending more than 497 keys.

The main benefit of taking a list of variant length parameters is to be able to have one C-\/\+Statement for any possible \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}. If you prefer, you can always create an empty \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} and use \mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ks\+Append\+Key()}}.

\begin{DoxyPostcond}{Postcondition}
the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} is rewinded properly
\end{DoxyPostcond}

\begin{DoxyParams}{Parameters}
{\em alloc} &amp; gives a hint for how many Keys may be stored initially\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a ready to use \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} object 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 0} &amp; on memory error\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0 
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\+Del()}} to free the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} afterwards 

\mbox{\hyperlink{group__keyset_gac59e4b328245463f1451f68d5106151c}{ks\+Dup()}} to duplicate an existing \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} 

\mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ks\+Append\+Key()}} to \mbox{\hyperlink{classkdb_1_1KeySet_a0d4b2f3aa9f58d10053561135b50233e}{append}} individual Keys to a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}
\end{DoxySeeAlso}
\begin{DoxyPrecond}{Precondition}
caller must call va\+\_\+start and va\+\_\+end 
\end{DoxyPrecond}
\begin{DoxyParagraph}{va the list of arguments}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em alloc} &amp; the allocation size \\
\hline
{\em va} &amp; the list of variable arguments \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{classkdb_1_1KeySet_ae0b2996803b9c9124cf791a1d738855c}\label{classkdb_1_1KeySet_ae0b2996803b9c9124cf791a1d738855c}} 
\index{kdb::KeySet@{kdb::KeySet}!KeySet@{KeySet}}
\index{KeySet@{KeySet}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{KeySet()}{KeySet()}\hspace{0.1cm}{\footnotesize\ttfamily [5/5]}}
{\footnotesize\ttfamily kdb\+::\+Key\+Set\+::\+Key\+Set (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structkdb_1_1VaAlloc}{Va\+Alloc}}}]{alloc,  }\item[{va\+\_\+list}]{av }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [explicit]}}



Create a new keyset. 


\begin{DoxyParams}{Parameters}
{\em alloc} &amp; minimum number of keys to allocate \\
\hline
{\em ap} &amp; variable arguments list\\
\hline
\end{DoxyParams}
Use va as first argument to use this constructor, e.\+g.\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} ks(va, 23, ...);}

\end{DoxyCode}


Allocate, initialize and return a new \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} object. Objects created with \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ks\+New()}} must be destroyed with \mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\+Del()}}.

You can use an arbitrary long list of parameters to preload the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} with a list of Keys. Either your first and only parameter is 0 or your last parameter must be KS\+\_\+\+END.

So, terminate with ks\+New(0, KS\+\_\+\+END) or ks\+New(20, ..., KS\+\_\+\+END)

\begin{DoxyWarning}{Warning}
Never use ks\+New(0, key\+New(...), KS\+\_\+\+END). If the first parameter is 0, other arguments are ignored.
\end{DoxyWarning}
The first parameter {\ttfamily alloc} defines how many Keys can be added without reallocation. If you pass any alloc size greater than 0, but less than 16, it will default to 16.

For most uses


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * keys = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (1, \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{\textcolor{comment}{// enough memory for up to 16 keys, without needing reallocation}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (keys);}

\end{DoxyCodeInclude}
 will be fine. The alloc size will be 16 and will double whenever size reaches alloc size, so it also performs well with large Key\+Sets.

You can defer the allocation of the internal array that holds the Keys, by passing 0 as the alloc size. This is useful if it is unclear whether your \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} will actually hold any Keys and you want to avoid a malloc call.


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{// Create KeySet without allocating memory for keys}}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * keys = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (0, \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{\textcolor{comment}{// The first allocation will happen in ksAppendKey}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ksAppendKey}}(keys, \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key02"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value02"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}));}
\DoxyCodeLine{\textcolor{comment}{// work with the KeySet}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (keys);}

\end{DoxyCodeInclude}
 If the size of the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} is known in advance, use the {\ttfamily alloc} parameter to hint the size of the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}.

If your application only needs up to 15 Keys you can request a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} of size 15\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * keys = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (15, \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key01"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value01"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                       \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key02"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value02"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                       \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key03"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value03"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                       \textcolor{comment}{// ...}}
\DoxyCodeLine{                       \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key15"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value15"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}), \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{\textcolor{comment}{// work with it}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (keys);}

\end{DoxyCodeInclude}
 If you start having 3 Keys, and your application needs approximately 200 up to 500 Keys, you can use\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * config = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (500, \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key1"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value1"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                         \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key2"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value2"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                         \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/sw/org/app/\#0/current/fixedConfiguration/key3"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}value3"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{                         \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}}); \textcolor{comment}{// don't forget the KS\_END at the end!}}
\DoxyCodeLine{\textcolor{comment}{// work with it}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (config);}

\end{DoxyCodeInclude}
 Alloc size is 500, the size of the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} will be 3 after ks\+New. This means the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} will reallocate when appending more than 497 keys.

The main benefit of taking a list of variant length parameters is to be able to have one C-\/\+Statement for any possible \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}. If you prefer, you can always create an empty \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} and use \mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ks\+Append\+Key()}}.

\begin{DoxyPostcond}{Postcondition}
the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} is rewinded properly
\end{DoxyPostcond}

\begin{DoxyParams}{Parameters}
{\em alloc} &amp; gives a hint for how many Keys may be stored initially\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a ready to use \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} object 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 0} &amp; on memory error\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0 
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\+Del()}} to free the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} afterwards 

\mbox{\hyperlink{group__keyset_gac59e4b328245463f1451f68d5106151c}{ks\+Dup()}} to duplicate an existing \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} 

\mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ks\+Append\+Key()}} to \mbox{\hyperlink{classkdb_1_1KeySet_a0d4b2f3aa9f58d10053561135b50233e}{append}} individual Keys to a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}
\end{DoxySeeAlso}
\begin{DoxyPrecond}{Precondition}
caller must call va\+\_\+start and va\+\_\+end 
\end{DoxyPrecond}
\begin{DoxyParagraph}{va the list of arguments}

\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em alloc} &amp; the allocation size \\
\hline
{\em va} &amp; the list of variable arguments \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{classkdb_1_1KeySet_ade654f92bddec24abad1b651e828f2b8}\label{classkdb_1_1KeySet_ade654f92bddec24abad1b651e828f2b8}} 
\index{kdb::KeySet@{kdb::KeySet}!````~KeySet@{$\sim$KeySet}}
\index{````~KeySet@{$\sim$KeySet}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{$\sim$KeySet()}{~KeySet()}}
{\footnotesize\ttfamily kdb\+::\+Key\+Set\+::$\sim$\+Key\+Set (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Deconstruct a keyset. 

A destructor for \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} objects. Every \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} created by \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ks\+New()}} must be deleted with \mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\+Del()}}.

When the reference counter of {\ttfamily ks} is non-\/zero, this function will do nothing and simply return the current value of the reference counter.

It is therefore safe to call {\ttfamily ks\+Del (ks)} on any {\ttfamily \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} $\ast$ ks}.


\begin{DoxyParams}{Parameters}
{\em ks} &amp; the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} object to delete\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 0} &amp; when the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} was freed \\
\hline
{\em -\/1} &amp; on NULL pointers \\
\hline
\end{DoxyRetVals}
\begin{DoxyReturn}{Returns}
the value of the reference counter, if it was non-\/zero
\end{DoxyReturn}
\begin{DoxySince}{Since}
1.\+0.\+0 
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ks\+New()}} for creating a new \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} 

\mbox{\hyperlink{group__keyset_ga5a656d35588d0c2f35c1e58653e46791}{ks\+Inc\+Ref()}} for more information about the reference counter 
\end{DoxySeeAlso}


\doxysubsection{Member Function Documentation}
\mbox{\Hypertarget{classkdb_1_1KeySet_a0d4b2f3aa9f58d10053561135b50233e}\label{classkdb_1_1KeySet_a0d4b2f3aa9f58d10053561135b50233e}} 
\index{kdb::KeySet@{kdb::KeySet}!append@{append}}
\index{append@{append}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{append()}{append()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily ssize\+\_\+t kdb\+::\+Key\+Set\+::append (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{classkdb_1_1Key}{Key}} \&amp;}]{to\+Append }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



append a key 


\begin{DoxyParams}{Parameters}
{\em to\+Append} &amp; key to append\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of keys in the keyset
\end{DoxyReturn}
Appends a \mbox{\hyperlink{classkdb_1_1Key}{Key}} to the end of {\ttfamily ks}. Hands the ownership of the \mbox{\hyperlink{classkdb_1_1Key}{Key}} {\ttfamily to\+Append} to the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} {\ttfamily ks}. ks\+Del(ks) uses key\+Del(k) to delete every \mbox{\hyperlink{classkdb_1_1Key}{Key}} unless it got its reference counter incremented by \mbox{\hyperlink{group__key_ga0b477b584c8be68519a8d92f90355136}{key\+Inc\+Ref()}}, e.\+g. by another \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} that contains this \mbox{\hyperlink{classkdb_1_1Key}{Key}}.

The reference counter of the \mbox{\hyperlink{classkdb_1_1Key}{Key}} will be incremented to indicate this ownership, and thus {\ttfamily to\+Append} is not const.

\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__key_ga0d82ce48529821aa43d82c035ba30c4f}{key\+Get\+Ref()}}
\end{DoxySeeAlso}
If the \mbox{\hyperlink{classkdb_1_1Key}{Key}}\textquotesingle{}s name already exists in the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}, it will be replaced with the new \mbox{\hyperlink{classkdb_1_1Key}{Key}}.

\mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ks\+Append\+Key()}} will also lock the \mbox{\hyperlink{classkdb_1_1Key}{Key}}\textquotesingle{}s name from {\ttfamily to\+Append}. This is necessary so that the order of the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} cannot be destroyed via calls to \mbox{\hyperlink{group__keyname_ga7699091610e7f3f43d2949514a4b35d9}{key\+Set\+Name()}}.

The \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} internal cursor will be set to the new \mbox{\hyperlink{classkdb_1_1Key}{Key}}.

It is safe to directly append newly created Keys\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * ks = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (1, \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ksAppendKey}} (ks, \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/my/new/key"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}));}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (ks);}
\DoxyCodeLine{\textcolor{comment}{// key deleted, too!}}

\end{DoxyCodeInclude}
 If you want the key to outlive the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}, make sure to do proper ref counting\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * ks = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (1, \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{Key * k = \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/ref/key"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}});}
\DoxyCodeLine{\mbox{\hyperlink{group__key_ga0b477b584c8be68519a8d92f90355136}{keyIncRef}} (k);}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ksAppendKey}} (ks, k);}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (ks);}
\DoxyCodeLine{\textcolor{comment}{// now we still can work with the key k!}}
\DoxyCodeLine{\mbox{\hyperlink{group__key_ga0c4d031ab6ee02cf884c64e28a2ad151}{keyDecRef}} (k);}
\DoxyCodeLine{\mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{keyDel}} (k);}

\end{DoxyCodeInclude}
 You can duplicate the \mbox{\hyperlink{classkdb_1_1Key}{Key}} to avoid aliasing, but then the \mbox{\hyperlink{classkdb_1_1Key}{Key}} in the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} has another identity\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * ks = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (1, \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{Key * k = \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}user:/ref/key"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}});}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ksAppendKey}} (ks, keyDup (k, \mbox{\hyperlink{group__key_gga9ff42b1e9a97222562bfda3dd1f8c735a3e04e17514f102f1e9217308d44e7612}{KEY\_CP\_ALL}}));}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (ks);}
\DoxyCodeLine{\textcolor{comment}{// now we still can work with the key k!}}
\DoxyCodeLine{\mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{keyDel}} (k);}

\end{DoxyCodeInclude}
 
\begin{DoxyParams}{Parameters}
{\em ks} &amp; \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} where {\ttfamily to\+Append} should be append \\
\hline
{\em to\+Append} &amp; \mbox{\hyperlink{classkdb_1_1Key}{Key}} that will be appended to {\ttfamily ks} or deleted\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the size of the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} after appending 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em -\/1} &amp; on NULL pointers \\
\hline
{\em -\/1} &amp; if appending failed (only on memory problems). The \mbox{\hyperlink{classkdb_1_1Key}{Key}} will be deleted then.\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0 
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__keyset_ga21eb9c3a14a604ee3a8bdc779232e7b7}{ks\+Append()}} for appending a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} to another \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} 

\mbox{\hyperlink{group__key_ga0b477b584c8be68519a8d92f90355136}{key\+Inc\+Ref()}} for manually increasing a \mbox{\hyperlink{classkdb_1_1Key}{Key}}\textquotesingle{}s reference counter 
\end{DoxySeeAlso}
\mbox{\Hypertarget{classkdb_1_1KeySet_ac9cbdc933d7171037d47c6d4d78595d1}\label{classkdb_1_1KeySet_ac9cbdc933d7171037d47c6d4d78595d1}} 
\index{kdb::KeySet@{kdb::KeySet}!append@{append}}
\index{append@{append}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{append()}{append()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily ssize\+\_\+t kdb\+::\+Key\+Set\+::append (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} \&amp;}]{to\+Append }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



append a keyset 


\begin{DoxyParams}{Parameters}
{\em to\+Append} &amp; keyset to append\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of keys in the keyset
\end{DoxyReturn}
Append all Keys in {\ttfamily to\+Append} to the end of the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} {\ttfamily ks}. {\ttfamily to\+Append} \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} will be left unchanged.

If a \mbox{\hyperlink{classkdb_1_1Key}{Key}} is both in {\ttfamily to\+Append} and {\ttfamily ks}, the \mbox{\hyperlink{classkdb_1_1Key}{Key}} in {\ttfamily ks} will be overwritten.

\begin{DoxyPostcond}{Postcondition}
Sorted \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} ks with all Keys it had before and additionally the Keys from to\+Append
\end{DoxyPostcond}

\begin{DoxyParams}{Parameters}
{\em ks} &amp; the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} that will receive the Keys \\
\hline
{\em to\+Append} &amp; the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} that provides the Keys that will be transferred\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the size of the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} {\ttfamily ks} after transfer 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em -\/1} &amp; on NULL pointers\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0 
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ks\+Append\+Key()}} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{classkdb_1_1KeySet_a40e32f2d9f34f03fa8ec85945f49b630}\label{classkdb_1_1KeySet_a40e32f2d9f34f03fa8ec85945f49b630}} 
\index{kdb::KeySet@{kdb::KeySet}!at@{at}}
\index{at@{at}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{at()}{at()}}
{\footnotesize\ttfamily \mbox{\hyperlink{classkdb_1_1Key}{Key}} kdb\+::\+Key\+Set\+::at (\begin{DoxyParamCaption}\item[{elektra\+Cursor}]{pos }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Lookup a key by index. 


\begin{DoxyParams}{Parameters}
{\em pos} &amp; cursor position\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the found key 
\end{DoxyReturn}
\mbox{\Hypertarget{classkdb_1_1KeySet_a38f5159e39758aa632421d2fe7440633}\label{classkdb_1_1KeySet_a38f5159e39758aa632421d2fe7440633}} 
\index{kdb::KeySet@{kdb::KeySet}!clear@{clear}}
\index{clear@{clear}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{clear()}{clear()}}
{\footnotesize\ttfamily void kdb\+::\+Key\+Set\+::clear (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Clear the keyset. 

Keyset will be empty afterwards. \mbox{\Hypertarget{classkdb_1_1KeySet_a28fd33fdaecf1d57d4dddac7058f5d38}\label{classkdb_1_1KeySet_a28fd33fdaecf1d57d4dddac7058f5d38}} 
\index{kdb::KeySet@{kdb::KeySet}!copy@{copy}}
\index{copy@{copy}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{copy()}{copy()}}
{\footnotesize\ttfamily void kdb\+::\+Key\+Set\+::copy (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} \&amp;}]{other }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Copy a keyset. 

Replaces all keys in {\ttfamily this} with the ones from {\ttfamily other}. This is only a shallow copy. For a deep copy you need to manually \mbox{\hyperlink{classkdb_1_1Key_a51d5873239ba67ffd3b475522e647434}{Key\+::dup}} every key.


\begin{DoxyParams}{Parameters}
{\em other} &amp; other keyset to copy\\
\hline
\end{DoxyParams}
Replace the content of a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} with another one. Most often you may want a duplicate of a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}, see \mbox{\hyperlink{group__keyset_gac59e4b328245463f1451f68d5106151c}{ks\+Dup()}} or append keys, see \mbox{\hyperlink{group__keyset_ga21eb9c3a14a604ee3a8bdc779232e7b7}{ks\+Append()}}. In some situations you need to copy Keys from a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} to another \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}, for which this function exists.

\begin{DoxyNote}{Note}
You can also use it to clear a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} when you pass a NULL pointer as {\ttfamily source}.
\end{DoxyNote}
\begin{DoxyParagraph}{Implementation\+:}
First all Keys in {\ttfamily dest} will be deleted. Afterwards the content of {\ttfamily source} will be added to the destination.
\end{DoxyParagraph}
A flat copy is made, so Keys will not be duplicated, but their reference counter is updated, so both Key\+Sets need to be deleted via \mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\+Del()}}.


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keywordtype}{int} f (\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} *ks)}
\DoxyCodeLine{\{}
\DoxyCodeLine{        \mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} *c = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (20, ..., \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{        \textcolor{comment}{// c receives keys}}
\DoxyCodeLine{        \mbox{\hyperlink{group__keyset_gaba1f1dbea191f4d7e7eb3e4296ae7d5e}{ksCopy}} (ks, c); \textcolor{comment}{// pass the KeySet to the caller}}
\DoxyCodeLine{}
\DoxyCodeLine{        \mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (c);}
\DoxyCodeLine{\}       \textcolor{comment}{// caller needs to ksDel (ks)}}

\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em source} &amp; an initialized \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} or NULL \\
\hline
{\em dest} &amp; an initialized \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}, where the Keys from {\ttfamily source} get copied to\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 1} &amp; on success \\
\hline
{\em 0} &amp; if {\ttfamily dest} was cleared successfully ({\ttfamily source} is NULL) \\
\hline
{\em -\/1} &amp; when {\ttfamily dest} is a NULL pointer\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0 
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ks\+New()}} for creating a new \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} 

\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\+Del()}} for deleting an existing \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} 

\mbox{\hyperlink{group__keyset_gac59e4b328245463f1451f68d5106151c}{ks\+Dup()}} for duplicating an existing \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} 

\mbox{\hyperlink{group__key_ga505575ebef060066984fe0f590081e37}{key\+Copy()}} for copying Keys 
\end{DoxySeeAlso}
\mbox{\Hypertarget{classkdb_1_1KeySet_ab283da798a7670d5c3f0e1a5b821e666}\label{classkdb_1_1KeySet_ab283da798a7670d5c3f0e1a5b821e666}} 
\index{kdb::KeySet@{kdb::KeySet}!cut@{cut}}
\index{cut@{cut}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{cut()}{cut()}}
{\footnotesize\ttfamily \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} kdb\+::\+Key\+Set\+::cut (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classkdb_1_1Key}{Key}}}]{k }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Cuts out all Keys from \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} {\ttfamily ks} that are below or at {\ttfamily cutpoint}. 

Searches for the {\ttfamily cutpoint} inside the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} {\ttfamily ks}. If found, it cuts out this \mbox{\hyperlink{classkdb_1_1Key}{Key}} and everything which is below (see \mbox{\hyperlink{group__keytest_ga03332b5d97c76a4fd2640aca4762b8df}{key\+Is\+Below()}}) this \mbox{\hyperlink{classkdb_1_1Key}{Key}}. These Keys will be missing in the keyset {\ttfamily ks}. Instead, they will be moved to the returned \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}. If {\ttfamily cutpoint} is not found an empty \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} is returned and {\ttfamily ks} is not changed.

The cursor will stay at the same \mbox{\hyperlink{classkdb_1_1Key}{Key}} as it was before. If the cursor was inside the region of cut (moved) Keys, the cursor will be set to the \mbox{\hyperlink{classkdb_1_1Key}{Key}} before the {\ttfamily cutpoint}.

If you use \mbox{\hyperlink{group__keyset_ga6b00cf82b59af4d883a9bad6cf4a4a4a}{ks\+Cut()}} on a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} you got from \mbox{\hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdb\+Get()}} and plan to use \mbox{\hyperlink{group__kdb_ga11436b058408f83d303ca5e996832bcf}{kdb\+Set()}} later, make sure that you keep all Keys that should not be removed permanently. You have to keep the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} that was returned and the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} {\ttfamily ks}.

\begin{DoxyParagraph}{Example\+:}

\end{DoxyParagraph}
You have the keyset {\ttfamily ks\+:} 
\begin{DoxyItemize}
\item {\ttfamily system\+:/mountpoint/interest} 
\item {\ttfamily system\+:/mountpoint/interest/folder} 
\item {\ttfamily system\+:/mountpoint/interest/folder/key1} 
\item {\ttfamily system\+:/mountpoint/interest/folder/key2} 
\item {\ttfamily system\+:/mountpoint/other/key1} 
\end{DoxyItemize}

When you use 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{        Key * parentKey = \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}system:/mountpoint/interest"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}});}
\DoxyCodeLine{        KDB * \mbox{\hyperlink{namespacekdb}{kdb}} = \mbox{\hyperlink{group__kdb_ga844e1299a84c3fbf1d3a905c5c893ba5}{kdbOpen}} (NULL, parentKey);}
\DoxyCodeLine{        \mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * ks = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (0, \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{        \mbox{\hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdbGet}} (\mbox{\hyperlink{namespacekdb}{kdb}}, ks, parentKey);}
\DoxyCodeLine{        \mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * returned = \mbox{\hyperlink{group__keyset_ga6b00cf82b59af4d883a9bad6cf4a4a4a}{ksCut}} (ks, parentKey);}
\DoxyCodeLine{        \mbox{\hyperlink{group__kdb_ga11436b058408f83d303ca5e996832bcf}{kdbSet}} (\mbox{\hyperlink{namespacekdb}{kdb}}, ks, parentKey); \textcolor{comment}{// all keys below cutpoint are now removed}}
\DoxyCodeLine{        \mbox{\hyperlink{group__kdb_gadb54dc9fda17ee07deb9444df745c96f}{kdbClose}} (\mbox{\hyperlink{namespacekdb}{kdb}}, parentKey);}

\end{DoxyCodeInclude}
 Then in {\ttfamily returned} are\+:
\begin{DoxyItemize}
\item {\ttfamily system\+:/mountpoint/interest} 
\item {\ttfamily system\+:/mountpoint/interest/folder} 
\item {\ttfamily system\+:/mountpoint/interest/folder/key1} 
\item {\ttfamily system\+:/mountpoint/interest/folder/key2} 
\end{DoxyItemize}

And in {\ttfamily ks} are\+:
\begin{DoxyItemize}
\item {\ttfamily system\+:/mountpoint/other/key1} 
\end{DoxyItemize}

So \mbox{\hyperlink{group__kdb_ga11436b058408f83d303ca5e996832bcf}{kdb\+Set()}} permanently removes all keys at or below {\ttfamily system\+:/mountpoint/interest}.


\begin{DoxyParams}{Parameters}
{\em ks} &amp; the Keyset to cut. It will be modified by removing all Keys at or below the cutpoint. \\
\hline
{\em cutpoint} &amp; the point where to cut out the Keyset\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a new allocated \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} which needs to be deleted with \mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\+Del()}}. The \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} consists of all Keys (of the original \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} ks) below the cutpoint. If the \mbox{\hyperlink{classkdb_1_1Key}{Key}} cutpoint exists, it will also be appended. 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 0} &amp; on NULL pointers, no \mbox{\hyperlink{classkdb_1_1Key}{Key}} name or allocation problems\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0 
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdb\+Get()}} for an explanation on why you might \mbox{\hyperlink{classkdb_1_1KeySet_a65208974b44da0162ef70dd7a173748f}{get}} more Keys than you requested. 
\end{DoxySeeAlso}
\mbox{\Hypertarget{classkdb_1_1KeySet_ad3f2b936d66729690e8a8a45b5074baa}\label{classkdb_1_1KeySet_ad3f2b936d66729690e8a8a45b5074baa}} 
\index{kdb::KeySet@{kdb::KeySet}!dup@{dup}}
\index{dup@{dup}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{dup()}{dup()}}
{\footnotesize\ttfamily ckdb\+::\+Key\+Set $\ast$ kdb\+::\+Key\+Set\+::dup (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Duplicate a keyset. 

\begin{DoxyReturn}{Returns}
a copy of the keys
\end{DoxyReturn}
This is only a shallow copy. For a deep copy you need to dup every key.

Return a duplicate of a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}. Objects created with \mbox{\hyperlink{group__keyset_gac59e4b328245463f1451f68d5106151c}{ks\+Dup()}} must be destroyed with \mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\+Del()}}.

Memory will be allocated as needed for dynamic properties, so you need to \mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\+Del()}} the returned pointer.

A flat copy is made, so the Keys will not be duplicated, but their reference counter is updated, so both Key\+Sets need to be deleted via \mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\+Del()}}.


\begin{DoxyParams}{Parameters}
{\em source} &amp; has to be an initialized \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a flat copy of source on success 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 0} &amp; on NULL pointer\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0 
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ks\+New()}} for creating a new \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} 

\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ks\+Del()}} for deleting a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} 

key\+Dup() for \mbox{\hyperlink{classkdb_1_1Key}{Key}} duplication 
\end{DoxySeeAlso}
\mbox{\Hypertarget{classkdb_1_1KeySet_a65208974b44da0162ef70dd7a173748f}\label{classkdb_1_1KeySet_a65208974b44da0162ef70dd7a173748f}} 
\index{kdb::KeySet@{kdb::KeySet}!get@{get}}
\index{get@{get}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{get()}{get()}}
{\footnotesize\ttfamily template$&lt;$typename T $&gt;$ \\
T kdb\+::\+Key\+Set\+::get (\begin{DoxyParamCaption}\item[{std\+::string const \&amp;}]{name,  }\item[{const \mbox{\hyperlink{group__keyset_gada05f4bbf46fde81d0d57df86e73d914}{elektra\+Lookup\+Flags}}}]{options = {\ttfamily \mbox{\hyperlink{group__keyset_ggada05f4bbf46fde81d0d57df86e73d914a00738455e0ae843c8720809d8287f370}{KDB\+\_\+\+O\+\_\+\+NONE}}} }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Generic lookup+get for keysets. 


\begin{DoxyParams}{Parameters}
{\em name} &amp; the key name to get \\
\hline
{\em options} &amp; the options to be passed to \mbox{\hyperlink{classkdb_1_1KeySet_a2b8537e388edfbb6941d771106c0ae3a}{lookup()}}\\
\hline
\end{DoxyParams}

\begin{DoxyExceptions}{Exceptions}
{\em Key\+Not\+Found\+Exception} &amp; if no key found\\
\hline
\end{DoxyExceptions}
\begin{DoxyNote}{Note}
To specialize more complex types (which are generic themselves) you can also specialize Key\+Set\+Type\+Wrapper$&lt;$\+T$&gt;$.
\end{DoxyNote}
Use 
\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#include &lt;\mbox{\hyperlink{keysetget_8hpp}{keysetget.hpp}}&gt;}}

\end{DoxyCode}
 to include specializations for std types.

\begin{DoxyReturn}{Returns}
the requested type 
\end{DoxyReturn}
\mbox{\Hypertarget{classkdb_1_1KeySet_a4e9a3906e0b18a783f8a6e8bdbec9ed0}\label{classkdb_1_1KeySet_a4e9a3906e0b18a783f8a6e8bdbec9ed0}} 
\index{kdb::KeySet@{kdb::KeySet}!getKeySet@{getKeySet}}
\index{getKeySet@{getKeySet}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{getKeySet()}{getKeySet()}}
{\footnotesize\ttfamily ckdb\+::\+Key\+Set $\ast$ kdb\+::\+Key\+Set\+::get\+Key\+Set (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Passes out the raw keyset pointer. 

This function exists so that pure C functions that do not have a C++ binding can be called.

\begin{DoxyReturn}{Returns}
pointer to internal ckdb \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} 
\end{DoxyReturn}
\mbox{\Hypertarget{classkdb_1_1KeySet_a2b8537e388edfbb6941d771106c0ae3a}\label{classkdb_1_1KeySet_a2b8537e388edfbb6941d771106c0ae3a}} 
\index{kdb::KeySet@{kdb::KeySet}!lookup@{lookup}}
\index{lookup@{lookup}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{lookup()}{lookup()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily \mbox{\hyperlink{classkdb_1_1Key}{Key}} kdb\+::\+Key\+Set\+::lookup (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{classkdb_1_1Key}{Key}} \&amp;}]{key,  }\item[{const \mbox{\hyperlink{group__keyset_gada05f4bbf46fde81d0d57df86e73d914}{elektra\+Lookup\+Flags}}}]{options = {\ttfamily \mbox{\hyperlink{group__keyset_ggada05f4bbf46fde81d0d57df86e73d914a00738455e0ae843c8720809d8287f370}{KDB\+\_\+\+O\+\_\+\+NONE}}} }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Look for a \mbox{\hyperlink{classkdb_1_1Key}{Key}} contained in {\ttfamily ks} that matches the name of the {\ttfamily key}. 

\begin{DoxyNote}{Note}
Applications should only use \mbox{\hyperlink{group__keyset_ga60f1ddcf23272f2b29b90e92ebe9b56f}{ks\+Lookup()}} with cascading Keys (\mbox{\hyperlink{classkdb_1_1Key}{Key}} name starting with {\ttfamily /}). Furthermore, a lookup should be done for every \mbox{\hyperlink{classkdb_1_1Key}{Key}} (also when iterating over Keys) so that the specifications are honored correctly. Keys of all namespaces need to be present so that \mbox{\hyperlink{group__keyset_ga60f1ddcf23272f2b29b90e92ebe9b56f}{ks\+Lookup()}} can work correctly, so make sure to also use \mbox{\hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdb\+Get()}} with a cascading \mbox{\hyperlink{classkdb_1_1Key}{Key}}.
\end{DoxyNote}
\mbox{\hyperlink{group__keyset_ga60f1ddcf23272f2b29b90e92ebe9b56f}{ks\+Lookup()}} is designed to let you work with a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} containing all Keys of the application. The idea is to fully \mbox{\hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdb\+Get()}} the whole configuration of your application and process it all at once with many {\ttfamily \mbox{\hyperlink{group__keyset_ga60f1ddcf23272f2b29b90e92ebe9b56f}{ks\+Lookup()}}}.

This function is efficient (at least using binary search). Together with \mbox{\hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdb\+Get()}}, which you can use to load the whole configuration, you can write very effective and short code for configuration\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{Key * key = \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}/sw/tests/myapp/\#0/current/"{}},  \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}});}
\DoxyCodeLine{KDB * handle = \mbox{\hyperlink{group__kdb_ga844e1299a84c3fbf1d3a905c5c893ba5}{kdbOpen}} (NULL, key);}
\DoxyCodeLine{\mbox{\hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdbGet}} (handle, myConfig, key);}
\DoxyCodeLine{Key * result = \mbox{\hyperlink{group__keyset_gad65d2cdcbb5381194a1688e169af8a83}{ksLookupByName}} (myConfig, \textcolor{stringliteral}{"{}/sw/tests/myapp/\#0/current/testkey1"{}}, 0);}

\end{DoxyCodeInclude}
 This is the way programs should get their configuration and search for the values. It is guaranteed, that more namespaces can be added easily and that all values can be set by admin and user. Furthermore, using the kdb-\/tool, it is possible to introspect which values an application will get (by doing the same cascading lookup).

If found, a pointer to the \mbox{\hyperlink{classkdb_1_1Key}{Key}} is returned. If not found a NULL pointer is returned.

Cascading lookups will by default search in all namespaces (proc\+:/, dir\+:/, user\+:/ and system\+:/), but will also correctly consider the specification (=metadata) in spec\+:/\+:


\begin{DoxyItemize}
\item {\ttfamily override/\#} will make sure that another \mbox{\hyperlink{classkdb_1_1Key}{Key}} is considered before
\item {\ttfamily namespace/\#} will change the number and/or order in which the namespaces are searched
\item {\ttfamily fallback/\#} will search for other Keys when the other possibilities up to now were not successful
\item {\ttfamily default} to return the given value when not even {\ttfamily fallback} Keys were found.
\end{DoxyItemize}

\begin{DoxyNote}{Note}
override and fallback work recursively, while default does not.
\end{DoxyNote}
This process is very flexible, but it would be boring to manually follow all this links to find out which \mbox{\hyperlink{classkdb_1_1Key}{Key}} will be taken in the end. Use {\ttfamily kdb get -\/v} to trace the Keys.

\begin{DoxyParagraph}{KDB\+\_\+\+O\+\_\+\+POP}
When \mbox{\hyperlink{group__keyset_ggada05f4bbf46fde81d0d57df86e73d914a52fb5f2cc86773d393da62bebebf7984}{KDB\+\_\+\+O\+\_\+\+POP}} is set the \mbox{\hyperlink{classkdb_1_1Key}{Key}} which was found will be \mbox{\hyperlink{group__keyset_gae42530b04defb772059de0600159cf69}{ks\+Pop()}}ed.
\end{DoxyParagraph}
\begin{DoxyNote}{Note}
Like in \mbox{\hyperlink{group__keyset_gae42530b04defb772059de0600159cf69}{ks\+Pop()}} the popped \mbox{\hyperlink{classkdb_1_1Key}{Key}} always needs to be \mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del()}} afterwards, even if it is appended to another \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}.
\end{DoxyNote}

\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{keywordtype}{void} f (\mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * iterator, \mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * \mbox{\hyperlink{classkdb_1_1KeySet_a2b8537e388edfbb6941d771106c0ae3a}{lookup}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{        \mbox{\hyperlink{classkdb_1_1KeySet_a4eac9850fa4f06c07a5306befc3e4377}{KeySet}} * \mbox{\hyperlink{classkdb_1_1KeySet_a0d4b2f3aa9f58d10053561135b50233e}{append}} = \mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (\mbox{\hyperlink{group__keyset_ga7474ad6b0a0fa969dbdf267ba5770eee}{ksGetSize}} (\mbox{\hyperlink{classkdb_1_1KeySet_a2b8537e388edfbb6941d771106c0ae3a}{lookup}}), \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{        ssize\_t ksSize = \mbox{\hyperlink{group__keyset_ga7474ad6b0a0fa969dbdf267ba5770eee}{ksGetSize}} (iterator);}
\DoxyCodeLine{}
\DoxyCodeLine{        \textcolor{keywordflow}{for} (elektraCursor it = 0; it &lt; ksSize; ++it)}
\DoxyCodeLine{        \{}
\DoxyCodeLine{                Key * current = \mbox{\hyperlink{group__keyset_gab3fb5e067c672d9fd60a4022b2ae9dd1}{ksAtCursor}} (iterator, it);}
\DoxyCodeLine{                Key * key = \mbox{\hyperlink{group__keyset_ga60f1ddcf23272f2b29b90e92ebe9b56f}{ksLookup}} (\mbox{\hyperlink{classkdb_1_1KeySet_a2b8537e388edfbb6941d771106c0ae3a}{lookup}}, current, \mbox{\hyperlink{group__keyset_ggada05f4bbf46fde81d0d57df86e73d914a52fb5f2cc86773d393da62bebebf7984}{KDB\_O\_POP}});}
\DoxyCodeLine{                \textcolor{comment}{// do something...}}
\DoxyCodeLine{                \mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ksAppendKey}} (\mbox{\hyperlink{classkdb_1_1KeySet_a0d4b2f3aa9f58d10053561135b50233e}{append}}, key); \textcolor{comment}{// now append it to append, not lookup!}}
\DoxyCodeLine{                \mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{keyDel}} (key);                \textcolor{comment}{// make sure to ALWAYS delete poped keys.}}
\DoxyCodeLine{        \}}
\DoxyCodeLine{        \mbox{\hyperlink{group__keyset_ga21eb9c3a14a604ee3a8bdc779232e7b7}{ksAppend}} (\mbox{\hyperlink{classkdb_1_1KeySet_a2b8537e388edfbb6941d771106c0ae3a}{lookup}}, \mbox{\hyperlink{classkdb_1_1KeySet_a0d4b2f3aa9f58d10053561135b50233e}{append}});}
\DoxyCodeLine{        \textcolor{comment}{// now lookup needs to be sorted only once, append never}}
\DoxyCodeLine{        \mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (\mbox{\hyperlink{classkdb_1_1KeySet_a0d4b2f3aa9f58d10053561135b50233e}{append}});}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 This is also a nice example how a complete application with \mbox{\hyperlink{group__keyset_ga60f1ddcf23272f2b29b90e92ebe9b56f}{ks\+Lookup()}} can look like.

\begin{DoxyParagraph}{KDB\+\_\+\+O\+\_\+\+DEL}
Passing \mbox{\hyperlink{group__keyset_ggada05f4bbf46fde81d0d57df86e73d914a66a5380c120f25f28f49848c4a863ead}{KDB\+\_\+\+O\+\_\+\+DEL}} will cause the deletion of the parameter {\ttfamily key} using \mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del()}}.
\end{DoxyParagraph}
\begin{DoxyParagraph}{Hybrid search}
When Elektra is compiled with {\ttfamily ENABLE\+\_\+\+OPTIMIZATIONS=ON} a hybrid search decides dynamically between the binary search and the \href{https://master.libelektra.org/doc/dev/data-structures.md\#order-preserving-minimal-perfect-hash-map-aka-opmphm}{\texttt{ OPMPHM}}. The hybrid search can be overruled by passing \mbox{\hyperlink{kdbhelper_8h_a93673533c4c8eb1fdfca76b98c5f49b0afe9f6ff6e374540baf600a918b07ee6e}{KDB\+\_\+\+O\+\_\+\+OPMPHM}} or \mbox{\hyperlink{kdbhelper_8h_a93673533c4c8eb1fdfca76b98c5f49b0ac67a43bd273203575090d26010f6c995}{KDB\+\_\+\+O\+\_\+\+BINSEARCH}} in the options to \mbox{\hyperlink{group__keyset_ga60f1ddcf23272f2b29b90e92ebe9b56f}{ks\+Lookup()}}.
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em ks} &amp; the \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} that should be searched \\
\hline
{\em key} &amp; the \mbox{\hyperlink{classkdb_1_1Key}{Key}} object you are looking for \\
\hline
{\em options} &amp; of type \mbox{\hyperlink{group__keyset_gada05f4bbf46fde81d0d57df86e73d914}{elektra\+Lookup\+Flags}} with some {\ttfamily KDB\+\_\+\+O\+\_\+$\ast$} option bits -\/ as explained above\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
pointer to the \mbox{\hyperlink{classkdb_1_1Key}{Key}} found 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em 0} &amp; if no \mbox{\hyperlink{classkdb_1_1Key}{Key}} has been found \\
\hline
{\em 0} &amp; on NULL pointers\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0 
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__keyset_gad65d2cdcbb5381194a1688e169af8a83}{ks\+Lookup\+By\+Name()}} to \mbox{\hyperlink{classkdb_1_1KeySet_a38abda394a4acf2267d5fe718e272759}{search}} by a name given by a string 

\mbox{\hyperlink{group__keyset_ga7474ad6b0a0fa969dbdf267ba5770eee}{ks\+Get\+Size()}}, \mbox{\hyperlink{group__keyset_gab3fb5e067c672d9fd60a4022b2ae9dd1}{ks\+At\+Cursor()}} for iterating over a \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}
\end{DoxySeeAlso}
\begin{DoxyNote}{Note}
That the internal key cursor will point to the found key 
\end{DoxyNote}
\mbox{\Hypertarget{classkdb_1_1KeySet_a0ef071747608900be478219e4a040612}\label{classkdb_1_1KeySet_a0ef071747608900be478219e4a040612}} 
\index{kdb::KeySet@{kdb::KeySet}!lookup@{lookup}}
\index{lookup@{lookup}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{lookup()}{lookup()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily \mbox{\hyperlink{classkdb_1_1Key}{Key}} kdb\+::\+Key\+Set\+::lookup (\begin{DoxyParamCaption}\item[{std\+::string const \&amp;}]{name,  }\item[{const \mbox{\hyperlink{group__keyset_gada05f4bbf46fde81d0d57df86e73d914}{elektra\+Lookup\+Flags}}}]{options = {\ttfamily \mbox{\hyperlink{group__keyset_ggada05f4bbf46fde81d0d57df86e73d914a00738455e0ae843c8720809d8287f370}{KDB\+\_\+\+O\+\_\+\+NONE}}} }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Lookup a key by name. 


\begin{DoxyParams}{Parameters}
{\em name} &amp; the name to look for \\
\hline
{\em options} &amp; some options to pass\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the found key 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{classkdb_1_1KeySet_a2b8537e388edfbb6941d771106c0ae3a}{lookup}} (const \mbox{\hyperlink{classkdb_1_1Key}{Key}} \&amp;\mbox{\hyperlink{group__key}{Key}}, const \mbox{\hyperlink{group__keyset_gada05f4bbf46fde81d0d57df86e73d914}{elektra\+Lookup\+Flags}} options)
\end{DoxySeeAlso}
\begin{DoxyNote}{Note}
That the internal key cursor will point to the found key 
\end{DoxyNote}
\mbox{\Hypertarget{classkdb_1_1KeySet_a1c54736b7206bc2253d02a5bf4b3ccfb}\label{classkdb_1_1KeySet_a1c54736b7206bc2253d02a5bf4b3ccfb}} 
\index{kdb::KeySet@{kdb::KeySet}!operator=@{operator=}}
\index{operator=@{operator=}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{operator=()}{operator=()}}
{\footnotesize\ttfamily \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} \&amp; kdb\+::\+Key\+Set\+::operator= (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} const \&amp;}]{other }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Duplicate a keyset. 

This keyset will be a duplicate of the other afterwards.

\begin{DoxyNote}{Note}
that they still reference to the same Keys, so if you change key values also the keys in the original keyset will be changed. 
\end{DoxyNote}
\mbox{\Hypertarget{classkdb_1_1KeySet_a7f207457a1c12633a1a5301a3a1bbaed}\label{classkdb_1_1KeySet_a7f207457a1c12633a1a5301a3a1bbaed}} 
\index{kdb::KeySet@{kdb::KeySet}!pop@{pop}}
\index{pop@{pop}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{pop()}{pop()}}
{\footnotesize\ttfamily \mbox{\hyperlink{classkdb_1_1Key}{Key}} kdb\+::\+Key\+Set\+::pop (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Remove and return the last \mbox{\hyperlink{classkdb_1_1Key}{Key}} of {\ttfamily ks}. 

The reference counter of the \mbox{\hyperlink{classkdb_1_1Key}{Key}} will be decremented by one.

The \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}\textquotesingle{}s cursor will not be affected if it did not point to the popped \mbox{\hyperlink{classkdb_1_1Key}{Key}}.

\begin{DoxyNote}{Note}
You need to \mbox{\hyperlink{group__key_ga3df95bbc2494e3e6703ece5639be5bb1}{key\+Del()}} the \mbox{\hyperlink{classkdb_1_1Key}{Key}} afterwards, if you don\textquotesingle{}t append it to another \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}}. It has the same semantics like a \mbox{\hyperlink{classkdb_1_1Key}{Key}} allocated with \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{key\+New()}} or key\+Dup().
\end{DoxyNote}

\begin{DoxyCode}{0}
\DoxyCodeLine{ks1=\mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}}(0, \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{ks2=\mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}}(0, \mbox{\hyperlink{group__keyset_ga7a28fce3773b2c873c94ac80b8b4cd54}{KS\_END}});}
\DoxyCodeLine{}
\DoxyCodeLine{k1=\mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}}(\textcolor{stringliteral}{"{}user:/name"{}}, \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}); \textcolor{comment}{// ref counter 0}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ksAppendKey}}(ks1, k1); \textcolor{comment}{// ref counter 1}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ksAppendKey}}(ks2, k1); \textcolor{comment}{// ref counter 2}}
\DoxyCodeLine{}
\DoxyCodeLine{k1=\mbox{\hyperlink{group__keyset_gae42530b04defb772059de0600159cf69}{ksPop}} (ks1); \textcolor{comment}{// ref counter 1}}
\DoxyCodeLine{k1=\mbox{\hyperlink{group__keyset_gae42530b04defb772059de0600159cf69}{ksPop}} (ks2); \textcolor{comment}{// ref counter 0, like after keyNew()}}
\DoxyCodeLine{}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_gaa5a1d467a4d71041edce68ea7748ce45}{ksAppendKey}}(ks1, k1); \textcolor{comment}{// ref counter 1}}
\DoxyCodeLine{}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (ks1); \textcolor{comment}{// key is deleted too}}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga27e5c16473b02a422238c8d970db7ac8}{ksDel}} (ks2);}

\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em ks} &amp; \mbox{\hyperlink{classkdb_1_1KeySet}{Key\+Set}} to pop a \mbox{\hyperlink{classkdb_1_1Key}{Key}} from\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the last \mbox{\hyperlink{classkdb_1_1Key}{Key}} of {\ttfamily ks} 
\end{DoxyReturn}

\begin{DoxyRetVals}{Return values}
{\em NULL} &amp; if {\ttfamily ks} is empty or a NULL pointer\\
\hline
\end{DoxyRetVals}
\begin{DoxySince}{Since}
1.\+0.\+0 
\end{DoxySince}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__keyset_ga60f1ddcf23272f2b29b90e92ebe9b56f}{ks\+Lookup()}} to \mbox{\hyperlink{classkdb_1_1KeySet_a7f207457a1c12633a1a5301a3a1bbaed}{pop}} Keys by name 

\mbox{\hyperlink{group__keyset_gaba1f1dbea191f4d7e7eb3e4296ae7d5e}{ks\+Copy()}} to \mbox{\hyperlink{classkdb_1_1KeySet_a7f207457a1c12633a1a5301a3a1bbaed}{pop}} all Keys 
\end{DoxySeeAlso}
\mbox{\Hypertarget{classkdb_1_1KeySet_a38abda394a4acf2267d5fe718e272759}\label{classkdb_1_1KeySet_a38abda394a4acf2267d5fe718e272759}} 
\index{kdb::KeySet@{kdb::KeySet}!search@{search}}
\index{search@{search}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{search()}{search()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily ssize\+\_\+t kdb\+::\+Key\+Set\+::search (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{classkdb_1_1Key}{Key}} \&amp;}]{to\+Search }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Search in a key set, either yielding the actual index of the key, if the ley has been found within the key set, or a negative value indicating the insertion index of the key, if the key would be inserted. 


\begin{DoxyCode}{0}
\DoxyCodeLine{ssize\_t result = \mbox{\hyperlink{group__keyset_gac59817ac58072708092fbeb87600beb1}{ksSearch}}(ks, key);}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordflow}{if} (result &gt;= 0)}
\DoxyCodeLine{\{}
\DoxyCodeLine{        ssize\_t position = result;}
\DoxyCodeLine{        \textcolor{comment}{// The key already exist in key set.}}
\DoxyCodeLine{\} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{        ssize\_t insertpos = -\/result-\/1;}
\DoxyCodeLine{        \textcolor{comment}{// The key was not found in key set.}}
\DoxyCodeLine{\}}

\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em ks} &amp; the keyset to work with \\
\hline
{\em key} &amp; the key to check \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
position where the key is ($&gt;$=0) if the key was found 

-\/insertpos -\/1 ($&lt;$ 0) if the key was not found so to get the insertpos simple do\+: -\/insertpos -\/1 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__keyset_ga60f1ddcf23272f2b29b90e92ebe9b56f}{ks\+Lookup()}} for retrieving the found \mbox{\hyperlink{group__key}{Key}} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{classkdb_1_1KeySet_af7478af835e648219b11a3e0268b8eaf}\label{classkdb_1_1KeySet_af7478af835e648219b11a3e0268b8eaf}} 
\index{kdb::KeySet@{kdb::KeySet}!search@{search}}
\index{search@{search}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{search()}{search()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily ssize\+\_\+t kdb\+::\+Key\+Set\+::search (\begin{DoxyParamCaption}\item[{std\+::string const \&amp;}]{name }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Search in a key set, either yielding the actual index of the key, if the ley has been found within the key set, or a negative value indicating the insertion index of the key, if the key would be inserted. 


\begin{DoxyCode}{0}
\DoxyCodeLine{ssize\_t result = \mbox{\hyperlink{group__keyset_gac59817ac58072708092fbeb87600beb1}{ksSearch}}(ks, key);}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordflow}{if} (result &gt;= 0)}
\DoxyCodeLine{\{}
\DoxyCodeLine{        ssize\_t position = result;}
\DoxyCodeLine{        \textcolor{comment}{// The key already exist in key set.}}
\DoxyCodeLine{\} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{        ssize\_t insertpos = -\/result-\/1;}
\DoxyCodeLine{        \textcolor{comment}{// The key was not found in key set.}}
\DoxyCodeLine{\}}

\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em ks} &amp; the keyset to work with \\
\hline
{\em key} &amp; the key to check \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
position where the key is ($&gt;$=0) if the key was found 

-\/insertpos -\/1 ($&lt;$ 0) if the key was not found so to get the insertpos simple do\+: -\/insertpos -\/1 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__keyset_ga60f1ddcf23272f2b29b90e92ebe9b56f}{ks\+Lookup()}} for retrieving the found \mbox{\hyperlink{group__key}{Key}}
\end{DoxySeeAlso}
\begin{DoxyNote}{Note}
Accepts a keyname as string instead of a \mbox{\hyperlink{classkdb_1_1Key}{Key}} object. 
\end{DoxyNote}
\mbox{\Hypertarget{classkdb_1_1KeySet_ab01c5c46e4c0802560b8f15886af89c4}\label{classkdb_1_1KeySet_ab01c5c46e4c0802560b8f15886af89c4}} 
\index{kdb::KeySet@{kdb::KeySet}!size@{size}}
\index{size@{size}!kdb::KeySet@{kdb::KeySet}}
\doxysubsubsection{\texorpdfstring{size()}{size()}}
{\footnotesize\ttfamily ssize\+\_\+t kdb\+::\+Key\+Set\+::size (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



The size of the keyset. 

\begin{DoxyReturn}{Returns}
the number of keys in the keyset 
\end{DoxyReturn}


The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{keyset_8hpp}{keyset.\+hpp}}\end{DoxyCompactItemize}
</pre></body></html>