12 #ifndef ZYPP_BYTECOUNT_H
13 #define ZYPP_BYTECOUNT_H
75 :
_count( unit_r.factor() )
79 :
_count( count_r * unit_r.factor() )
111 {
return ByteCount(*this).fillBlock( blocksize_r ); }
115 {
return fullBlocks( blocksize_r ) / blocksize_r; }
134 unsigned unit_width_r = 1 )
const
138 unsigned unit_width_r,
139 unsigned prec_r )
const
143 unsigned field_width_r = 0,
144 unsigned unit_width_r = 1 )
const
145 {
return asString( unit_r, field_width_r, unit_width_r, unit_r.
prec() ); }
148 unsigned field_width_r,
149 unsigned unit_width_r,
150 unsigned prec_r )
const
151 {
return unit_r.
form(
_count, field_width_r, unit_width_r, prec_r ); }
166 #endif // ZYPP_BYTECOUNT_H
ByteCount operator++(int)
std::ostream & operator<<(std::ostream &str, const ByteCount &obj)
std::string asString(unsigned field_width_r, unsigned unit_width_r, unsigned prec_r) const
Auto selected Unit.
ByteCount & operator-=(const SizeType rhs)
ByteCount & operator/=(const SizeType rhs)
Store and operate with byte count.
static const Unit GB
1000^3 Byte
std::string form(ValueType val_r, unsigned field_width_r=0, unsigned unit_width_r=1) const
Build string representation of val_r.
std::string asString(const Unit &unit_r, unsigned field_width_r=0, unsigned unit_width_r=1) const
Auto selected precision.
std::string asString(unsigned field_width_r=0, unsigned unit_width_r=1) const
Auto selected Unit and precision.
static const Unit MB
1000^2 Byte
ByteCount fullBlocks(ByteCount blocksize_r=K) const
Return count adjusted to multiple of blocksize_r (default 1K).
const Unit & bestUnit1000() const
Return the best Unit (B,kB,MB,GB,TB) for count.
ByteCount & operator+=(const SizeType rhs)
ByteCount & fillBlock(ByteCount blocksize_r=K)
Adjust count to multiple of blocksize_r (default 1K).
static const Unit G
1024^3 Byte
ByteCount & operator*=(const SizeType rhs)
friend std::ostream & operator<<(std::ostream &str, const ByteCount &obj)
static const Unit B
1 Byte
ByteCount(const Unit &unit_r)
Ctor taking 1 Unit.
ByteCount operator--(int)
Simple handling of Units.
static const Unit M
1024^2 Byte
ByteCount(const SizeType count_r, const Unit &unit_r=B)
Ctor taking a count and optinal Unit.
static const Unit K
1024 Byte
static const Unit T
1024^4 Byte
static const Unit TB
1000^4 Byte
static const Unit kB
1000 Byte
const Unit & bestUnit() const
Return the best Unit (B,K,M,G,T) for count.
std::string asString(const Unit &unit_r, unsigned field_width_r, unsigned unit_width_r, unsigned prec_r) const
Nothing auto selected.
SizeType blocks(ByteCount blocksize_r=K) const
Return number of blocks of size blocksize_r (default 1K).