|
libyui
3.4.2
|
Store and operate on (file/package/partition) sizes. More...
#include <FSize.h>


Public Types | |
| enum | Unit { B, K, M, G, T, P, E, Z, Y } |
| The Units. | |
Public Member Functions | |
| 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 Public Member Functions | |
| 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 Public Attributes | |
| 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. | |
|
inline |
Construct from size in certain unit.
E.g. FSize( 1, FSize::Unit::K ) makes 1024 Byte.
|
inline |
| FSize::FSize | ( | const std::string & | sizeStr, |
| const Unit | unit_r = Unit::B |
||
| ) |
Construct from string containing a number in given unit.
| sizeStr | input string - must contain only numbers |
| unit_r | optional unit, bytes by default |
| std::runtime_error | if the string contains any non numeric characters, even a trailing white space! |
| 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.

|
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.
Definition at line 148 of file FSize.h.
