LCOV - code coverage report
Current view: top level - src/libs/tools/include/helper - keyhelper.hpp (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 2 2 100.0 %
Date: 2019-09-12 12:28:41 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /**
       2             :  * @file
       3             :  *
       4             :  * @brief Key helper functions
       5             :  *
       6             :  * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
       7             :  *
       8             :  */
       9             : 
      10             : #ifndef KEYHELPER_HPP_
      11             : #define KEYHELPER_HPP_
      12             : 
      13             : #include <kdb.hpp>
      14             : #include <string>
      15             : #include <toolexcept.hpp>
      16             : 
      17             : namespace kdb
      18             : {
      19             : 
      20             : namespace tools
      21             : {
      22             : 
      23             : namespace helper
      24             : {
      25             : 
      26           8 : class InvalidRebaseException : public ToolException
      27             : {
      28             : public:
      29          16 :         explicit InvalidRebaseException (std::string message) : ToolException (message){};
      30             : };
      31             : 
      32             : /**
      33             :  * Rebases the supplied key from the old parent to the new parent.
      34             :  *
      35             :  * @see ThreeWayMerge::rebasePath
      36             :  * @param key the key to be rebased
      37             :  * @param oldParent the old parent of the key
      38             :  * @param newParent the new parent of the key
      39             :  * @return a rebased copy of the supplied key
      40             :  * @throws InvalidRebaseException if the key is not below the old parent
      41             :  */
      42             : Key rebaseKey (const Key & key, const Key & oldParent, const Key & newParent);
      43             : 
      44             : /**
      45             :  * Rebases the relative path of the passed key from the old parent
      46             :  * to the new parent and returns the new path.
      47             :  *
      48             :  * For example a key /user/example/config/key1 with the oldparent
      49             :  * /user/example and the new parent /user/newexample/newpath would
      50             :  * result in /user/newexample/newpath/config/key1
      51             :  *
      52             :  * If any of the parent keys is a cascading key the namespace of the
      53             :  * key to be rebased is assumed instead.
      54             :  *
      55             :  * @param key the key whose path should be rebased
      56             :  * @param oldParent the old parent of the key
      57             :  * @param newParent the new parent of the key
      58             :  * @return the rebased path
      59             :  * @throws InvalidRebaseException if the key is not below the old parent
      60             :  */
      61             : std::string rebasePath (const Key & key, const Key & oldParent, const Key & newParent);
      62             : 
      63             : /**
      64             :  * @brief Removes the namespace
      65             :  *
      66             :  * @param key will be made to a cascading key
      67             :  */
      68             : void removeNamespace (Key & key);
      69             : 
      70             : /**
      71             :  * @brief Find common name between two keys
      72             :  *
      73             :  * @return the longest common name found
      74             :  */
      75             : Key commonKeyName (Key key1, Key key2);
      76             : } // namespace helper
      77             : } // namespace tools
      78             : } // namespace kdb
      79             : 
      80             : #endif /* KEYHELPER_HPP_ */

Generated by: LCOV version 1.13