libzypp  13.10.6
zypp::ByteCount Class Reference

Store and operate with byte count. More...

#include <ByteCount.h>

Public Types

typedef base::Unit Unit
 
typedef Unit::ValueType SizeType
 

Public Member Functions

 ByteCount ()
 Default ctor. More...
 
 ByteCount (const Unit &unit_r)
 Ctor taking 1 Unit. More...
 
 ByteCount (const SizeType count_r, const Unit &unit_r=B)
 Ctor taking a count and optinal Unit. More...
 
 operator SizeType () const
 Conversion to SizeType. More...
 
ByteCountfillBlock (ByteCount blocksize_r=K)
 Adjust count to multiple of blocksize_r (default 1K). More...
 
ByteCount fullBlocks (ByteCount blocksize_r=K) const
 Return count adjusted to multiple of blocksize_r (default 1K). More...
 
SizeType blocks (ByteCount blocksize_r=K) const
 Return number of blocks of size blocksize_r (default 1K). More...
 
const UnitbestUnit () const
 Return the best Unit (B,K,M,G,T) for count. More...
 
const UnitbestUnit1000 () const
 Return the best Unit (B,kB,MB,GB,TB) for count. More...
 
Arithmetic operations.

+ - * / are provided via conversion to SizeType.

ByteCountoperator+= (const SizeType rhs)
 
ByteCountoperator-= (const SizeType rhs)
 
ByteCountoperator*= (const SizeType rhs)
 
ByteCountoperator/= (const SizeType rhs)
 
ByteCountoperator++ ()
 
ByteCountoperator-- ()
 
ByteCount operator++ (int)
 
ByteCount operator-- (int)
 
Conversion to string.
  • field_width_r Width for the number part (incl. precision)
  • unit_width_r With for the unit symbol (without symbol if zero)
  • prec_r Precision to use.
    See Also
    zypp::base::Unit
std::string asString (unsigned field_width_r=0, unsigned unit_width_r=1) const
 Auto selected Unit and precision. More...
 
std::string asString (unsigned field_width_r, unsigned unit_width_r, unsigned prec_r) const
 Auto selected Unit. More...
 
std::string asString (const Unit &unit_r, unsigned field_width_r=0, unsigned unit_width_r=1) const
 Auto selected precision. More...
 
std::string asString (const Unit &unit_r, unsigned field_width_r, unsigned unit_width_r, unsigned prec_r) const
 Nothing auto selected. More...
 

Static Public Attributes

Byte unit constants.
static const Unit B
 1 Byte More...
 
static const Unit K
 1024 Byte More...
 
static const Unit KiB
 
static const Unit M
 1024^2 Byte More...
 
static const Unit MiB
 
static const Unit G
 1024^3 Byte More...
 
static const Unit GiB
 
static const Unit T
 1024^4 Byte More...
 
static const Unit TiB
 
static const Unit kB
 1000 Byte More...
 
static const Unit MB
 1000^2 Byte More...
 
static const Unit GB
 1000^3 Byte More...
 
static const Unit TB
 1000^4 Byte More...
 

Private Attributes

SizeType _count
 

Friends

std::ostream & operator<< (std::ostream &str, const ByteCount &obj)
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &str, const ByteCount &obj)
 

Detailed Description

Store and operate with byte count.

Definition at line 30 of file ByteCount.h.

Member Typedef Documentation

Definition at line 36 of file ByteCount.h.

Definition at line 37 of file ByteCount.h.

Constructor & Destructor Documentation

zypp::ByteCount::ByteCount ( )
inline

Default ctor.

Definition at line 70 of file ByteCount.h.

zypp::ByteCount::ByteCount ( const Unit unit_r)
inline

Ctor taking 1 Unit.

Definition at line 74 of file ByteCount.h.

zypp::ByteCount::ByteCount ( const SizeType  count_r,
const Unit unit_r = B 
)
inline

Ctor taking a count and optinal Unit.

