LCOV - code coverage report
Current view: top level - src/tools/kdb - rename.hpp (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 7 7 100.0 %
Date: 2019-09-12 12:28:41 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /**
       2             :  * @file
       3             :  *
       4             :  * @brief
       5             :  *
       6             :  * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
       7             :  */
       8             : 
       9             : #ifndef ELEKTRA_KDBRENAME_HPP
      10             : #define ELEKTRA_KDBRENAME_HPP
      11             : 
      12             : #include <key.hpp>
      13             : 
      14             : #include <iostream>
      15             : #include <string>
      16             : 
      17             : /** @return a renamed key
      18             :  */
      19          22 : inline kdb::Key rename_key (kdb::Key & k, std::string const & sourceName, std::string const & newDirName, bool verbose)
      20             : {
      21          44 :         std::string otherName = k.getName ();
      22          44 :         std::string baseName = otherName.substr (sourceName.length ());
      23          22 :         if (verbose) std::cout << "key: " << otherName << " will be renamed to: " << newDirName + baseName << std::endl;
      24             : 
      25          44 :         kdb::Key newKey = k.dup ();
      26          44 :         newKey.setName (newDirName + baseName);
      27          22 :         return newKey;
      28             : }
      29             : 
      30             : #endif

Generated by: LCOV version 1.13