Made some UI states persistent across sessions, ref #484

This commit is contained in:
emeric
2024-09-12 14:01:03 +02:00
parent da22843272
commit c165ed9f2f
25 changed files with 486 additions and 101 deletions
+17 -6
View File
@@ -67,14 +67,25 @@ namespace lms::core::stringUtils
template<typename T>
[[nodiscard]] std::optional<T> readAs(std::string_view str)
{
T res;
if constexpr (std::is_enum_v<T>)
{
using UnderlyingType = std::underlying_type_t<T>;
std::optional<UnderlyingType> underlyingValue{ readAs<UnderlyingType>(str) };
if (!underlyingValue)
return std::nullopt;
std::istringstream iss{ std::string{ str } };
iss >> res;
if (iss.fail())
return std::nullopt;
return static_cast<T>(*underlyingValue);
}
else
{
T res;
std::istringstream iss{ std::string{ str } };
iss >> res;
if (iss.fail())
return std::nullopt;
return res;
return res;
}
}
template<>