LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
lar::details::OptionalHexFloatFormatter< T > Struct Template Reference

#include "hexfloat.h"

Public Types

using real_t = T
 

Public Member Functions

 OptionalHexFloatFormatter (real_t v, bool start_active=true)
 
template<typename Stream >
Stream & operator() (Stream &&os) const
 Prints the value set at construction. More...
 
template<typename Stream >
void write (Stream &&os, real_t v) const
 Prints the specified value into the specified stream. More...
 

Static Public Member Functions

template<typename Stream >
static void write_hexfloat (Stream &&os, real_t v)
 Prints the specified value into the specified stream. More...
 
template<typename Stream >
static void write_standard (Stream &&os, real_t v)
 Prints the specified value into the specified stream. More...
 

Private Attributes

bool active
 whether we are writing in base 16 More...
 
real_t value
 the value to be printed More...
 

Detailed Description

template<typename T>
struct lar::details::OptionalHexFloatFormatter< T >

Definition at line 31 of file hexfloat.h.

Member Typedef Documentation

template<typename T>
using lar::details::OptionalHexFloatFormatter< T >::real_t = T

Definition at line 33 of file hexfloat.h.

Constructor & Destructor Documentation

template<typename T>
lar::details::OptionalHexFloatFormatter< T >::OptionalHexFloatFormatter ( real_t  v,
bool  start_active = true 
)
inline

Definition at line 42 of file hexfloat.h.

43  : active(start_active), value(v) {}
real_t value
the value to be printed
Definition: hexfloat.h:75
bool active
whether we are writing in base 16
Definition: hexfloat.h:74

Member Function Documentation

template<typename T>
template<typename Stream >
Stream& lar::details::OptionalHexFloatFormatter< T >::operator() ( Stream &&  os) const
inline

Prints the value set at construction.

Definition at line 47 of file hexfloat.h.

References lar::details::OptionalHexFloatFormatter< T >::value, and lar::details::OptionalHexFloatFormatter< T >::write().

48  { write(std::forward<Stream>(os), value); return os; }
void write(Stream &&os, real_t v) const
Prints the specified value into the specified stream.
Definition: hexfloat.h:53
real_t value
the value to be printed
Definition: hexfloat.h:75
template<typename T>
template<typename Stream >
void lar::details::OptionalHexFloatFormatter< T >::write ( Stream &&  os,
real_t  v 
) const
inline

Prints the specified value into the specified stream.

Definition at line 53 of file hexfloat.h.

References lar::details::OptionalHexFloatFormatter< T >::active, lar::details::OptionalHexFloatFormatter< T >::write_hexfloat(), and lar::details::OptionalHexFloatFormatter< T >::write_standard().

Referenced by lar::details::OptionalHexFloatFormatter< T >::operator()().

54  {
55  if (active) write_hexfloat(std::forward<Stream>(os), v);
56  else write_standard(std::forward<Stream>(os), v);
57  }
static void write_standard(Stream &&os, real_t v)
Prints the specified value into the specified stream.
Definition: hexfloat.h:71
static void write_hexfloat(Stream &&os, real_t v)
Prints the specified value into the specified stream.
Definition: hexfloat.h:61
bool active
whether we are writing in base 16
Definition: hexfloat.h:74
template<typename T>
template<typename Stream >
static void lar::details::OptionalHexFloatFormatter< T >::write_hexfloat ( Stream &&  os,
real_t  v 
)
inlinestatic

Prints the specified value into the specified stream.

Definition at line 61 of file hexfloat.h.

Referenced by lar::details::OptionalHexFloatFormatter< T >::write().

62  {
63  constexpr auto buf_size = 8 * sizeof(real_t) + 1;
64  char buf[buf_size];
65  std::snprintf(buf, buf_size, "%+24.14a", v);
66  os << buf;
67  }
template<typename T>
template<typename Stream >
static void lar::details::OptionalHexFloatFormatter< T >::write_standard ( Stream &&  os,
real_t  v 
)
inlinestatic

Prints the specified value into the specified stream.

Definition at line 71 of file hexfloat.h.

Referenced by lar::details::OptionalHexFloatFormatter< T >::write().

71 { os << v; }

Member Data Documentation

template<typename T>
real_t lar::details::OptionalHexFloatFormatter< T >::value
private

the value to be printed

Definition at line 75 of file hexfloat.h.

Referenced by lar::details::OptionalHexFloatFormatter< T >::operator()(), and lar::OptionalHexFloat::operator()().


The documentation for this struct was generated from the following file: