LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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 30 of file hexfloat.h.

Member Typedef Documentation

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

Definition at line 32 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 39 of file hexfloat.h.

39  : active(start_active), value(v)
40  {}
real_t value
the value to be printed
Definition: hexfloat.h:79
bool active
whether we are writing in base 16
Definition: hexfloat.h:78

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 44 of file hexfloat.h.

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

45  {
46  write(std::forward<Stream>(os), value);
47  return os;
48  }
void write(Stream &&os, real_t v) const
Prints the specified value into the specified stream.
Definition: hexfloat.h:52
real_t value
the value to be printed
Definition: hexfloat.h:79
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 52 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()().

53  {
54  if (active)
55  write_hexfloat(std::forward<Stream>(os), v);
56  else
57  write_standard(std::forward<Stream>(os), v);
58  }
static void write_standard(Stream &&os, real_t v)
Prints the specified value into the specified stream.
Definition: hexfloat.h:72
static void write_hexfloat(Stream &&os, real_t v)
Prints the specified value into the specified stream.
Definition: hexfloat.h:62
bool active
whether we are writing in base 16
Definition: hexfloat.h:78
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 62 of file hexfloat.h.

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

63  {
64  constexpr auto buf_size = 8 * sizeof(real_t) + 1;
65  char buf[buf_size];
66  std::snprintf(buf, buf_size, "%+24.14a", v);
67  os << buf;
68  }
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 72 of file hexfloat.h.

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

73  {
74  os << v;
75  }

Member Data Documentation

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

the value to be printed

Definition at line 79 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: