Formatter for Base/UUID and Math/Range

This commit is contained in:
Vladyslav Baranovskyi
2025-02-13 13:11:12 +02:00
parent 9eaecd7982
commit 1c31850497

View File

@@ -15,6 +15,8 @@
#endif
#include "Math/ByteSize.hpp"
#include "Math/Math.hpp"
#include "Math/Range.hpp"
#include "Base/UUID.hpp"
#include <filesystem>
template<> struct fmt::formatter<OpenVulkano::ByteSize>
@@ -157,4 +159,36 @@ struct fmt::formatter<glm::qua<T, Q>>
{
return fmt::format_to(ctx.out(), "({}, {}, {}, {})", q.w, q.x, q.y, q.z);
}
};
template<typename T>
struct fmt::formatter<OpenVulkano::Math::Range<T>> : fmt::formatter<std::string>
{
template<typename ParseContext>
constexpr auto parse(ParseContext& ctx)
{
return ctx.begin();
}
template<typename FormatContext>
auto format(const OpenVulkano::Math::Range<T>& range, FormatContext& ctx) const
{
return fmt::format_to(ctx.out(), "[{}, {}]", range.min, range.max);
}
};
template<>
struct fmt::formatter<OpenVulkano::UUID> : fmt::formatter<std::string>
{
template<typename ParseContext>
constexpr auto parse(ParseContext& ctx)
{
return ctx.begin();
}
template<typename FormatContext>
auto format(const OpenVulkano::UUID& uuid, FormatContext& ctx) const
{
return fmt::format_to(ctx.out(), "{}", uuid.string());
}
};