advgetopt 2.0.47
Parse complex command line arguments and configuration files in C++.
variables.h
Go to the documentation of this file.
1// Copyright (c) 2006-2024 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
29// self
30//
31#include <advgetopt/utils.h>
32
33
34// C++
35//
36#include <map>
37#include <memory>
38#include <string>
39
40
41
42namespace advgetopt
43{
44
45
46
56
57
59{
60public:
61 typedef std::shared_ptr<variables> pointer_t;
62 typedef std::map<std::string, std::string> variable_t;
63
64 bool has_variable(std::string const & name) const;
65 std::string get_variable(std::string const & name) const;
66 variable_t const & get_variables() const;
67 void set_variable(
68 std::string const & name
69 , std::string const & value
71
72 std::string process_value(std::string const & value) const;
73
74 static std::string canonicalize_variable_name(std::string const & name);
75
76private:
78
79 std::string recursive_process_value(
80 std::string const & value
81 , variable_names_t & names) const;
82
84};
85
86
87
88} // namespace advgetopt
89// vim: ts=4 sw=4 et
std::string process_value(std::string const &value) const
Process variables against a parameter.
void set_variable(std::string const &name, std::string const &value, assignment_t assignment=assignment_t::ASSIGNMENT_SET)
Set a variable.
variable_t const & get_variables() const
Return a reference to the map of variables.
variable_t f_variables
Definition variables.h:83
std::string recursive_process_value(std::string const &value, variable_names_t &names) const
Internal function processing variables recursively.
string_set_t variable_names_t
Definition variables.h:77
std::shared_ptr< variables > pointer_t
Definition variables.h:61
std::map< std::string, std::string > variable_t
Definition variables.h:62
std::string get_variable(std::string const &name) const
Return the value of the named variable.
static std::string canonicalize_variable_name(std::string const &name)
Canonicalize the variable name.
Definition variables.cpp:79
bool has_variable(std::string const &name) const
Check whether a variable is defined.
The advgetopt environment to parse command line options.
constexpr flag_t option_flags_merge()
Definition flags.h:87
std::set< std::string > string_set_t
Definition utils.h:42
A few utility functions that are not specific to an object.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.