This struct is used to format sizes of byte arrays (streams, files, etc), in accordance with SI units (kB, MB, GB, etc). Integral values embedded in this struct are appendable to class AString.
Definition at line 150 of file bytesize.hpp.
#include <bytesize.hpp>
Public Field Index: | |
uint16_t | MagnitudeThreshold |
char | UnitSeparator |
An optional character to separate the number from the unit. | |
uinteger | Value |
The encapsulated value to print. | |
Public Method Index: | |
constexpr | ByteSizeSI (uinteger value, uint16_t magnitudeThreshold=800, char unitSeparator='\0') noexcept |
ALIB_API double | ConvertTo (ByteSizeUnits unit) |
ALIB_API std::pair< double, ByteSizeUnits > | GetMagnitude () |
uint16_t MagnitudeThreshold |
The lowest value to use with the next lower possible magnitude. If for example to 900
, then 0.9 GiB is preferred over 900.0 MiB.
Definition at line 153 of file bytesize.hpp.
char UnitSeparator |
An optional character to separate the number from the unit.
Definition at line 156 of file bytesize.hpp.
uinteger Value |
The encapsulated value to print.
Definition at line 152 of file bytesize.hpp.
|
inlineconstexprnoexcept |
Constructor.
value | The value to append/format. |
magnitudeThreshold | Stored in MagnitudeThreshold. Defaults to 800 . |
unitSeparator | Separation character between printed number and unit. Defaults to 0 . |
Definition at line 163 of file bytesize.hpp.
ALIB_API double ConvertTo | ( | ByteSizeUnits | unit | ) |
Returns a double value converted to the given unit. Note that while this class otherwise is responsible for SI units, conversions to IEC-units may be requested.
unit | The unit to convert to. |
double
converted to unit. ALIB_API std::pair< double, ByteSizeUnits > GetMagnitude | ( | ) |
Evaluates the magnitude of the value and returns the converted double
value between 0.0
and threshold.
double
together with the magnitude flag.