$darkmode
Public Member Functions | |
| Environment (const Environment &)=default | |
| Environment (Environment &&)=default | |
| Environment & | operator= (const Environment &)=default |
| Environment & | operator= (Environment &&)=default |
| Environment (std::initializer_list< std::pair< std::string const, std::string >> init) | |
| Environment (const std::map< std::string, std::string > &defines) | |
| Environment (std::map< std::string, std::string > &&defines) | |
| bool | prefer_external () const |
| void | prefer_external (bool value) |
| bool | allow_undefined () const |
| void | allow_undefined (bool value) |
| void | insert (const std::string &key, const std::string &value) |
| void | set (const std::string &key, const std::string &value) |
| std::optional< std::string > | get (const std::string &key) const |
| std::optional< std::string > | get (const std::string &key, bool prefer_external) const |
| std::string | get_or (const std::string &key, const std::string &alternative) const |
| std::string | get_or (const std::string &key, const std::string &alternative, bool prefer_external) const |
| std::string | require (const std::string &key) const |
| std::string | require (const std::string &key, bool prefer_external) const |
| std::string | evaluate (const std::string &s) const |
| std::string | evaluate (const std::string &s, bool prefer_external, bool allow_undefined) const |
| std::string | interpolate (const std::string &s) const |
| std::string | interpolate (const std::string &s, bool prefer_external, bool allow_undefined) const |
|
inline |
Evaluate a single variable, such as "KEY" or "KEY-ALTERNATIVE".
Throws std::out_of_range if allow_undefined() is false and std::invalid_argument if a malformed string is supplied.
|
inline |
Return the value of a literal key, trying both environment and internal defines, depending on the value of perfer_external().
If neither are defined, "" is returned when allow_undefined() is true, and a std::out_of_range error is thrown.
This is roughly equivalent to ${KEY}.
|
inline |
Return the value of a literal key, trying both environment and internal defines, depending on the value of perfer_external().
If neither are defined, alternative is returned.
This is equivalent to ${KEY-ALTERNATIVE}, and cannot fail.
|
inline |
Interpolate a string will evaluate all variable instances in a string.
Throws std::out_of_range if allow_undefined() is false and std::invalid_argument if a malformed string is supplied.
|
inline |
Return the value of a literal key, trying both environment and internal defines, depending on the value of perfer_external().
If neither are defined, a std::out_of_range error is thrown.
This is roughly equivalent to ${KEY?out_of_range}.