libyui
3.3.1
|
Store and operate on (file/package/partition) sizes (long long). More...
#include <FSize.h>
Public Types | |
enum | Unit { B = 0, K, M, G, T } |
The Units. | |
Public Member Functions | |
FSize (const long long size_r=0) | |
Construct from size in Byte. | |
FSize (const long long size_r, const Unit unit_r) | |
Construct from size in certain unit. More... | |
FSize (const std::string &sizeStr, const Unit unit_r=B) | |
Construct from string containing a number in given unit. | |
operator long long () const | |
Conversion to long long. | |
FSize & | operator+= (const long long rhs) |
FSize & | operator-= (const long long rhs) |
FSize & | operator*= (const long long rhs) |
FSize & | operator/= (const long long rhs) |
FSize & | operator++ () |
FSize & | operator-- () |
FSize | operator++ (int) |
FSize | operator-- (int) |
FSize & | fillBlock (FSize blocksize_r=KB) |
Adjust size to multiple of blocksize_r | |
FSize | fullBlock (FSize blocksize_r=KB) const |
Return size adjusted to multiple of blocksize_r | |
long long | operator() (const Unit unit_r) const |
Return size in Unit ( not rounded ) | |
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 Public Member Functions | |
static long long | factor (const Unit unit_r) |
Return ammount of Byte in Unit. | |
static const char * | unit (const Unit unit_r) |
String representation of Unit. | |
Static Public Attributes | |
static const long long | KB = 1024 |
static const long long | MB = 1024 * KB |
static const long long | GB = 1024 * MB |
static const long long | TB = 1024 * GB |
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 (long long).
|
inline |
Construct from size in certain unit.
E.g. FSize( 1, FSize::K )
makes 1024 Byte.
Definition at line 103 of file FSize.h.
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 87 of file FSize.cc.