/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #pragma once #if __has_include("fmt/format.h") #include #elif __has_include("spdlog/fmt/fmt.h") #include #else #error "Failed to find fmt include" #endif #include "Math/ByteSize.hpp" #include "Math/Math.hpp" #include "Math/Range.hpp" #include "Base/UUID.hpp" #include #include template<> struct fmt::formatter { template constexpr auto parse(ParseContext& ctx) { return ctx.begin(); } template auto format(const OpenVulkano::ByteSize& bs, FormatContext& ctx) const { return fmt::format_to(ctx.out(), "{}", bs.Format()); } }; template<> struct fmt::formatter : fmt::formatter { template auto format(const std::filesystem::path& path, format_context& ctx) const requires std::is_same_v { return formatter::format(path.native(), ctx); } template auto format(const std::filesystem::path& path, format_context& ctx) const requires std::is_same_v { return formatter::format(path.string(), ctx); } }; template struct fmt::formatter> { template constexpr auto parse(ParseContext& ctx) { return ctx.begin(); } template auto format(const glm::vec<2, T, Q>& v, FormatContext& ctx) const { return fmt::format_to(ctx.out(), "({}, {})", v.x, v.y); } }; template struct fmt::formatter> { template constexpr auto parse(ParseContext& ctx) { return ctx.begin(); } template auto format(const glm::vec<3, T, Q>& v, FormatContext& ctx) const { return fmt::format_to(ctx.out(), "({}, {}, {})", v.x, v.y, v.z); } }; template struct fmt::formatter> { template constexpr auto parse(ParseContext& ctx) { return ctx.begin(); } template auto format(const glm::vec<4, T, Q>& v, FormatContext& ctx) const { return fmt::format_to(ctx.out(), "({}, {}, {}, {})", v.x, v.y, v.z, v.w); } }; template struct fmt::formatter> { template constexpr auto parse(ParseContext& ctx) { return ctx.begin(); } template auto format(const glm::mat<2, 2, T, Q>& m, FormatContext& ctx) const { return fmt::format_to(ctx.out(), "[[{}, {}], [{}, {}]]", m[0][0], m[1][0], m[0][1], m[1][1]); } }; template struct fmt::formatter> { template constexpr auto parse(ParseContext& ctx) { return ctx.begin(); } template auto format(const glm::mat<3, 3, T, Q>& m, FormatContext& ctx) const { return fmt::format_to(ctx.out(), "[[{}, {}, {}], [{}, {}, {}], [{}, {}, {}]]", m[0][0], m[1][0], m[2][0], m[0][1], m[1][1], m[2][1], m[0][2], m[1][2], m[2][2]); } }; template struct fmt::formatter> { template constexpr auto parse(ParseContext& ctx) { return ctx.begin(); } template auto format(const glm::mat<4, 4, T, Q>& m, FormatContext& ctx) const { return fmt::format_to(ctx.out(), "[[{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}], [{}, {}, {}, {}]]", m[0][0], m[1][0], m[2][0], m[3][0], m[0][1], m[1][1], m[2][1], m[3][1], m[0][2], m[1][2], m[2][2], m[3][2], m[0][3], m[1][3], m[2][3], m[3][3]); } }; template struct fmt::formatter> { template constexpr auto parse(ParseContext& ctx) { return ctx.begin(); } template auto format(const glm::qua& q, FormatContext& ctx) const { return fmt::format_to(ctx.out(), "({}, {}, {}, {})", q.w, q.x, q.y, q.z); } }; template struct fmt::formatter> : fmt::formatter { template constexpr auto parse(ParseContext& ctx) { return ctx.begin(); } template auto format(const OpenVulkano::Math::Range& range, FormatContext& ctx) const { return fmt::format_to(ctx.out(), "[{}, {}]", range.min, range.max); } }; template<> struct fmt::formatter : fmt::formatter { template constexpr auto parse(ParseContext& ctx) { return ctx.begin(); } template auto format(const OpenVulkano::UUID& uuid, FormatContext& ctx) const { return fmt::format_to(ctx.out(), "{}", uuid.string()); } };