#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <mutex>
#include <sstream>
#include <string>
#include "G4Exception.hh"
#include "G4ExceptionSeverity.hh"
#include "G4String.hh"
#include "G4ios.hh"
Go to the source code of this file.
|
template<typename _Tp > |
_Tp | G4GetEnv (const std::string &env_id, _Tp _default=_Tp()) |
|
template<> |
G4bool | G4GetEnv (const std::string &env_id, bool _default) |
|
template<typename _Tp > |
_Tp | G4GetEnv (const std::string &env_id, _Tp _default, const std::string &msg) |
|
G4String | G4GetDataEnv (const std::string &env_id, const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description) |
|
void | G4PrintEnv (std::ostream &os=G4cout) |
|
◆ G4GetDataEnv()
G4String G4GetDataEnv |
( |
const std::string & |
env_id, |
|
|
const char * |
originOfException, |
|
|
const char * |
exceptionCode, |
|
|
G4ExceptionSeverity |
severity, |
|
|
const char * |
description |
|
) |
| |
|
inline |
Definition at line 198 of file G4EnvironmentUtils.hh.
203{
204 char* env_var = std::getenv(env_id.c_str());
205 if(env_var)
206 {
207 std::string str_var = std::string(env_var);
208 std::istringstream iss(str_var);
210 iss >> var;
211
213 return var;
214 }
215
216
217 G4Exception(originOfException, exceptionCode, severity, description);
218
219
220 return "";
221}
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
void insert(const std::string &env_id, _Tp val)
static G4EnvSettings * GetInstance()
◆ G4GetEnv() [1/3]
template<typename _Tp >
_Tp G4GetEnv |
( |
const std::string & |
env_id, |
|
|
_Tp |
_default, |
|
|
const std::string & |
msg |
|
) |
| |
Definition at line 167 of file G4EnvironmentUtils.hh.
168{
169 char* env_var = std::getenv(env_id.c_str());
170 if(env_var)
171 {
172 std::string str_var = std::string(env_var);
173 std::istringstream iss(str_var);
174 _Tp var = _Tp();
175 iss >> var;
176 G4cout <<
"Environment variable \"" << env_id <<
"\" enabled with "
177 <<
"value == " << var <<
". " << msg <<
G4endl;
178
180 return var;
181 }
182
184
185
186 return _default;
187}
G4GLOB_DLL std::ostream G4cout
◆ G4GetEnv() [2/3]
template<typename _Tp >
_Tp G4GetEnv |
( |
const std::string & |
env_id, |
|
|
_Tp |
_default = _Tp() |
|
) |
| |
Definition at line 116 of file G4EnvironmentUtils.hh.
117{
118 char* env_var = std::getenv(env_id.c_str());
119 if(env_var)
120 {
121 std::string str_var = std::string(env_var);
122 std::istringstream iss(str_var);
123 _Tp var = _Tp();
124 iss >> var;
125
127 return var;
128 }
129
131
132
133 return _default;
134}
◆ G4GetEnv() [3/3]
template<>
G4bool G4GetEnv |
( |
const std::string & |
env_id, |
|
|
bool |
_default |
|
) |
| |
|
inline |
Definition at line 143 of file G4EnvironmentUtils.hh.
144{
145 char* env_var = std::getenv(env_id.c_str());
146 if(env_var)
147 {
148
150 return true;
151 }
152
154
155
156 return _default;
157}
◆ G4PrintEnv()
void G4PrintEnv |
( |
std::ostream & |
os = G4cout | ) |
|
|
inline |