template <typename T, typename V, typename H> \
struct ns::formatter<
Gaudi::Property<T, V, H>> : ns::formatter<T> { \
bool debug = false; \
constexpr auto parse( ns::format_parse_context& ctx ) { \
auto it = ctx.begin(), end = ctx.end(); \
if ( it != end && *it == '?' ) { \
debug = true; \
++it; \
if ( it != end && *it != '}' ) throw ns::format_error( "invalid format" ); \
return it; \
} \
return ns::formatter<T>::
parse( ctx ); \
} \
auto
format( const
Gaudi::Property<T, V, H>& p, ns::format_context& ctx )
const { \
if ( debug ) { \
if constexpr ( std::is_same_v<T, std::string> ) { \
std::stringstream s; \
s << std::quoted( p.value(), '\'' ); \
return ns::format_to( ctx.out(), " '{}':{}", p.name(), s.str() ); \
} else { \
return ns::format_to( ctx.out(), " '{}':{}", p.name(), p.value() ); \
} \
} else { \
return ns::formatter<T>::format( static_cast<const T&>( p ), ctx ); \
} \
} \
};
StatusCode parse(DataObjID &dest, std::string_view src)
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
#define assert_for_ranges
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
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> { \
69 assert_for_ranges; \
70 bool debug = false; \
71 constexpr auto parse( ns::format_parse_context& ctx ) { \
72 auto it = ctx.begin(), end = ctx.end(); \
73 if ( it != end && *it == '?' ) { \
74 debug = true; \
75 ++it; \
76 if ( it != end && *it != '}' ) throw ns::format_error( "invalid format" ); \
77 return it; \
78 } \
79 return ns::formatter<T>::parse( ctx ); \
80 } \
81 auto format( const Gaudi::Property<T, V, H>& p, ns::format_context& ctx ) const { \
82 if ( debug ) { \
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() ); \
87 } else { \
88 return ns::format_to( ctx.out(), " '{}':{}", p.name(), p.value() ); \
89 } \
90 } else { \
91 return ns::formatter<T>::format( static_cast<const T&>( p ), ctx ); \
92 } \
93 } \
94 };