eOn client
Long-timescale dynamics: aKMC, NEB, parallel replica
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
EnvHelpers.cc
Go to the documentation of this file.
1
#include "
eon/EnvHelpers.hpp
"
2
#include "
eon/BaseStructures.h
"
3
#include "
eon/EonLogger.h
"
4
5
namespace
eonc::helpers
{
6
7
std::string
get_value_from_env_or_param
(
const
char
*env_variable,
8
const
std::string ¶m_value,
9
const
std::string &default_value,
10
const
std::string &warning_message,
11
const
bool
is_mandatory) {
12
const
char
*env_value = std::getenv(env_variable);
13
if
(env_value !=
nullptr
) {
14
return
std::string(env_value);
15
}
16
17
if
(!param_value.empty()) {
18
return
param_value;
19
}
20
21
if
(is_mandatory) {
22
throw
std::runtime_error(
23
"Environment variable "
+ std::string(env_variable) +
24
" is not set and no parameter value provided. Please set it in the "
25
"configuration or as an environment variable.\n"
);
26
}
27
28
if
(!default_value.empty() && !warning_message.empty()) {
29
EONC_LOG_WARNING
(
"{}"
, warning_message);
30
}
31
32
return
default_value;
33
}
34
35
}
// namespace eonc::helpers
BaseStructures.h
EnvHelpers.hpp
EonLogger.h
EONC_LOG_WARNING
#define EONC_LOG_WARNING(...)
Definition
EonLogger.h:256
eonc::helpers
Definition
EnvHelpers.cc:5
eonc::helpers::get_value_from_env_or_param
std::string get_value_from_env_or_param(const char *env_variable, const std::string ¶m_value, const std::string &default_value, const std::string &warning_message, const bool is_mandatory)
Definition
EnvHelpers.cc:7
client
EnvHelpers.cc
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf