Store and operate on (file/package/partition) sizes.
More...
#include <FSize.h>
|
enum | Unit {
B,
K,
M,
G,
T,
P,
E,
Z,
Y
} |
| The Units.
|
|
|
| FSize (const boost::multiprecision::cpp_int &size_r=0, const Unit unit_r=Unit::B) |
| Construct from size in certain unit. More...
|
|
| FSize (double size_r) |
| Construct from size in Byte. More...
|
|
| FSize (const std::string &sizeStr, const Unit unit_r=Unit::B) |
| Construct from string containing a number in given unit. More...
|
|
| operator long long () const |
| Conversions to native data types - only explicit as it might overflow If the value is out of range then the behavior depends on the boost version. More...
|
|
| operator int () const |
|
| operator double () const |
|
| operator boost::multiprecision::cpp_int () const |
|
boost::multiprecision::cpp_int | in_unit (const Unit unit_r) const |
|
FSize | operator- () const |
|
FSize & | operator+= (const FSize &rhs) |
|
FSize & | operator-= (const FSize &rhs) |
|
FSize & | operator*= (const FSize &rhs) |
|
FSize & | operator/= (const FSize &rhs) |
|
bool | operator< (const FSize &rhs) const |
|
bool | operator== (const FSize &rhs) const |
|
FSize & | operator++ () |
|
FSize & | operator-- () |
|
FSize & | fillBlock (FSize blocksize_r=boost::multiprecision::cpp_int(KB)) |
| Adjust size to multiple of blocksize_r
|
|
FSize | fullBlock (FSize blocksize_r=boost::multiprecision::cpp_int(KB)) const |
| Return a new size adjusted to multiple of blocksize_r
|
|
Unit | bestUnit () const |
| Return the best unit for string representation.
|
|
std::string | form (const Unit unit_r, unsigned fw=0, unsigned prec=bestPrec, const bool showunit=true) const |
| Return string representation in given Unit. More...
|
|
std::string | form (unsigned fw=0, unsigned prec=bestPrec, const bool showunit=true) const |
| Return string representation in bestUnit.
|
|
std::string | asString () const |
| Default string representation (precision 1 and unit appended).
|
|
|
static boost::multiprecision::cpp_int | factor (const Unit unit_r) |
| Return ammount of bytes in Unit.
|
|
static const char * | unit (const Unit unit_r) |
| String representation of Unit.
|
|
|
static const boost::multiprecision::cpp_int | KB = 1024 |
|
static const boost::multiprecision::cpp_int | MB = FSize::KB * 1024 |
|
static const boost::multiprecision::cpp_int | GB = FSize::MB * 1024 |
|
static const boost::multiprecision::cpp_int | TB = FSize::GB * 1024 |
|
static const boost::multiprecision::cpp_int | PB = FSize::TB * 1024 |
|
static const boost::multiprecision::cpp_int | EB = FSize::PB * 1024 |
|
static const boost::multiprecision::cpp_int | ZB = FSize::EB * 1024 |
|
static const boost::multiprecision::cpp_int | YB = FSize::ZB * 1024 |
|
static const unsigned | bestPrec = (unsigned)-1 |
| Used as precision argument to form(), the 'best' precision according to Unist is chosen.
|
|
Store and operate on (file/package/partition) sizes.
Definition at line 45 of file FSize.h.
◆ FSize() [1/3]
FSize::FSize |
( |
const boost::multiprecision::cpp_int & |
size_r = 0 , |
|
|
const Unit |
unit_r = Unit::B |
|
) |
| |
|
inline |
◆ FSize() [2/3]
FSize::FSize |
( |
double |
size_r | ) |
|
|
inline |
Construct from size in Byte.
- Parameters
-
Definition at line 129 of file FSize.h.
◆ FSize() [3/3]
FSize::FSize |
( |
const std::string & |
sizeStr, |
|
|
const Unit |
unit_r = Unit::B |
|
) |
| |
Construct from string containing a number in given unit.
- Parameters
-
sizeStr | input string - must contain only numbers |
unit_r | optional unit, bytes by default |
- Exceptions
-
std::runtime_error | if the string contains any non numeric characters, even a trailing white space! |
Definition at line 50 of file FSize.cc.
◆ form()
std::string FSize::form |
( |
const Unit |
unit_r, |
|
|
unsigned |
fw = 0 , |
|
|
unsigned |
prec = bestPrec , |
|
|
const bool |
showunit = true |
|
) |
| const |
Return string representation in given Unit.
Parameter fw
and prec
denote field width and precision as in a "%*.*f" printf format string. Avalue of bestPrec
automatically picks an appropriate precision depending on the unit. If showunit
ist true, the string representaion of Unit is appended separated by a single blank.
If Unit is Byte, precision is set to zero.
Definition at line 111 of file FSize.cc.
◆ operator long long()
FSize::operator long long |
( |
| ) |
const |
|
inlineexplicit |
Conversions to native data types - only explicit as it might overflow If the value is out of range then the behavior depends on the boost version.
- 1.67 - the min/max values for the corresponding type are returned
- 1.66 - returns just the lower bits
Definition at line 148 of file FSize.h.
The documentation for this class was generated from the following files:
- /usr/src/RPM/BUILD/libyui-3.4.2/src/FSize.h
- /usr/src/RPM/BUILD/libyui-3.4.2/src/FSize.cc