aboutsummaryrefslogtreecommitdiffstats
path: root/common/strutils.cpp
blob: 0163de7b125877ad1b8b4c544ed32b725261762c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

#include "config.h"

#include "strutils.h"

#include <cstdlib>


namespace al {

al::optional<std::string> getenv(const char *envname)
{
    const char *str{std::getenv(envname)};
    if(str && str[0] != '\0') return str;
    return al::nullopt;
}

#ifdef _WIN32
al::optional<std::wstring> getenv(const WCHAR *envname)
{
    const WCHAR *str{_wgetenv(envname)};
    if(str && str[0] != L'\0') return str;
    return al::nullopt;
}
#endif

} // namespace al