2019-01-10 19:41:51 +00:00
|
|
|
#include <util/str.hpp>
|
2018-10-03 11:00:30 +00:00
|
|
|
|
2018-12-12 02:17:40 +00:00
|
|
|
#include <algorithm>
|
2018-10-03 11:00:30 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
bool
|
|
|
|
IsFalseValue(const char* str)
|
|
|
|
{
|
|
|
|
std::string value = str;
|
|
|
|
std::transform(value.begin(), value.end(), value.begin(),
|
|
|
|
[](char ch) -> char { return std::tolower(ch); });
|
2019-04-28 11:48:29 +00:00
|
|
|
return value == "no" || value == "false" || value == "0" || value == "off";
|
2018-10-03 11:00:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
IsTrueValue(const char* str)
|
|
|
|
{
|
|
|
|
std::string value = str;
|
|
|
|
std::transform(value.begin(), value.end(), value.begin(),
|
|
|
|
[](char ch) -> char { return std::tolower(ch); });
|
2019-04-28 11:48:29 +00:00
|
|
|
return value == "yes" || value == "true" || value == "1" || value == "on";
|
2018-10-03 11:00:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
StrEq(const char* s1, const char* s2)
|
|
|
|
{
|
|
|
|
size_t sz1 = strlen(s1);
|
|
|
|
size_t sz2 = strlen(s2);
|
|
|
|
if(sz1 == sz2)
|
|
|
|
{
|
|
|
|
return strncmp(s1, s2, sz1) == 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} // namespace llarp
|