Webdar 1.0.0
Web user interface to libdar
environment.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef ENVIRONMENT_HPP
25#define ENVIRONMENT_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31
32}
33
34 // C++ system header files
35#include <string>
36#include <map>
37
38 // webdar headers
39
41
43{
44public:
45 environment() = default;
46 environment(const environment & ref) = default;
47 environment(environment && ref) noexcept = default;
48 environment & operator = (const environment & ref) = default;
49 environment & operator = (environment && ref) noexcept = default;
50 ~environment() = default;
51
53 void feed(char** env);
54
56
61 bool get_value_of(const std::string & var, std::string & value) const;
62
64
68 std::string get_value_with_default(const std::string & var, const std::string & defaulted) const;
69
70private:
71 std::map<std::string, std::string> envir;
72};
73
74extern environment global_envir;
75
76#endif
class environment holds environment variables passed to webdar from its parent process (a shell for e...
Definition: environment.hpp:43
std::string get_value_with_default(const std::string &var, const std::string &defaulted) const
provide the value associated to a given environment variable or the provided defaulted value
Definition: environment.cpp:78
bool get_value_of(const std::string &var, std::string &value) const
provide the value associated to a given environment variable
Definition: environment.cpp:65
void feed(char **env)
feed the object with the system provided environment
Definition: environment.cpp:45