Add double constructor for Version

This commit is contained in:
Georg Hagen
2025-06-11 17:06:20 +02:00
parent 6d49c7199f
commit 3b243260c0
2 changed files with 18 additions and 0 deletions

View File

@@ -178,4 +178,20 @@ namespace OpenVulkano
return CompareTimestamp(other);
}
//endregion
namespace
{
uint32_t GetDigits(double val)
{
if (val == 0) return 0;
std::string fracStr = std::to_string(val);
fracStr.erase(fracStr.find_last_not_of('0') + 1, std::string::npos);
fracStr.erase(0, fracStr.find_first_of('.') + 1);
return std::stoul(fracStr);
}
}
Version::Version(double version)
: Version(static_cast<uint32_t>(version), GetDigits(version))
{}
}

View File

@@ -32,6 +32,8 @@ namespace OpenVulkano
Version(std::string_view versionString, bool ignoreTags = false);
explicit Version(double version);
[[nodiscard]] uint32_t GetComponent(size_t compId) const
{
if (m_versionComponents.size() < compId + 1) return 0u;