libzypp: zypp::ByteCount Class Reference

libzypp 17.38.11

zypp::ByteCount Class Reference

Store and operate with byte count. More...

`#include <zypp-core/ByteCount.h>`

## Public Types
using | Unit = base::Unit
using | SizeType = Unit::ValueType

## Public Member Functions
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)
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.

## Friends
std::ostream & | operator<< (std::ostream &str, const ByteCount &obj)
| relates: ByteCount Stream output

## 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
| 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.

## 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
SizeType | _count
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.

## Detailed Description

Store and operate with byte count.

Definition at line 31 of file ByteCount.h.

## Member Typedef Documentation

## ◆ Unit

using zypp::ByteCount::Unit = base::Unit

Definition at line 37 of file ByteCount.h.

## ◆ SizeType

using zypp::ByteCount::SizeType = Unit::ValueType

Definition at line 38 of file ByteCount.h.

## Constructor & Destructor Documentation

## ◆ ByteCount() [1/3]

zypp::ByteCount::ByteCount | ( |  | ) |
| inline

Default ctor.

Definition at line 71 of file ByteCount.h.

## ◆ ByteCount() [2/3]

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

Ctor taking 1 Unit.

Definition at line 75 of file ByteCount.h.

## ◆ ByteCount() [3/3]

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

Ctor taking a count and optinal Unit.

Definition at line 79 of file ByteCount.h.

## Member Function Documentation

## ◆ operator SizeType()

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

Conversion to SizeType.

Definition at line 86 of file ByteCount.h.

## ◆ operator+=()

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

Definition at line 93 of file ByteCount.h.

## ◆ operator-=()

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

Definition at line 94 of file ByteCount.h.

## ◆ operator*=()

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

Definition at line 95 of file ByteCount.h.

## ◆ operator/=()

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

Definition at line 96 of file ByteCount.h.

## ◆ operator++() [1/2]

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

Definition at line 98 of file ByteCount.h.

## ◆ operator--() [1/2]

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

Definition at line 99 of file ByteCount.h.

## ◆ operator++() [2/2]

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

Definition at line 101 of file ByteCount.h.

## ◆ operator--() [2/2]

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

Definition at line 102 of file ByteCount.h.

## ◆ fillBlock()

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.

## ◆ fullBlocks()

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

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

Definition at line 111 of file ByteCount.h.

## ◆ blocks()

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

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

Definition at line 115 of file ByteCount.h.

## ◆ bestUnit()

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.

## ◆ bestUnit1000()

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.

## ◆ asString() [1/4]

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 134 of file ByteCount.h.

## ◆ asString() [2/4]

std::string zypp::ByteCount::asString | ( | unsigned | field_width_r,
|  | unsigned | unit_width_r,
|  | unsigned | prec_r ) const
| inline

Auto selected Unit.

Definition at line 138 of file ByteCount.h.

## ◆ asString() [3/4]

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 143 of file ByteCount.h.

## ◆ asString() [4/4]

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 148 of file ByteCount.h.

## Friends And Related Symbol Documentation

## ◆ operator<<

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

relates: ByteCount Stream output

Definition at line 161 of file ByteCount.h.

## Member Data Documentation

## ◆ B

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

1 Byte

Definition at line 43 of file ByteCount.h.

## ◆ K

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

1024 Byte

Definition at line 46 of file ByteCount.h.

## ◆ KiB

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

Definition at line 47 of file ByteCount.h.

## ◆ M

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

1024^2 Byte

Definition at line 49 of file ByteCount.h.

## ◆ MiB

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

Definition at line 50 of file ByteCount.h.

## ◆ G

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

1024^3 Byte

Definition at line 52 of file ByteCount.h.

## ◆ GiB

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

Definition at line 53 of file ByteCount.h.

## ◆ T

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

1024^4 Byte

Definition at line 55 of file ByteCount.h.

## ◆ TiB

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

Definition at line 56 of file ByteCount.h.

## ◆ kB

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

1000 Byte

Definition at line 59 of file ByteCount.h.

## ◆ MB

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

1000^2 Byte

Definition at line 61 of file ByteCount.h.

## ◆ GB

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

1000^3 Byte

Definition at line 63 of file ByteCount.h.

## ◆ TB

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

1000^4 Byte

Definition at line 65 of file ByteCount.h.

## ◆ _count

SizeType zypp::ByteCount::_count
| private

Definition at line 156 of file ByteCount.h.

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

- zypp-core/ByteCount.h
- zypp-core/ByteCount.cc