R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BFormatters.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2024 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2024-2026 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
14#pragma once
15
16#ifndef __CLING__
17#include "R3BShared.h"
18#include "R3BValueError.h"
19#include <Math/Vector3Dfwd.h>
20#include <TVector3.h>
21#include <fmt/base.h>
22#include <fmt/core.h>
23#include <fmt/format.h>
24
25// NOLINTNEXTLINE(misc-include-cleaner)
26#include <Math/Vector3D.h>
27
28template <>
29class fmt::formatter<TVector3>
30{
31 public:
32 static constexpr auto parse(format_parse_context& ctx) { return ctx.end(); }
33 template <typename FmtContent>
34 constexpr auto format(const TVector3& vec, FmtContent& ctn) const
35 {
36 return fmt::format_to(ctn.out(), "[x: {}, y: {}, z: {}]", vec.X(), vec.Y(), vec.Z());
37 }
38};
39
40template <>
41class fmt::formatter<ROOT::Math::XYZVector>
42{
43 public:
44 static constexpr auto parse(format_parse_context& ctx) { return ctx.end(); }
45 template <typename FmtContent>
46 constexpr auto format(const ROOT::Math::XYZVector& vec, FmtContent& ctn) const
47 {
48 return fmt::format_to(ctn.out(), "[x: {}, y: {}, z: {}]", vec.X(), vec.Y(), vec.Z());
49 }
50};
51
52template <typename DataType>
53class fmt::formatter<R3B::LRPair<DataType>>
54{
55 public:
56 static constexpr auto parse(format_parse_context& ctx) { return ctx.end(); }
57 template <typename FmtContent>
58 constexpr auto format(const R3B::LRPair<DataType>& data_pair, FmtContent& ctn) const
59 {
60 return fmt::format_to(ctn.out(), "[left: {}, right: {}]", data_pair.left(), data_pair.right());
61 }
62};
63
64template <>
65class fmt::formatter<R3B::Side>
66{
67 public:
68 static constexpr auto parse(format_parse_context& ctx) { return ctx.end(); }
69 template <typename FmtContent>
70 constexpr auto format(const R3B::Side& side, FmtContent& ctn) const
71 {
72 if (side == R3B::Side::left)
73 {
74 return fmt::format_to(ctn.out(), "{}", "left");
75 }
76 return fmt::format_to(ctn.out(), "{}", "right");
77 }
78};
79#endif
Side
Definition R3BShared.h:112
auto left() -> DataType &
Definition R3BShared.h:149
auto right() -> DataType &
Definition R3BShared.h:150
constexpr auto format(const R3B::LRPair< DataType > &data_pair, FmtContent &ctn) const
static constexpr auto parse(format_parse_context &ctx)
constexpr auto format(const R3B::Side &side, FmtContent &ctn) const
static constexpr auto parse(format_parse_context &ctx)
static constexpr auto parse(format_parse_context &ctx)
constexpr auto format(const ROOT::Math::XYZVector &vec, FmtContent &ctn) const
constexpr auto format(const TVector3 &vec, FmtContent &ctn) const
static constexpr auto parse(format_parse_context &ctx)