sbuild
1.7.1
|
Container of environment variables. More...
#include <environment.h>
Public Member Functions | |
environment () | |
The constructor. | |
environment (char **environment) | |
The constructor. More... | |
~environment () | |
The destructor. | |
void | set_filter (const regex &filter) |
Set environment filter. More... | |
regex const & | get_filter () const |
Get environment filter. More... | |
void | add (char **environment) |
Add environment variables. More... | |
void | add (const environment &environment) |
Add environment variables. More... | |
void | add (const value_type &value) |
Add environment variable. More... | |
void | add (const std::string &name, const std::string &value) |
Add environment variable. More... | |
template<typename T > | |
void | add (const std::string &name, T const &value) |
Add environment variable. More... | |
void | add (const std::string &value) |
Add environment variable. More... | |
void | remove (char **environment) |
Remove environment variables. More... | |
void | remove (const environment &environment) |
Remove environment variables. More... | |
void | remove (const std::string &value) |
Remove environment variable. More... | |
void | remove (const value_type &value) |
Remove environment variable. More... | |
template<typename T > | |
bool | get (const std::string &name, T &value) const |
Get the value of an environment variable. More... | |
char ** | get_strv () const |
Get the evironment variables as a string vector. More... | |
template<typename T > | |
environment & | operator+= (T const &rhs) |
Add variables to the environment. More... | |
template<typename T > | |
environment & | operator-= (T const &rhs) |
Remove variables from the environment. More... | |
Private Attributes | |
regex | filter |
Filter regex. | |
Friends | |
template<typename T > | |
environment | operator+ (const environment &lhs, T const &rhs) |
Add variables to the environment. More... | |
template<typename T > | |
environment | operator- (const environment &lhs, T const &rhs) |
Remove variables from the environment. More... | |
template<class charT , class traits > | |
std::basic_ostream< charT, traits > & | operator<< (std::basic_ostream< charT, traits > &stream, const environment &rhs) |
Output the environment to an ostream. More... | |
Additional Inherited Members | |
![]() | |
K | keys |
STL member. | |
T | elements |
STL member. | |
Container of environment variables.
sbuild::environment::environment | ( | char ** | environment) |
void sbuild::environment::add | ( | char ** | environment) |
Add environment variables.
Any existing variables sharing the name of a new value will be replaced.
environment | the environment variables to add. This is a null-terminated array of pointers to char. |
Referenced by add(), environment(), sbuild::session::get_login_command(), sbuild::auth::auth::get_minimal_environment(), operator+=(), sbuild::session::setup_chroot(), sbuild::chroot::facet::directory_base::setup_env(), sbuild::chroot::facet::userdata::setup_env(), sbuild::chroot::facet::block_device_base::setup_env(), sbuild::chroot::facet::loopback::setup_env(), sbuild::chroot::facet::session::setup_env(), sbuild::chroot::facet::lvm_snapshot::setup_env(), sbuild::chroot::facet::mountable::setup_env(), sbuild::chroot::facet::file::setup_env(), sbuild::chroot::facet::btrfs_snapshot::setup_env(), sbuild::chroot::facet::unshare::setup_env(), sbuild::chroot::facet::fsunion::setup_env(), and sbuild::chroot::chroot::setup_env().
void sbuild::environment::add | ( | const environment & | environment) |
Add environment variables.
Any existing variables sharing the name of a new value will be replaced.
environment | the environment variables to add. |
References add().
void sbuild::environment::add | ( | const value_type & | value) |
Add environment variable.
Any existing variable sharing the name will be replaced.
value | the environment variable to add. |
References sbuild::DEBUG_INFO, sbuild::DEBUG_NOTICE, filter, sbuild::log_debug(), and sbuild::regex_search().
|
inline |
Add environment variable.
Any existing variable sharing the name will be replaced.
name | the environment variable name |
value | the environment variable value to add. |
References add().
|
inline |
Add environment variable.
Any existing variable sharing the name will be replaced.
name | the environment variable name |
value | the environment variable value to add. |
References add().
void sbuild::environment::add | ( | const std::string & | value) |
Add environment variable.
Any existing variable sharing the name will be replaced.
value | the environment variable to add. This is a string in the form key=value. |
References add().
|
inline |
Get the value of an environment variable.
name | the name of the environment variable. |
value | the variable to store the value in on success. |
References sbuild::DEBUG_INFO, sbuild::DEBUG_NOTICE, sbuild::log_debug(), sbuild::log_warning(), and sbuild::parse_value().
Referenced by sbuild::session::get_login_directories(), sbuild::session::get_user_command(), and sbuild::chroot::facet::userdata::setup_env().
regex const & sbuild::environment::get_filter | ( | ) | const |
char ** sbuild::environment::get_strv | ( | ) | const |
Get the evironment variables as a string vector.
This form is suitable for use as an envp argument with execve, for example.
Referenced by sbuild::exec().
|
inline |
Add variables to the environment.
rhs | the values to add. |
References add().
|
inline |
Remove variables from the environment.
rhs | the values to remove. |
void sbuild::environment::remove | ( | char ** | environment) |
Remove environment variables.
Any variables sharing the names of a specified value will be removed.
environment | the environment variables to remove. This is a null-terminated array of pointers to char. |
Referenced by sbuild::auth::auth::get_complete_environment().
void sbuild::environment::remove | ( | const environment & | environment) |
Remove environment variables.
Any variables sharing the names of a specified value will be removed.
environment | the environment variables to remove. |
void sbuild::environment::remove | ( | const std::string & | value) |
Remove environment variable.
Any variable sharing the name of the specified value will be removed.
value | the environment variable to remove. |
void sbuild::environment::remove | ( | const value_type & | value) |
Remove environment variable.
Any variable sharing the name of the specified value will be removed.
value | the environment variable to remove. |
void sbuild::environment::set_filter | ( | const regex & | filter) |
Set environment filter.
If the environment variable name matches the regex when add() is called, addition will be .
The default filter is to allow all strings.
If the regex contains errors, an exception will be thrown.
filter | the filter regex. |
References filter.
Referenced by sbuild::session::run_child().
|
friend |
Add variables to the environment.
lhs | the environment to add to. |
rhs | the values to add. |
|
friend |
Remove variables from the environment.
lhs | the environment to remove from. |
rhs | the values to remove. |
|
friend |
Output the environment to an ostream.
stream | the stream to output to. |
rhs | the environment to output. |