libzypp: zypp::base::Unit Class Reference

libzypp 17.36.6

Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
zypp::base::Unit Class Reference

Simple handling of Units. More...

`#include <zypp-core/base/Unit.h>`

## Public Types
using | ValueType = long long

## Public Member Functions
| Unit ()
| Default ctor.
| Unit (ValueType factor_r, std::string symbol_r, unsigned prec_r)
| ctor
ValueType | factor () const
const std::string & | symbol () const
unsigned | prec () const
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 | form (ValueType val_r, unsigned field_width_r, unsigned unit_width_r, unsigned prec_r) const

## Static Public Member Functions
static std::string | form (double val_r, const std::string &symbol_r, unsigned field_width_r, unsigned unit_width_r, unsigned prec_r)

## Private Attributes
ValueType | _factor
std::string | _symbol
unsigned | _prec

## Detailed Description

Simple handling of Units.

Unit stores factor and symbol, and a precision value for printing. form builds a string from a value according to the format specification.

static const Unit B( 1, "B", 0 );
static const Unit K( 1024, "K", 1 );
static const Unit M( 1048576, "M", 1 );
static const Unit G( 1073741824, "G", 2 );
static const Unit T( 1099511627776, "T", 3 );
zypp::base::Unit::Unit
Unit()
Default ctor.
Definition Unit.h:51

Definition at line 45 of file Unit.h.

## Member Typedef Documentation

## ◆ ValueType

using zypp::base::Unit::ValueType = long long

Definition at line 48 of file Unit.h.

## Constructor & Destructor Documentation

## ◆ Unit() [1/2]

zypp::base::Unit::Unit | ( |  | ) |
| inline

Default ctor.

Definition at line 51 of file Unit.h.

## ◆ Unit() [2/2]

zypp::base::Unit::Unit | ( | ValueType | factor_r,
|  | std::string | symbol_r,
|  | unsigned | prec_r )
| inline

ctor

Definition at line 57 of file Unit.h.

## Member Function Documentation

## ◆ factor()

ValueType zypp::base::Unit::factor | ( |  | ) | const
| inline

Definition at line 63 of file Unit.h.

## ◆ symbol()

const std::string & zypp::base::Unit::symbol | ( |  | ) | const
| inline

Definition at line 66 of file Unit.h.

## ◆ prec()

unsigned zypp::base::Unit::prec | ( |  | ) | const
| inline

Definition at line 69 of file Unit.h.

## ◆ form() [1/3]

std::string zypp::base::Unit::form | ( | ValueType | val_r,
|  | unsigned | field_width_r = 0,
|  | unsigned | unit_width_r = 1 ) const
| inline

Build string representation of val_r.

Definition at line 73 of file Unit.h.

## ◆ form() [2/3]

std::string zypp::base::Unit::form | ( | ValueType | val_r,
|  | unsigned | field_width_r,
|  | unsigned | unit_width_r,
|  | unsigned | prec_r ) const
| inline

Definition at line 78 of file Unit.h.

## ◆ form() [3/3]

std::string zypp::base::Unit::form | ( | double | val_r,
|  | const std::string & | symbol_r,
|  | unsigned | field_width_r,
|  | unsigned | unit_width_r,
|  | unsigned | prec_r )
| static

Definition at line 23 of file Unit.cc.

## Member Data Documentation

## ◆ _factor

ValueType zypp::base::Unit::_factor
| private

Definition at line 93 of file Unit.h.

## ◆ _symbol

std::string zypp::base::Unit::_symbol
| private

Definition at line 94 of file Unit.h.

## ◆ _prec

unsigned zypp::base::Unit::_prec
| private

Definition at line 95 of file Unit.h.

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

- zypp-core/base/Unit.h
- zypp-core/base/Unit.cc