41 #ifndef G4ENVIRONMENTUTILS_HH_
42 #define G4ENVIRONMENTUTILS_HH_
77 template <
typename _Tp>
78 void insert(
const std::string& env_id, _Tp val)
94 std::stringstream filler;
96 filler << std::setw(90) <<
"";
98 ss << filler.str() <<
"\n# Environment settings:\n";
99 for(
const auto& itr : env.
get())
101 ss <<
"# " << std::setw(35) <<
std::right << itr.first
102 <<
"\t = \t" <<
std::left << itr.second <<
"\n";
105 os << ss.str() << std::endl;
119 template <
typename _Tp>
120 _Tp
G4GetEnv(
const std::string& env_id, _Tp _default = _Tp())
122 char* env_var = std::getenv(env_id.c_str());
125 std::string str_var = std::string(env_var);
126 std::istringstream iss(str_var);
149 char* env_var = std::getenv(env_id.c_str());
170 template <
typename _Tp>
171 _Tp
G4GetEnv(
const std::string& env_id, _Tp _default,
const std::string& msg)
173 char* env_var = std::getenv(env_id.c_str());
176 std::string str_var = std::string(env_var);
177 std::istringstream iss(str_var);
180 G4cout <<
"Environment variable \"" << env_id <<
"\" enabled with "
181 <<
"value == " << var <<
". " << msg <<
G4endl;
204 const char* originOfException,
205 const char* exceptionCode,
207 const char* description)
209 char* env_var = std::getenv(env_id.c_str());
212 std::string str_var = std::string(env_var);
213 std::istringstream iss(str_var);
222 G4Exception(originOfException, exceptionCode, severity, description);