Scroom  0.14
format_stuff.hh
Go to the documentation of this file.
1 /*
2  * Scroom - Generic viewer for 2D data
3  * Copyright (C) 2009-2022 Kees-Jan Dijkzeul
4  *
5  * SPDX-License-Identifier: LGPL-2.1
6  */
7 
8 #pragma once
9 
10 #include <fmt/format.h>
11 
12 #include <scroom/point.hh>
13 #include <scroom/rectangle.hh>
14 
15 template <typename T>
16 struct fmt::formatter<Scroom::Utils::Rectangle<T>> : formatter<T>
17 {
18  template <typename FormatContext>
19  auto format(const Scroom::Utils::Rectangle<T>& r, FormatContext& ctx) -> decltype(ctx.out())
20  {
21  format_to(ctx.out(), "<");
22  formatter<T>::format(r.getLeft(), ctx);
23  format_to(ctx.out(), ",");
24  formatter<T>::format(r.getTop(), ctx);
25  format_to(ctx.out(), ",");
26  formatter<T>::format(r.getWidth(), ctx);
27  format_to(ctx.out(), ",");
28  formatter<T>::format(r.getHeight(), ctx);
29  format_to(ctx.out(), ">");
30 
31  return ctx.out();
32  }
33 };
34 
35 template <typename T>
36 struct fmt::formatter<Scroom::Utils::Point<T>> : formatter<T>
37 {
38  template <typename FormatContext>
39  auto format(const Scroom::Utils::Point<T>& p, FormatContext& ctx) -> decltype(ctx.out())
40  {
41  format_to(ctx.out(), "(");
42  formatter<T>::format(p.x, ctx);
43  format_to(ctx.out(), ",");
44  formatter<T>::format(p.y, ctx);
45  format_to(ctx.out(), ")");
46 
47  return ctx.out();
48  }
49 };
fmt::formatter< Scroom::Utils::Point< T > >::format
auto format(const Scroom::Utils::Point< T > &p, FormatContext &ctx) -> decltype(ctx.out())
Definition: format_stuff.hh:39
point.hh
Scroom
Definition: assertions.hh:14
fmt::formatter< Scroom::Utils::Rectangle< T > >::format
auto format(const Scroom::Utils::Rectangle< T > &r, FormatContext &ctx) -> decltype(ctx.out())
Definition: format_stuff.hh:19
Scroom::Utils::Rectangle
Definition: rectangle.hh:22
rectangle.hh
Scroom::Utils::Point
Definition: point.hh:23