Celeritas
0.5.0-56+6b053cd
|
#include "Environment.hh"
#include <algorithm>
#include <cstdlib>
#include <mutex>
#include "corecel/Assert.hh"
#include "corecel/io/Logger.hh"
Functions | |
Environment & | celeritas::environment () |
Access a static global environment variable. More... | |
std::string const & | celeritas::getenv (std::string const &key) |
Thread-safe access to global modified environment variables. More... | |
GetenvFlagResult | celeritas::getenv_flag (std::string const &key, bool default_val) |
Get a true/false flag with a default value. More... | |
std::ostream & | celeritas::operator<< (std::ostream &os, Environment const &env) |
Write the accessed environment variables to a stream. | |
Environment & celeritas::environment | ( | ) |
Access a static global environment variable.
This static variable should be shared among Celeritas objects.
std::string const & celeritas::getenv | ( | std::string const & | key | ) |
Thread-safe access to global modified environment variables.
This function will insert the current value of the key into the environment, which remains immutable over the lifetime of the program (allowing the use of static const
data to be set from the environment).
GetenvFlagResult celeritas::getenv_flag | ( | std::string const & | key, |
bool | default_val | ||
) |
Get a true/false flag with a default value.
The return value is a pair that has (1) the flag as determined by the environment variable or default value, and (2) an "insertion" flag specifying whether the default was used. The insertion result can be useful for providing a diagnostic message to the user.
"1", "t", "yes", "true", "True"
"0", "f", "no", "false", "False"