55#include <fmt/format.h>
56#include <fmt/ranges.h>
63template <
typename T,
typename V,
typename H,
typename Char>
64struct fmt::is_range<
Gaudi::Property<T, V, H>, Char> : std::false_type {};
66#define GAUDI_PROPERTY_FORMATTING_IMPL( ns, assert_for_ranges ) \
67 template <typename T, typename V, typename H> \
68 struct ns::formatter<Gaudi::Property<T, V, H>> : ns::formatter<T> { \
71 constexpr auto parse( ns::format_parse_context& ctx ) { \
72 auto it = ctx.begin(), end = ctx.end(); \
73 if ( it != end && *it == '?' ) { \
76 if ( it != end && *it != '}' ) throw ns::format_error( "invalid format" ); \
79 return ns::formatter<T>::parse( ctx ); \
81 auto format( const Gaudi::Property<T, V, H>& p, ns::format_context& ctx ) const { \
83 if constexpr ( std::is_same_v<T, std::string> ) { \
84 std::stringstream s; \
85 s << std::quoted( p.value(), '\'' ); \
86 return ns::format_to( ctx.out(), " '{}':{}", p.name(), s.str() ); \
88 return ns::format_to( ctx.out(), " '{}':{}", p.name(), p.value() ); \
91 return ns::formatter<T>::format( static_cast<const T&>( p ), ctx ); \
98#ifndef __cpp_lib_format_ranges
99# define assert_for_ranges \
100 static_assert( !std::ranges::range<T> || std::is_same_v<T, std::string>, \
101 "Range-valued Property formatting is not supported with std::format in C++20" )
103# define assert_for_ranges static_assert( true )
108#undef assert_for_ranges
109#undef GAUDI_PROPERTY_FORMATTING_IMPL
#define GAUDI_PROPERTY_FORMATTING_IMPL(ns, assert_for_ranges)
#define assert_for_ranges
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...