Definition at line 78 of file ByteCount.h.

Member Function Documentation

zypp::ByteCount::operator SizeType ( ) const
inline

Conversion to SizeType.

Definition at line 85 of file ByteCount.h.

ByteCount& zypp::ByteCount::operator+= ( const SizeType  rhs)
inline

Definition at line 92 of file ByteCount.h.

ByteCount& zypp::ByteCount::operator-= ( const SizeType  rhs)
inline

Definition at line 93 of file ByteCount.h.

ByteCount& zypp::ByteCount::operator*= ( const SizeType  rhs)
inline

Definition at line 94 of file ByteCount.h.

ByteCount& zypp::ByteCount::operator/= ( const SizeType  rhs)
inline

Definition at line 95 of file ByteCount.h.

ByteCount& zypp::ByteCount::operator++ ( )
inline

Definition at line 97 of file ByteCount.h.

ByteCount& zypp::ByteCount::operator-- ( )
inline

Definition at line 98 of file ByteCount.h.

ByteCount zypp::ByteCount::operator++ ( int  )
inline

Definition at line 100 of file ByteCount.h.

ByteCount zypp::ByteCount::operator-- ( int  )
inline

Definition at line 101 of file ByteCount.h.

ByteCount & zypp::ByteCount::fillBlock ( ByteCount  blocksize_r = K)

Adjust count to multiple of blocksize_r (default 1K).

Zero blocksize_r is treated as 1B.

Definition at line 43 of file ByteCount.cc.

ByteCount zypp::ByteCount::fullBlocks ( ByteCount  blocksize_r = K) const
inline

Return count adjusted to multiple of blocksize_r (default 1K).

Definition at line 110 of file ByteCount.h.

SizeType zypp::ByteCount::blocks ( ByteCount  blocksize_r = K) const
inline

Return number of blocks of size blocksize_r (default 1K).

Definition at line 114 of file ByteCount.h.

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.

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.

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.

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.

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.

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.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  str,
const ByteCount obj 
)
friend
std::ostream & operator<< ( std::ostream &  str,
const ByteCount obj 
)
related

Stream output

Definition at line 160 of file ByteCount.h.

Member Data Documentation

const ByteCount::Unit zypp::ByteCount::B
static

1 Byte

Definition at line 42 of file ByteCount.h.

const ByteCount::Unit zypp::ByteCount::K
static

1024 Byte

Definition at line 45 of file ByteCount.h.

const ByteCount::Unit zypp::ByteCount::KiB
static

Definition at line 46 of file ByteCount.h.

const ByteCount::Unit zypp::ByteCount::M
static

1024^2 Byte

Definition at line 48 of file ByteCount.h.

const ByteCount::Unit zypp::ByteCount::MiB
static

Definition at line 49 of file ByteCount.h.

const ByteCount::Unit zypp::ByteCount::G
static

1024^3 Byte

Definition at line 51 of file ByteCount.h.

const ByteCount::Unit zypp::ByteCount::GiB
static

Definition at line 52 of file ByteCount.h.

const ByteCount::Unit zypp::ByteCount::T
static

1024^4 Byte

Definition at line 54 of file ByteCount.h.

const ByteCount::Unit zypp::ByteCount::TiB
static

Definition at line 55 of file ByteCount.h.

const ByteCount::Unit zypp::ByteCount::kB
static

1000 Byte

Definition at line 58 of file ByteCount.h.

const ByteCount::Unit zypp::ByteCount::MB
static

1000^2 Byte

Definition at line 60 of file ByteCount.h.

const ByteCount::Unit zypp::ByteCount::GB
static

1000^3 Byte

Definition at line 62 of file ByteCount.h.

const ByteCount::Unit zypp::ByteCount::TB
static

1000^4 Byte

Definition at line 64 of file ByteCount.h.

SizeType zypp::ByteCount::_count
private

Definition at line 155 of file ByteCount.h.


The documentation for this class was generated from the following files: