The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
fmt::formatter< Gaudi::Histograming::Sink::detail::IntWithFixedWidth > Struct Reference

fmt dedicated formatter for IntWithFixedWidth More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/Gaudi/Histograming/Sink/Utils.h>

Public Member Functions

constexpr auto parse (format_parse_context &ctx)
auto format (Gaudi::Histograming::Sink::detail::IntWithFixedWidth n, format_context &ctx) const

Public Attributes

unsigned int width { 10 }

Detailed Description

fmt dedicated formatter for IntWithFixedWidth

supports 2 kinds of formatting string :

  • the empty '{}' which uses a width of 10
  • '{:n}' where n is an unsigned int, then n is the used width Using this formatter will result is always respecting the given width If the number of digits is less than n, the integer is printed using d, otherwise it's using scientific notation with n-5 digits. So n has to be at least 6

Definition at line 88 of file Utils.h.

Member Function Documentation

◆ format()

auto fmt::formatter< Gaudi::Histograming::Sink::detail::IntWithFixedWidth >::format ( Gaudi::Histograming::Sink::detail::IntWithFixedWidth n,
format_context & ctx ) const
inline

Definition at line 101 of file Utils.h.

101 {
102 auto s = fmt::format( "{:{}d}", n.value, width );
103 if ( s.size() > width ) { s = fmt::format( "{:{}.{}g}", (double)n.value, width, width - 5 ); }
104 return fmt::format_to( ctx.out(), "{:s}", s );
105 }

◆ parse()

auto fmt::formatter< Gaudi::Histograming::Sink::detail::IntWithFixedWidth >::parse ( format_parse_context & ctx)
inlineconstexpr

Definition at line 91 of file Utils.h.

91 {
92 auto it = ctx.begin();
93 if ( it == ctx.end() || *it == '}' ) { return it; }
94 int w = fmt::detail::parse_nonnegative_int( it, ctx.end(), -1 );
95 if ( w == -1 ) throw fmt::format_error( "bad" );
96 width = (unsigned int)w;
97 if ( it == ctx.end() || *it != '}' ) throw fmt::format_error( "bad" );
98 return it;
99 }

Member Data Documentation

◆ width

unsigned int fmt::formatter< Gaudi::Histograming::Sink::detail::IntWithFixedWidth >::width { 10 }

Definition at line 89 of file Utils.h.

89{ 10 };

The documentation for this struct was generated from the following file:
  • GaudiKernel/include/Gaudi/Histograming/Sink/Utils.h