[ox/model] Add constexpr ModelTypeId_v

This commit is contained in:
Gary Talent 2024-04-09 23:52:43 -05:00
parent 0c09c5306e
commit 7941a514ba

View File

@ -147,4 +147,19 @@ constexpr auto ModelTypeName_v = getModelTypeName<T, Str>();
template<typename T, typename Str = const char*> template<typename T, typename Str = const char*>
constexpr auto ModelTypeVersion_v = requireModelTypeVersion<T>(); constexpr auto ModelTypeVersion_v = requireModelTypeVersion<T>();
template<typename T, typename Str = const char*>
constexpr auto ModelTypeVersionStr_v = [] {
constexpr auto version = ModelTypeVersion_v<T>;
constexpr auto versionStr = ox::sfmt("{}", version);
return ox::BString<versionStr.len()>{versionStr};
};
template<typename T>
constexpr auto ModelTypeId_v = [] {
constexpr auto name = ModelTypeName_v<T, ox::StringView>;
constexpr auto version = ModelTypeVersion_v<T>;
constexpr auto versionStr = ox::sfmt<ox::BString<19>>("{}", version);
return ox::sfmt<ox::BString<name.len() + versionStr.len() + 1>>("{};{}", name, versionStr);
}();
} }