Environment variable expansion utilities.
More...
#include <YamlEnv.hpp>
|
| static std::string | Expand (const std::string &value, bool strict=true) |
| | Expand environment variables in a string.
|
| static bool | ContainsEnvVars (const std::string &value) |
| | Check if string contains environment variable references.
|
| static YamlNode | ExpandAll (const YamlNode &node) |
| | Recursively expand all string values in a YAML tree.
|
| static YamlNode | LoadFileWithEnv (const std::string &path) |
| | Load YAML file with environment variable expansion.
|
| static YamlNode | LoadWithIncludesAndEnv (const std::string &path) |
| | Load with includes AND environment expansion.
|
| static YamlNode | LoadFromEnvPath (const std::string &path_with_vars) |
| | Expand envvars in path, then load the file.
|
| static std::optional< std::string > | GetEnv (const std::string &name) |
| | Get environment variable value.
|
| static std::string | GetEnv (const std::string &name, const std::string &default_value) |
| | Get environment variable with default.
|
Environment variable expansion utilities.
◆ ContainsEnvVars()
| bool vulcan::io::YamlEnv::ContainsEnvVars |
( |
const std::string & | value | ) |
|
|
inlinestatic |
Check if string contains environment variable references.
◆ Expand()
| std::string vulcan::io::YamlEnv::Expand |
( |
const std::string & | value, |
|
|
bool | strict = true ) |
|
inlinestatic |
Expand environment variables in a string.
- Parameters
-
| value | String potentially containing ${VAR} or ${VAR:default} |
| strict | If true, throws on undefined variables without defaults |
- Returns
- Expanded string
- Exceptions
-
| EnvVarError | if strict=true and required variable is undefined |
◆ ExpandAll()
Recursively expand all string values in a YAML tree.
- Parameters
-
- Returns
- New YamlNode with expanded values
◆ GetEnv() [1/2]
| std::optional< std::string > vulcan::io::YamlEnv::GetEnv |
( |
const std::string & | name | ) |
|
|
inlinestatic |
Get environment variable value.
- Parameters
-
| name | Variable name (without $) |
- Returns
- Value if defined, nullopt otherwise
◆ GetEnv() [2/2]
| std::string vulcan::io::YamlEnv::GetEnv |
( |
const std::string & | name, |
|
|
const std::string & | default_value ) |
|
inlinestatic |
Get environment variable with default.
◆ LoadFileWithEnv()
| YamlNode vulcan::io::YamlEnv::LoadFileWithEnv |
( |
const std::string & | path | ) |
|
|
inlinestatic |
Load YAML file with environment variable expansion.
Order of operations:
- Load file
- Expand envvars in all string values
◆ LoadFromEnvPath()
| YamlNode vulcan::io::YamlEnv::LoadFromEnvPath |
( |
const std::string & | path_with_vars | ) |
|
|
inlinestatic |
Expand envvars in path, then load the file.
◆ LoadWithIncludesAndEnv()
| YamlNode vulcan::io::YamlEnv::LoadWithIncludesAndEnv |
( |
const std::string & | path | ) |
|
|
inlinestatic |
Load with includes AND environment expansion.
Order of operations:
- Expand envvars in the path itself
- Resolve !include directives (with envvar expansion in paths)
- Expand envvars in all string values
The documentation for this class was generated from the following file: