mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-11 16:46:16 +00:00
Fix clang tidy
This commit is contained in:
@@ -181,4 +181,23 @@ namespace utils::string
|
||||
{
|
||||
return std::ranges::equal(lhs, rhs, [](const auto c1, const auto c2) { return char_to_lower(c1) == char_to_lower(c2); });
|
||||
}
|
||||
|
||||
template <typename Integer, class Elem, class Traits>
|
||||
requires(std::is_integral_v<Integer>)
|
||||
Integer parse_number(const std::basic_string_view<Elem, Traits> str)
|
||||
{
|
||||
Integer result = 0;
|
||||
|
||||
for (const auto ch : str)
|
||||
{
|
||||
if (ch < u'0' || ch > u'9')
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
result = result * 10 + static_cast<Integer>(ch - u'0');
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,17 +182,21 @@ namespace
|
||||
const auto key = registry.get_key({R"(\Registry\Machine\Software\Microsoft\Windows NT\CurrentVersion)"});
|
||||
|
||||
if (!key)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (size_t i = 0; const auto value = registry.get_value(*key, i); ++i)
|
||||
{
|
||||
if (value->type != REG_SZ)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value->name == "CurrentBuildNumber" || value->name == "CurrentBuild")
|
||||
{
|
||||
const auto* s = reinterpret_cast<const char16_t*>(value->data.data());
|
||||
return static_cast<uint32_t>(std::wcstoul(reinterpret_cast<const wchar_t*>(s), nullptr, 10));
|
||||
return utils::string::parse_number<uint32_t>(std::u16string_view(s));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user