BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SysUtils Namespace Reference

Functions

std::string getCurrentDateAndTime ()
 
void enableFloatingPointExceptions ()
 
std::string getenv (const std::string &name)
 
bool isWindowsHost ()
 

Detailed Description

Utility functions getCurrentDateAndTime, enableFloatingPointExceptions.

Function Documentation

◆ getCurrentDateAndTime()

std::string SysUtils::getCurrentDateAndTime ( )

Definition at line 22 of file SysUtils.cpp.

23 {
24  using clock = std::chrono::system_clock;
25 
26  std::stringstream output;
27  std::time_t current_time = clock::to_time_t(clock::now());
28  output << std::put_time(std::gmtime(&current_time), "%Y-%b-%d %T");
29  return output.str();
30 }

◆ enableFloatingPointExceptions()

void SysUtils::enableFloatingPointExceptions ( )

Enables exception throw in the case of NaN, Inf.

enables exception throw in the case of NaN, Inf

Definition at line 33 of file SysUtils.cpp.

34 {
35 #ifdef DEBUG_FPE
36 #ifndef _WIN32
37  std::cout << "SysUtils::EnableFloatingPointExceptions() -> "
38  "Enabling floating point exception debugging\n";
39  feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
40 // feenableexcept(-1);
41 #endif // _WIN32
42 #else
43  std::cout << "SysUtils::EnableFloatingPointExceptions() -> "
44  "Can't enable floating point exceptions. Available in debug mode only.\n";
45 #endif
46 }

◆ getenv()

std::string SysUtils::getenv ( const std::string &  name)

Returns environment variable.

Definition at line 48 of file SysUtils.cpp.

49 {
50  if (char* c = std::getenv(name.c_str()))
51  return c;
52  else
53  return "";
54 }
std::string getenv(const std::string &name)
Returns environment variable.
Definition: SysUtils.cpp:48

Referenced by PyEmbeddedUtils::pythonRuntimeInfo().

◆ isWindowsHost()

bool SysUtils::isWindowsHost ( )

Returns true if operation system is Windows.

Definition at line 56 of file SysUtils.cpp.

57 {
58 #ifdef _WIN32
59  return true;
60 #else
61  return false;
62 #endif
63 }