45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
/*
|
|
* 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 <fmt/format.h>
|
|
#elif __has_include("spdlog/fmt/fmt.h")
|
|
#include <spdlog/fmt/fmt.h>
|
|
#else
|
|
#error "Failed to find fmt include"
|
|
#endif
|
|
#include "Math/ByteSize.hpp"
|
|
#include <filesystem>
|
|
|
|
template<> struct fmt::formatter<OpenVulkano::ByteSize>
|
|
{
|
|
template<typename ParseContext> constexpr auto parse(ParseContext& ctx)
|
|
{
|
|
return ctx.begin();
|
|
}
|
|
|
|
template<typename FormatContext> auto format(const OpenVulkano::ByteSize& bs, FormatContext& ctx) const
|
|
{
|
|
return fmt::format_to(ctx.out(), "{}", bs.Format());
|
|
}
|
|
};
|
|
|
|
template<> struct fmt::formatter<std::filesystem::path> : fmt::formatter<std::string>
|
|
{
|
|
template<typename PATH = std::filesystem::path>
|
|
auto format(const std::filesystem::path& path, format_context& ctx) const requires std::is_same_v<std::filesystem::path::value_type, char>
|
|
{
|
|
return formatter<std::string>::format(path.native(), ctx);
|
|
}
|
|
|
|
template<typename PATH = std::filesystem::path>
|
|
auto format(const std::filesystem::path& path, format_context& ctx) const requires std::is_same_v<std::filesystem::path::value_type, wchar_t>
|
|
{
|
|
return formatter<std::string>::format(path.string(), ctx);
|
|
}
|
|
}; |