LCOV - code coverage report
Current view: top level - advgetopt - variables.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2022-05-26 21:41:34 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2006-2022  Made to Order Software Corp.  All Rights Reserved
       2             : //
       3             : // https://snapwebsites.org/project/advgetopt
       4             : // contact@m2osw.com
       5             : //
       6             : // This program is free software; you can redistribute it and/or modify
       7             : // it under the terms of the GNU General Public License as published by
       8             : // the Free Software Foundation; either version 2 of the License, or
       9             : // (at your option) any later version.
      10             : //
      11             : // This program is distributed in the hope that it will be useful,
      12             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             : // GNU General Public License for more details.
      15             : //
      16             : // You should have received a copy of the GNU General Public License along
      17             : // with this program; if not, write to the Free Software Foundation, Inc.,
      18             : // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      19             : #pragma once
      20             : 
      21             : /** \file
      22             :  * \brief Declaration of the variable class.
      23             :  *
      24             :  * The advgetopt library supports variables in its configuration files.
      25             :  *
      26             :  * This class handles the variable data store and replacement in strings.
      27             :  */
      28             : 
      29             : // C++ lib
      30             : //
      31             : #include    <map>
      32             : #include    <memory>
      33             : #include    <set>
      34             : #include    <string>
      35             : 
      36             : 
      37             : 
      38             : namespace advgetopt
      39             : {
      40             : 
      41             : 
      42             : 
      43         703 : class variables
      44             : {
      45             : public:
      46             :     typedef std::shared_ptr<variables>          pointer_t;
      47             :     typedef std::map<std::string, std::string>  variable_t;
      48             : 
      49             :     bool                    has_variable(std::string const & name) const;
      50             :     std::string             get_variable(std::string const & name) const;
      51             :     variable_t const &      get_variables() const;
      52             :     void                    set_variable(
      53             :                                   std::string const & name
      54             :                                 , std::string const & value
      55             :                                 , bool overwrite = true);
      56             : 
      57             :     std::string             process_value(std::string const & value) const;
      58             : 
      59             :     static std::string      canonicalize_variable_name(std::string const & name);
      60             : 
      61             : private:
      62             :     typedef std::set<std::string>               variable_names_t;
      63             : 
      64             :     std::string             recursive_process_value(
      65             :                                   std::string const & value
      66             :                                 , variable_names_t & names) const;
      67             : 
      68             :     variable_t              f_variables = variable_t();
      69             : };
      70             : 
      71             : 
      72             : 
      73             : }   // namespace advgetopt
      74             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.13