12#ifndef ZYPP_BYTECOUNT_H
13#define ZYPP_BYTECOUNT_H
17#include <zypp-core/base/Unit.h>
36 typedef base::Unit
Unit;
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; }
133 std::string
asString(
unsigned field_width_r = 0,
134 unsigned unit_width_r = 1 )
const
137 std::string
asString(
unsigned field_width_r,
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 ); }
160 inline std::ostream &
operator<<( std::ostream &
str,
const ByteCount & obj )
161 {
return str << obj.asString(); }
static const Unit MB
1000^2 Byte
static const Unit G
1024^3 Byte
const Unit & bestUnit1000() const
Return the best Unit (B,kB,MB,GB,TB) for count.
static const Unit kB
1000 Byte
SizeType blocks(ByteCount blocksize_r=K) const
Return number of blocks of size blocksize_r (default 1K).
friend std::ostream & operator<<(std::ostream &str, const ByteCount &obj)
ByteCount & fillBlock(ByteCount blocksize_r=K)
Adjust count to multiple of blocksize_r (default 1K).
const Unit & bestUnit() const
Return the best Unit (B,K,M,G,T) for count.
ByteCount & operator+=(const SizeType rhs)
static const Unit K
1024 Byte
ByteCount & operator*=(const SizeType rhs)
static const Unit TB
1000^4 Byte
ByteCount & operator/=(const SizeType rhs)
static const Unit B
1 Byte
ByteCount & operator-=(const SizeType rhs)
ByteCount fullBlocks(ByteCount blocksize_r=K) const
Return count adjusted to multiple of blocksize_r (default 1K).
static const Unit M
1024^2 Byte
static const Unit GB
1000^3 Byte
std::string asString(unsigned field_width_r=0, unsigned unit_width_r=1) const
Auto selected Unit and precision.
static const Unit T
1024^4 Byte
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)