sbuild
1.6.10
|
Container of environment variables. More...
#include <sbuild-environment.h>
Public Member Functions | |
environment () | |
The constructor. | |
environment (char **environment) | |
The constructor. More... | |
~environment () | |
The destructor. | |
void | set_filter (regex const &filter) |
Set environment filter. More... | |
regex const & | get_filter () const |
Get environment filter. More... | |
void | add (char **environment) |
Add environment variables. More... | |
void | add (environment const &environment) |
Add environment variables. More... | |
void | add (value_type const &value) |
Add environment variable. More... | |
void | add (std::string const &name, std::string const &value) |
Add environment variable. More... | |
template<typename T > | |
void | add (std::string const &name, T const &value) |
Add environment variable. More... | |
void | add (std::string const &value) |
Add environment variable. More... | |
void | remove (char **environment) |
Remove environment variables. More... | |
void | remove (environment const &environment) |
Remove environment variables. More... | |
void | remove (std::string const &value) |
Remove environment variable. More... | |
void | remove (value_type const &value) |
Remove environment variable. More... | |
template<typename T > | |
bool | get (std::string const &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+ (environment const &lhs, T const &rhs) |
Add variables to the environment. More... | |
template<typename T > | |
environment | operator- (environment const &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, environment const &rhs) |
Output the environment to an ostream. More... | |
Container of environment variables.
environment::environment | ( | char ** | environment | ) |
void 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::get_minimal_environment(), operator+=(), sbuild::session::setup_chroot(), sbuild::chroot_directory_base::setup_env(), sbuild::chroot_block_device_base::setup_env(), sbuild::chroot_facet_userdata::setup_env(), sbuild::chroot_loopback::setup_env(), sbuild::chroot_lvm_snapshot::setup_env(), sbuild::chroot_file::setup_env(), sbuild::chroot_btrfs_snapshot::setup_env(), sbuild::chroot_facet_mountable::setup_env(), sbuild::chroot_facet_session::setup_env(), sbuild::chroot_facet_union::setup_env(), and sbuild::chroot::setup_env().
void environment::add | ( | environment const & | 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 environment::add | ( | value_type const & | 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(), and environment().
void environment::add | ( | std::string const & | 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, get_strv(), 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 & environment::get_filter | ( | ) | const |
char ** 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(), and get().
|
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 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::get_complete_environment().
void environment::remove | ( | environment const & | environment | ) |
Remove environment variables.
Any variables sharing the names of a specified value will be removed.
environment | the environment variables to remove. |
void environment::remove | ( | std::string const & | value | ) |
Remove environment variable.
Any variable sharing the name of the specified value will be removed.
value | the environment variable to remove. |
void environment::remove | ( | value_type const & | value | ) |
Remove environment variable.
Any variable sharing the name of the specified value will be removed.
value | the environment variable to remove. |
void environment::set_filter | ( | regex const & | 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. |