A convenience class for manipulating a copy of the environment variables.
More...
#include <glibmm/environ.h>
A convenience class for manipulating a copy of the environment variables.
Useful for generating the envp parameter in calls to Glib::spawn_async_with_pipes(), Glib::spawn_async() and Glib::spawn_sync().
If you want to change the environment itself (i.e. not a copy of it), see Glib::getenv(), Glib::setenv() and Glib::unsetenv().
- Since glibmm 2.70:
◆ Environ() [1/2]
Glib::Environ::Environ |
( |
| ) |
|
Constructs a list of environment variables for the current process.
Each item in the list is of the form 'NAME=VALUE'.
◆ Environ() [2/2]
Constructs a Glib::Environ instance from a vector.
- Parameters
-
env_vec | A vector with the environment variables. Each element in the vector must be of the form 'NAME=VALUE'. |
◆ get()
Gets the value of the environment variable variable.
- Parameters
-
variable | The environment variable to get, must not contain '='. |
- Returns
- The value of the environment variable, or an empty std::optional if the environment variable is not set in this Environ.
◆ operator[]()
◆ set()
Sets the environment variable variable in the provided list to value.
- Parameters
-
variable | The environment variable to set, must not contain '='. |
value | The value to set the variable to. |
overwrite | Whether to change the variable if it already exists. |
◆ to_vector()
Get a vector with the environment variables.
- Returns
- A vector with the environment variables. Each element in the vector is of the form 'NAME=VALUE'.
◆ unset()
Removes the environment variable variable from the provided list.
- Parameters
-
variable | The environment variable to remove, must not contain '='. |