koutil
Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1
#ifndef KOUTIL_UTIL_UTILS_H
2
#define KOUTIL_UTIL_UTILS_H
3
4
#if defined(__linux__)
5
#define OS_LINUX
6
#elif defined(_WIN32) || defined(_WIN64)
7
#define OS_WINDOWS
8
#endif
9
10
#include <cstdlib>
11
#include <string_view>
12
13
#ifdef OS_WINDOWS
14
// [C4996] 'getenv': This function or variable may be unsafe
15
#pragma warning(disable : 4996)
16
#endif
17
18
namespace
koutil::util
{
19
20
constexpr
char
ESC
=
'\x1B'
;
21
22
inline
std::string_view
safe_getenv
(
const
char
* name) {
23
const
char
* value = std::getenv(name);
24
if
(value ==
nullptr
) {
25
return
""
;
26
}
else
{
27
return
value;
28
}
29
}
30
31
}
32
33
#endif
koutil::util
Definition
utils.h:18
koutil::util::ESC
constexpr char ESC
Definition
utils.h:20
koutil::util::safe_getenv
std::string_view safe_getenv(const char *name)
Definition
utils.h:22
include
koutil
util
utils.h
Generated by
1.11.0