Static Public Member Functions | List of all members
PrettyPrint Struct Referencefinal

Utilities for printing numeric values in different formats. More...

#include <PrettyPrint.hpp>

Static Public Member Functions

template<typename T >
static std::string binaryPrefix (const T &value, const size_t decimalPlaces)
 Print the value with a binary prefix. More...
 
static std::string byteValue (const size_t bytes, const size_t decimalPlaces=0)
 Returns a string containing the supplied byte value in terms of B/KB/MB/GB etc. More...
 
template<typename Rep , typename Period >
static std::string duration (std::chrono::duration< Rep, Period > d, const size_t decimalPlaces=0)
 Pretty print the duration. More...
 
template<typename T >
static std::string fixed (const T &value, const size_t decimalPlaces)
 Print the value in fixed notation. More...
 
template<typename T >
static std::string metricPrefix (const T &value, size_t decimalPlaces)
 Print the value with a metric prefix. More...
 
template<typename T >
static std::string printHexBytes (const T &value, size_t lineLength=0, size_t groupSize=0)
 Print the value as bytes in hexadecimal. More...
 
static std::string printHexBytes (const char *ptr, size_t byteCount, size_t lineLength=0, size_t groupSize=0)
 Print the bytes in hexadecimal. More...
 
template<typename T >
static std::string scientific (const T &value, const size_t decimalPlaces)
 Print the value in scientific notation. More...
 

Detailed Description

Utilities for printing numeric values in different formats.

Member Function Documentation

◆ binaryPrefix()

static std::string binaryPrefix ( const T &  value,
const size_t  decimalPlaces 
)
inlinestatic

Print the value with a binary prefix.

This is similar to a metric prefix, but uses 2^10 (1024) as the divisor.

Template Parameters
Tthe numeric type: must be castable to a double
Parameters
valuethe value to pretty print
decimalPlacesthe number of decimal places to print

◆ byteValue()

static std::string byteValue ( const size_t  bytes,
const size_t  decimalPlaces = 0 
)
inlinestatic

Returns a string containing the supplied byte value in terms of B/KB/MB/GB etc.

◆ duration()

static std::string duration ( std::chrono::duration< Rep, Period >  d,
const size_t  decimalPlaces = 0 
)
inlinestatic

Pretty print the duration.

Parameters
dthe duration
decimalPlacesthe number of decimal places to print

◆ fixed()

static std::string fixed ( const T &  value,
const size_t  decimalPlaces 
)
inlinestatic

Print the value in fixed notation.

Template Parameters
Tthe numeric type
Parameters
valuethe value to pretty print
decimalPlacesthe number of decimal places to print

◆ metricPrefix()

static std::string metricPrefix ( const T &  value,
size_t  decimalPlaces 
)
inlinestatic

Print the value with a metric prefix.

Template Parameters
Tthe numeric type - must be castable to a long double
Parameters
valuethe value to pretty print
decimalPlacesthe number of decimal places to print

◆ printHexBytes() [1/2]

static std::string printHexBytes ( const T &  value,
size_t  lineLength = 0,
size_t  groupSize = 0 
)
inlinestatic

Print the value as bytes in hexadecimal.

Template Parameters
Tthe numeric type
Parameters
valuethe value to print
lineLengththe maximum length length to print (0 == single line)
groupSizethe number of hex byte values to group together (0 == no groups)

◆ printHexBytes() [2/2]

static std::string printHexBytes ( const char *  ptr,
size_t  byteCount,
size_t  lineLength = 0,
size_t  groupSize = 0 
)
inlinestatic

Print the bytes in hexadecimal.

Parameters
ptrthe pointer to the bytes to print
byteCountthe number of bytes
lineLengththe maximum length length to print (0 == single line)
groupSizethe number of hex byte values to group together (0 == no groups)

◆ scientific()

static std::string scientific ( const T &  value,
const size_t  decimalPlaces 
)
inlinestatic

Print the value in scientific notation.

Template Parameters
Tthe numeric type
Parameters
valuethe value to pretty print
decimalPlacesthe number of decimal places to print

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