Update utils

This commit is contained in:
FutureRave 2022-04-26 19:39:50 +01:00
parent 6dc57cc3ed
commit 7f0b485208
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955
5 changed files with 12 additions and 18 deletions

View File

@ -257,7 +257,7 @@ filter {}
filter "configurations:Release"
optimize "Size"
buildoptions {"/GL"}
linkoptions { "/IGNORE:4702", "/LTCG" }
linkoptions {"/IGNORE:4702", "/LTCG"}
defines {"NDEBUG"}
flags {"FatalCompileWarnings"}
filter {}

View File

@ -21,7 +21,8 @@ namespace utils::flags
if (wide_flag[0] == L'-')
{
wide_flag.erase(wide_flag.begin());
flags.emplace_back(string::convert(wide_flag));
const auto flag = string::convert(wide_flag);
flags.emplace_back(string::to_lower(flag));
}
}
@ -40,14 +41,7 @@ namespace utils::flags
parsed = true;
}
for (const auto& entry : enabled_flags)
{
if (string::to_lower(entry) == string::to_lower(flag))
{
return true;
}
}
return false;
return std::ranges::any_of(enabled_flags.cbegin(), enabled_flags.cend(),
[flag](const auto& elem) { return elem == string::to_lower(flag); });
}
}

View File

@ -26,7 +26,7 @@ namespace utils
return value->second;
}
return "";
return {};
}
void info_string::parse(std::string buffer)
@ -49,15 +49,15 @@ namespace utils
{
//auto first = true;
std::string info_string;
for (auto i = this->key_value_pairs_.begin(); i != this->key_value_pairs_.end(); ++i)
for (const auto& [key, val] : this->key_value_pairs_)
{
//if (first) first = false;
/*else*/
info_string.append("\\");
info_string.append(i->first); // Key
info_string.append(key);
info_string.append("\\");
info_string.append(i->second); // Value
info_string.append(val);
}
return info_string;

View File

@ -32,7 +32,7 @@ namespace utils::io
if (stream.is_open())
{
stream.write(data.data(), data.size());
stream.write(data.data(), static_cast<std::streamsize>(data.size()));
stream.close();
return true;
}

View File

@ -64,7 +64,7 @@ namespace utils
void* memory::allocate(const size_t length)
{
return calloc(length, 1);
return std::calloc(length, 1);
}
char* memory::duplicate_string(const std::string& string)
@ -78,7 +78,7 @@ namespace utils
{
if (data)
{
::free(data);
std::free(data);
}
}