mirror of
https://github.com/c-sooyoung/fold_slice.git
synced 2026-09-18 00:49:09 +09:00
initial commit
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#ifndef ENV_HELPER_H
|
||||
#define ENV_HELPER_H
|
||||
|
||||
/*!
|
||||
* \file
|
||||
* Helper functions for environment parsing
|
||||
*/
|
||||
|
||||
namespace env {
|
||||
|
||||
/*!
|
||||
* \brief Check if environment variable steered feature is enabled
|
||||
*
|
||||
* \param envvar environment variable name
|
||||
* \return true if feature is enabled
|
||||
*/
|
||||
inline bool is_enabled (const std::string &envvar)
|
||||
{
|
||||
char *val = std::getenv(envvar.c_str());
|
||||
if (! val)
|
||||
return false;
|
||||
std::string value(val);
|
||||
if (value == "1")
|
||||
return true;
|
||||
if (value == "yes")
|
||||
return true;
|
||||
if (value == "true")
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user