Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/src/common/gsvector_formatter.h
4222 views
1
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <[email protected]>
2
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
3
4
#pragma once
5
6
#include "gsvector.h"
7
#include "small_string.h"
8
9
#include "fmt/format.h"
10
11
template<>
12
struct fmt::formatter<GSVector2i> : formatter<std::string_view>
13
{
14
auto format(const GSVector2i& rc, format_context& ctx) const
15
{
16
const TinyString str = TinyString::from_format("{},{}", rc.x, rc.y);
17
return fmt::formatter<std::string_view>::format(str.view(), ctx);
18
}
19
};
20
21
template<>
22
struct fmt::formatter<GSVector2> : formatter<std::string_view>
23
{
24
auto format(const GSVector2& rc, format_context& ctx) const
25
{
26
const TinyString str = TinyString::from_format("{},{}", rc.x, rc.y);
27
return fmt::formatter<std::string_view>::format(str.view(), ctx);
28
}
29
};
30
31
template<>
32
struct fmt::formatter<GSVector4i> : formatter<std::string_view>
33
{
34
auto format(const GSVector4i& rc, format_context& ctx) const
35
{
36
const TinyString str =
37
TinyString::from_format("{},{} => {},{} ({}x{})", rc.left, rc.top, rc.right, rc.bottom, rc.width(), rc.height());
38
39
return fmt::formatter<std::string_view>::format(str.view(), ctx);
40
}
41
};
42
43
template<>
44
struct fmt::formatter<GSVector4> : formatter<std::string_view>
45
{
46
auto format(const GSVector4& rc, format_context& ctx) const
47
{
48
const TinyString str = TinyString::from_format("{},{},{},{}", rc.x, rc.y, rc.z, rc.w);
49
return fmt::formatter<std::string_view>::format(str.view(), ctx);
50
}
51
};
52
53