RAII guard that saves, optionally modifies, and restores an environment variable. More...
#include <scoped_env_var.hpp>
Public Member Functions | |
| ScopedEnvVar (char const *name, char const *value) | |
| Construct the guard, saving and optionally replacing the variable. More... | |
| ScopedEnvVar (ScopedEnvVar const &)=delete | |
| ScopedEnvVar & | operator= (ScopedEnvVar const &)=delete |
RAII guard that saves, optionally modifies, and restores an environment variable.
On construction the current value of the named variable is captured. The caller may pass an initial value to set, or nullptr to unset the variable. On destruction the original state is restored unconditionally, making this class safe to use across code that may throw.
Definition at line 29 of file scoped_env_var.hpp.
|
inline |
Construct the guard, saving and optionally replacing the variable.
| name | Name of the environment variable. |
| value | Value to set, or nullptr to unset the variable. |
Definition at line 37 of file scoped_env_var.hpp.