Utilities for printing numeric values in different formats.
More...
#include <PrettyPrint.hpp>
|
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...
|
|
Utilities for printing numeric values in different formats.
◆ 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
-
T | the numeric type: must be castable to a double |
- Parameters
-
value | the value to pretty print |
decimalPlaces | the 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
-
d | the duration |
decimalPlaces | the 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
-
- Parameters
-
value | the value to pretty print |
decimalPlaces | the 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
-
T | the numeric type - must be castable to a long double |
- Parameters
-
value | the value to pretty print |
decimalPlaces | the 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
-
- Parameters
-
value | the value to print |
lineLength | the maximum length length to print (0 == single line) |
groupSize | the 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
-
ptr | the pointer to the bytes to print |
byteCount | the number of bytes |
lineLength | the maximum length length to print (0 == single line) |
groupSize | the 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
-
- Parameters
-
value | the value to pretty print |
decimalPlaces | the number of decimal places to print |
The documentation for this struct was generated from the following file: