#include <ByteCount.h>
Public Types | |
typedef base::Unit | Unit |
typedef Unit::ValueType | SizeType |
Public Member Functions | |
ByteCount () | |
Default ctor. | |
ByteCount (const Unit &unit_r) | |
Ctor taking 1 Unit. | |
ByteCount (const SizeType count_r, const Unit &unit_r=B) | |
Ctor taking a count and optinal Unit. | |
operator SizeType () const | |
Conversion to SizeType. | |
ByteCount & | fillBlock (ByteCount blocksize_r=K) |
Adjust count to multiple of blocksize_r (default 1K). | |
ByteCount | fullBlocks (ByteCount blocksize_r=K) const |
Return count adjusted to multiple of blocksize_r (default 1K). | |
SizeType | blocks (ByteCount blocksize_r=K) const |
Return number of blocks of size blocksize_r (default 1K). | |
const Unit & | bestUnit () const |
Return the best Unit (B,K,M,G,T) for count. | |
const Unit & | bestUnit1000 () const |
Return the best Unit (B,kB,MB,GB,TB) for count. | |
Arithmetic operations. | |
+ - * / are provided via conversion to SizeType. | |
ByteCount & | operator+= (const SizeType rhs) |
ByteCount & | operator-= (const SizeType rhs) |
ByteCount & | operator*= (const SizeType rhs) |
ByteCount & | operator/= (const SizeType rhs) |
ByteCount & | operator++ () |
ByteCount & | operator-- () |
ByteCount | operator++ (int) |
ByteCount | operator-- (int) |
Conversion to string. | |
| |
std::string | asString (unsigned field_width_r=0, unsigned unit_width_r=1) const |
Auto selected Unit and precision. | |
std::string | asString (unsigned field_width_r, unsigned unit_width_r, unsigned prec_r) const |
Auto selected Unit. | |
std::string | asString (const Unit &unit_r, unsigned field_width_r=0, unsigned unit_width_r=1) const |
Auto selected precision. | |
std::string | asString (const Unit &unit_r, unsigned field_width_r, unsigned unit_width_r, unsigned prec_r) const |
Nothing auto selected. | |
Static Public Attributes | |
Byte unit constants. | |
static const Unit | B |
1 Byte | |
static const Unit | K |
1024 Byte | |
static const Unit | KiB |
static const Unit | M |
1024^2 Byte | |
static const Unit | MiB |
static const Unit | G |
1024^3 Byte | |
static const Unit | GiB |
static const Unit | T |
1024^4 Byte | |
static const Unit | TiB |
static const Unit | kB |
1000 Byte | |
static const Unit | MB |
1000^2 Byte | |
static const Unit | GB |
1000^3 Byte | |
static const Unit | TB |
1000^4 Byte | |
Private Attributes | |
SizeType | _count |
Friends | |
std::ostream & | operator<< (std::ostream &str, const ByteCount &obj) |
Definition at line 30 of file ByteCount.h.
typedef base::Unit zypp::ByteCount::Unit |
Definition at line 36 of file ByteCount.h.
Definition at line 37 of file ByteCount.h.
zypp::ByteCount::ByteCount | ( | ) | [inline] |
zypp::ByteCount::ByteCount | ( | const Unit & | unit_r | ) | [inline] |
zypp::ByteCount::operator SizeType | ( | ) | const [inline] |
ByteCount& zypp::ByteCount::operator++ | ( | ) | [inline] |
ByteCount& zypp::ByteCount::operator-- | ( | ) | [inline] |
ByteCount zypp::ByteCount::operator++ | ( | int | ) | [inline] |
ByteCount zypp::ByteCount::operator-- | ( | int | ) | [inline] |
Adjust count to multiple of blocksize_r (default 1K).
Zero blocksize_r is treated as 1B.
Definition at line 43 of file ByteCount.cc.
References _count.
Return count adjusted to multiple of blocksize_r (default 1K).
Definition at line 110 of file ByteCount.h.
References ByteCount().
Referenced by blocks().
Return number of blocks of size blocksize_r (default 1K).
Definition at line 114 of file ByteCount.h.
References fullBlocks().
const ByteCount::Unit & zypp::ByteCount::bestUnit | ( | ) | const |
Return the best Unit (B,K,M,G,T) for count.
Definition at line 70 of file ByteCount.cc.
References _count, B, zypp::base::Unit::factor(), G, K, M, and T.
Referenced by asString().
const ByteCount::Unit & zypp::ByteCount::bestUnit1000 | ( | ) | const |
Return the best Unit (B,kB,MB,GB,TB) for count.
Definition at line 89 of file ByteCount.cc.
References _count, B, zypp::base::Unit::factor(), GB, kB, MB, and TB.
std::string zypp::ByteCount::asString | ( | unsigned | field_width_r = 0 , |
|
unsigned | unit_width_r = 1 | |||
) | const [inline] |
Auto selected Unit and precision.
Definition at line 133 of file ByteCount.h.
References asString(), and bestUnit().
Referenced by asString().
std::string zypp::ByteCount::asString | ( | unsigned | field_width_r, | |
unsigned | unit_width_r, | |||
unsigned | prec_r | |||
) | const [inline] |
Auto selected Unit.
Definition at line 137 of file ByteCount.h.
References asString(), and bestUnit().
Referenced by asString().
std::string zypp::ByteCount::asString | ( | const Unit & | unit_r, | |
unsigned | field_width_r = 0 , |
|||
unsigned | unit_width_r = 1 | |||
) | const [inline] |
Auto selected precision.
Definition at line 142 of file ByteCount.h.
References asString(), and zypp::base::Unit::prec().
Referenced by asString().
std::string zypp::ByteCount::asString | ( | const Unit & | unit_r, | |
unsigned | field_width_r, | |||
unsigned | unit_width_r, | |||
unsigned | prec_r | |||
) | const [inline] |
Nothing auto selected.
Definition at line 147 of file ByteCount.h.
References _count, and zypp::base::Unit::form().
std::ostream & operator<< | ( | std::ostream & | str, | |
const ByteCount & | obj | |||
) | [friend] |
Stream output
Definition at line 160 of file ByteCount.h.
const ByteCount::Unit zypp::ByteCount::B [static] |
1 Byte
Definition at line 42 of file ByteCount.h.
Referenced by bestUnit(), bestUnit1000(), and zypp::DiskUsageCounter::MountPoint::blockSize().
const ByteCount::Unit zypp::ByteCount::K [static] |
1024 Byte
Definition at line 45 of file ByteCount.h.
Referenced by bestUnit(), zypp::DiskUsageCounter::MountPoint::commitDiff(), zypp::packagedelta::DeltaRpm::DeltaRpm(), zypp::ResObject::downloadSize(), zypp::DiskUsageCounter::MountPoint::freeAfterCommit(), zypp::DiskUsageCounter::MountPoint::freeSize(), zypp::ResObject::installSize(), zypp::sat::Solvable::lookupLocation(), zypp::target::rpm::RpmHeader::tag_du(), zypp::DiskUsageCounter::MountPoint::totalSize(), zypp::DiskUsageCounter::MountPoint::usedAfterCommit(), and zypp::DiskUsageCounter::MountPoint::usedSize().
const ByteCount::Unit zypp::ByteCount::KiB [static] |
Definition at line 46 of file ByteCount.h.
const ByteCount::Unit zypp::ByteCount::M [static] |
const ByteCount::Unit zypp::ByteCount::MiB [static] |
Definition at line 49 of file ByteCount.h.
const ByteCount::Unit zypp::ByteCount::G [static] |
const ByteCount::Unit zypp::ByteCount::GiB [static] |
Definition at line 52 of file ByteCount.h.
const ByteCount::Unit zypp::ByteCount::T [static] |
const ByteCount::Unit zypp::ByteCount::TiB [static] |
Definition at line 55 of file ByteCount.h.
const ByteCount::Unit zypp::ByteCount::kB [static] |
const ByteCount::Unit zypp::ByteCount::MB [static] |
const ByteCount::Unit zypp::ByteCount::GB [static] |
const ByteCount::Unit zypp::ByteCount::TB [static] |
SizeType zypp::ByteCount::_count [private] |
Definition at line 155 of file ByteCount.h.
Referenced by asString(), bestUnit(), bestUnit1000(), fillBlock(), operator SizeType(), operator*=(), operator++(), operator+=(), operator--(), operator-=(), and operator/=().