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

          Line data    Source code
       1             : /**
       2             :  * @file
       3             :  *
       4             :  * @brief Implements ways to parse backends
       5             :  *
       6             :  * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
       7             :  *
       8             :  */
       9             : 
      10             : 
      11             : #ifndef TOOLS_BACKEND_PARSER_HPP
      12             : #define TOOLS_BACKEND_PARSER_HPP
      13             : 
      14             : 
      15             : #include <algorithm>
      16             : #include <initializer_list>
      17             : #include <memory>
      18             : #include <sstream>
      19             : #include <vector>
      20             : 
      21             : #include <pluginspec.hpp>
      22             : 
      23             : #include <kdb.hpp>
      24             : 
      25             : namespace kdb
      26             : {
      27             : 
      28             : namespace tools
      29             : {
      30             : 
      31             : kdb::KeySet parsePluginArguments (std::string const & pluginArguments, std::string const & basename = "user");
      32             : PluginSpecVector parseArguments (std::string const & cmdline);
      33             : PluginSpecVector parseArguments (std::initializer_list<std::string> cmdline);
      34             : 
      35             : namespace detail
      36             : {
      37             : void processArgument (PluginSpecVector & arguments, size_t & counter, std::string argument);
      38             : void fixArguments (PluginSpecVector & arguments);
      39             : } // namespace detail
      40             : 
      41             : /**
      42             :  * @brief Parse a complete commandline that is already tokenized in pluginname pluginconfig
      43             :  *
      44             :  * @tparam Iterator forward iterator type
      45             :  *
      46             :  * @param cmdline contains space separated plugins with optional plugin configurations
      47             :  *
      48             :  * @return a parsed PluginSpecVector
      49             :  */
      50             : template <typename Iterator>
      51        1124 : PluginSpecVector parseArguments (Iterator first, Iterator last)
      52             : {
      53        1124 :         PluginSpecVector arguments;
      54        1124 :         size_t counter = 0;
      55        1936 :         while (first != last)
      56             :         {
      57        2401 :                 detail::processArgument (arguments, counter, *first);
      58          20 :                 ++first;
      59             :         }
      60        1109 :         detail::fixArguments (arguments);
      61        1077 :         return arguments;
      62             : }
      63             : } // namespace tools
      64             : } // namespace kdb
      65             : 
      66             : #endif

Generated by: LCOV version 1.13