Utilities for reading environment variables.
More...
#include <environment.hpp>
|
| static std::optional< std::string > | get_value (const std::string &name) |
| | Gets an environment variable value.
|
| |
| static std::string | get_value_or_default (const std::string &name, const std::string &default_value) |
| | Gets an environment variable value with a default.
|
| |
| static int | get_int_value_or_default (const std::string &name, int default_value) |
| | Gets an environment variable value as an integer.
|
| |
| static void | set_value (const std::string &name, const std::string &value) |
| | Sets an environment variable value.
|
| |
Utilities for reading environment variables.
◆ get_value()
| std::optional< std::string > get_value |
( |
const std::string & |
name | ) |
|
|
static |
Gets an environment variable value.
- Parameters
-
| name | Name of the environment variable. |
- Returns
- The value if found, empty optional otherwise.
◆ get_value_or_default()
| std::string get_value_or_default |
( |
const std::string & |
name, |
|
|
const std::string & |
default_value |
|
) |
| |
|
static |
Gets an environment variable value with a default.
- Parameters
-
| name | Name of the environment variable. |
| default_value | Default value if not found. |
- Returns
- The value if found, default_value otherwise.
◆ get_int_value_or_default()
| int get_int_value_or_default |
( |
const std::string & |
name, |
|
|
int |
default_value |
|
) |
| |
|
static |
Gets an environment variable value as an integer.
- Parameters
-
| name | Name of the environment variable. |
| default_value | Default value if not found or not parseable. |
- Returns
- The value if found and parseable, default_value otherwise.
◆ set_value()
| void set_value |
( |
const std::string & |
name, |
|
|
const std::string & |
value |
|
) |
| |
|
static |
Sets an environment variable value.
- Parameters
-
| name | Name of the environment variable. |
| value | Value to set. |