$darkmode
Elektra 0.11.0
Namespaces | Functions
keyhelper.hpp File Reference

Key helper functions. More...

#include <kdb.hpp>
#include <string>
#include <toolexcept.hpp>
Include dependency graph for keyhelper.hpp:
This graph shows which files directly or indirectly include this file:

Namespaces

 kdb
 This is the main namespace for the C++ binding and libraries.
 
 kdb::tools
 This namespace is for the libtool library.
 

Functions

Key kdb::tools::helper::rebaseKey (const Key &key, const Key &oldParent, const Key &newParent)
 Rebases the supplied key from the old parent to the new parent. More...
 
std::string kdb::tools::helper::rebasePath (const Key &key, const Key &oldParent, const Key &newParent)
 Rebases the relative path of the passed key from the old parent to the new parent and returns the new path. More...
 
void kdb::tools::helper::removeNamespace (Key &key)
 Removes the namespace. More...
 
Key kdb::tools::helper::prependNamespace (Key const &root, std::string const &ns)
 Prepends the namespace to the key. More...
 
KeySet kdb::tools::helper::prependNamespace (KeySet const &resultKeys, std::string const &ns)
 Prepends the namespace to each key of the key set. More...
 
void kdb::tools::helper::copyAllMeta (KeySet &to, KeySet const &from)
 Copies all metadata of each key in from to their pendant in to. More...
 
Key kdb::tools::helper::commonKeyName (Key key1, Key key2)
 Find common name between two keys. More...
 

Detailed Description

Key helper functions.

Function Documentation

◆ commonKeyName()

Key kdb::tools::helper::commonKeyName ( Key  key1,
Key  key2 
)

Find common name between two keys.

Returns
the longest common name found

◆ copyAllMeta()

void kdb::tools::helper::copyAllMeta ( KeySet to,
KeySet const &  from 
)

Copies all metadata of each key in from to their pendant in to.

The pendant is determined by ksLookup.

Parameters
tometadata is copied to keys in this key set
frommetadata is copied from keys in this key set

◆ prependNamespace() [1/2]

Key kdb::tools::helper::prependNamespace ( Key const &  root,
std::string const &  ns 
)

Prepends the namespace to the key.

Parameters
rootis the key where the namespace will be prepended
nsis the namespace to be prepended
Returns
a duplicate of root with the new namespace

◆ prependNamespace() [2/2]

KeySet kdb::tools::helper::prependNamespace ( KeySet const &  resultKeys,
std::string const &  ns 
)

Prepends the namespace to each key of the key set.

Parameters
resultKeyswhich keys to prepend the namepsace to
nsis the namespace to be prepended to each key
Returns
a keyset where each key has the new namespace

◆ rebaseKey()

Key kdb::tools::helper::rebaseKey ( const Key key,
const Key oldParent,
const Key newParent 
)

Rebases the supplied key from the old parent to the new parent.

See also
ThreeWayMerge::rebasePath
Parameters
keythe key to be rebased
oldParentthe old parent of the key
newParentthe new parent of the key
Returns
a rebased copy of the supplied key
Exceptions
InvalidRebaseExceptionif the key is not below the old parent

◆ rebasePath()

string kdb::tools::helper::rebasePath ( const Key key,
const Key oldParent,
const Key newParent 
)

Rebases the relative path of the passed key from the old parent to the new parent and returns the new path.

For example a key /user/example/config/key1 with the oldparent /user/example and the new parent /user/newexample/newpath would result in /user/newexample/newpath/config/key1

If any of the parent keys is a cascading key the namespace of the key to be rebased is assumed instead.

Parameters
keythe key whose path should be rebased
oldParentthe old parent of the key
newParentthe new parent of the key
Returns
the rebased path
Exceptions
InvalidRebaseExceptionif the key is not below the old parent

◆ removeNamespace()

void kdb::tools::helper::removeNamespace ( Key key)

Removes the namespace.

Parameters
keywill be made to a cascading key