#include <Environment.hpp>
|
| ~Environment () |
|
void | initialize (char **envp=NULL) |
|
std::string | getValue (const char *variableName, bool exceptionIfMissing=false) noexcept(false) |
|
std::string | getValue (const std::string &variableName, bool exceptionIfMissing=false) noexcept(false) |
|
void | setVariable (const std::string &name, const std::string &value, bool overwrite=true) noexcept(false) |
|
void | unsetVariable (const std::string &name) noexcept(false) |
|
Environment variables reader
◆ ~Environment()
anna::Environment::~Environment |
( |
| ) |
|
|
inline |
◆ getValue() [1/2]
std::string anna::Environment::getValue |
( |
const char * |
variableName, |
|
|
bool |
exceptionIfMissing = false |
|
) |
| |
|
noexcept |
Return associated value (could be empty). This value could be cached at initialization (envp array from main function), if not, would be cached here.
- Parameters
-
variableName | Environment variable name. |
exceptionIfMissing | When enabled, an exception is launched for missing variables. Empty string in other case (default behaviour). |
- Returns
- Environment value.
◆ getValue() [2/2]
std::string anna::Environment::getValue |
( |
const std::string & |
variableName, |
|
|
bool |
exceptionIfMissing = false |
|
) |
| |
|
noexcept |
◆ initialize()
void anna::Environment::initialize |
( |
char ** |
envp = NULL | ) |
|
Parses the environment data (all variables available) when process was started.
- Parameters
-
envp | Environment array passed on main function as third argument. Cache data is cleared if NULL passed, allowing to get current environment values for variables. |
◆ setVariable()
void anna::Environment::setVariable |
( |
const std::string & |
name, |
|
|
const std::string & |
value, |
|
|
bool |
overwrite = true |
|
) |
| |
|
noexcept |
Sets an environment variable. If an empty variable name is provided, or environment set operation fails, an exception will be launched.
- Parameters
-
name | Variable name. |
value | Variable value |
overwrite | Overwrite an existing variable name/value or keep old value if exists |
◆ unsetVariable()
void anna::Environment::unsetVariable |
( |
const std::string & |
name | ) |
|
|
noexcept |
Unsets an environment variable (different than set empty string). If an empty variable name is provided, or environment set operation fails, an exception will be launched.
- Parameters
-
name | Variable name. If empty, nothing is done. |
◆ Singleton< Environment >
The documentation for this class was generated from the following file: