libzypp: ztui::Out::ProgressBar Class Reference

libzypp 17.38.14

ztui::Out::ProgressBar Class Reference

Convenience class for progress output. More...

`#include <zypp-tui/output/Out.h>`

Inheritance diagram for ztui::Out::ProgressBar:

## Classes
struct | NoStartBar
| Indicator type for ctor not drawing an initial start bar. More...
struct | Print
| ProgressData::ReceiverFnc printing to a ProgressBar. More...

## Public Member Functions
| ProgressBar (Out &out_r, NoStartBar, std::string progressId_r, const std::string &label_r, unsigned current_r=0, unsigned total_r=0)
| Ctor not displaying an initial progress bar.
| ProgressBar (Out &out_r, NoStartBar, const std::string &label_r, unsigned current_r=0, unsigned total_r=0)
| ProgressBar (Out &out_r, const std::string &progressId_r, const std::string &label_r, unsigned current_r=0, unsigned total_r=0)
| Ctor displays initial progress bar.
| ProgressBar (Out &out_r, const std::string &label_r, unsigned current_r=0, unsigned total_r=0)
| ~ProgressBar ()
| Dtor displays final progress bar.
void | print ()
| Immediately print the progress bar not waiting for a new trigger.
void | print (const std::string &label_r)
void | error (ProgressEnd donetag_r=ProgressEnd::error)
| Explicitly indicate the error condition for the final progress bar.
void | error (bool error_r)
void | errorreset ()
| Reset any error condition.
void | error (const std::string &label_r)
void | error (const char *label_r)

## Static Public Attributes
static constexpr NoStartBar | noStartBar = NoStartBar()
| Indicator argument for ctor not drawing an initial start bar.

## Access the embedded ProgressData object
Out & | _out
std::optional< ProgressEnd > | _donetag
zypp::ProgressData | _progress
std::string | _progressId
std::string | _labelPrefix
zypp::ProgressData * | operator-> ()
const zypp::ProgressData * | operator-> () const
zypp::ProgressData & | operator* ()
const zypp::ProgressData & | operator* () const
std::string | outLabel (const std::string &msg_r) const
int | numDigits (unsigned num_r) const

## Detailed Description

Convenience class for progress output.

Progress start and end messages are provided upon object construction and deletion. Progress data are sent through a ProgressData object accessible via operator->.

{
Out::ProgressBar report( _zypper.out(), "Prepare action" );
for ( unsigned i = 0; i < 10; ++ i )
{
report->tick(); // turn wheel
sleep(1);
}
report->range( 10 ); // switch to percent mode [0,10]
report.print( "Running action" );
for ( unsigned i = 0; i < 10; ++ i )
{
report->
report->set( i ); // send 0%, 10%, ...
sleep(1);
}
// report.error( "Action failed" );
}
ztui::Out::ProgressBar
Convenience class for progress output.
Definition Out.h:983

If non zero values for current_r or total_r are passed to the ctor, the label is prefixed by either "(#C)" or "(#C/#T)"

Todo
  ProgressData provides NumericId which might be used as id for_out.progress*().

Definition at line 982 of file Out.h.

## Constructor & Destructor Documentation

## ◆ ProgressBar() [1/4]

ztui::Out::ProgressBar::ProgressBar | ( | Out & | out_r,
|  | NoStartBar | ,
|  | std::string | progressId_r,
|  | const std::string & | label_r,
|  | unsigned | current_r = 0,
|  | unsigned | total_r = 0 )
| inline

Ctor not displaying an initial progress bar.

If non zero values for current_r or total_r are passed, the label is prefixed by either "(#C)" or "(#C/#T)"

Definition at line 995 of file Out.h.

## ◆ ProgressBar() [2/4]

ztui::Out::ProgressBar::ProgressBar | ( | Out & | out_r,
|  | NoStartBar | ,
|  | const std::string & | label_r,
|  | unsigned | current_r = 0,
|  | unsigned | total_r = 0 )
| inline

Definition at line 1007 of file Out.h.

## ◆ ProgressBar() [3/4]

ztui::Out::ProgressBar::ProgressBar | ( | Out & | out_r,
|  | const std::string & | progressId_r,
|  | const std::string & | label_r,
|  | unsigned | current_r = 0,
|  | unsigned | total_r = 0 )
| inline

Ctor displays initial progress bar.

If non zero values for current_r or total_r are passed, the label is prefixed by either "(#C)" or "(#C/#T)"

Definition at line 1015 of file Out.h.

## ◆ ProgressBar() [4/4]

ztui::Out::ProgressBar::ProgressBar | ( | Out & | out_r,
|  | const std::string & | label_r,
|  | unsigned | current_r = 0,
|  | unsigned | total_r = 0 )
| inline

Definition at line 1022 of file Out.h.

## ◆ ~ProgressBar()

ztui::Out::ProgressBar::~ProgressBar | ( |  | ) |
| inline

Dtor displays final progress bar.

Unless error has explicitly been set, an error is indicated if a ProgressData range has been set, but 100% were not reached.

Definition at line 1030 of file Out.h.

## Member Function Documentation

## ◆ print() [1/2]

void ztui::Out::ProgressBar::print | ( |  | ) |
| inline

Immediately print the progress bar not waiting for a new trigger.

Definition at line 1039 of file Out.h.

## ◆ print() [2/2]

void ztui::Out::ProgressBar::print | ( | const std::string & | label_r | ) |
| inline

Definition at line 1043 of file Out.h.

## ◆ error() [1/4]

void ztui::Out::ProgressBar::error | ( | ProgressEnd | donetag_r = ProgressEnd::error | ) |
| inline

Explicitly indicate the error condition for the final progress bar.

Definition at line 1047 of file Out.h.

## ◆ error() [2/4]

void ztui::Out::ProgressBar::error | ( | bool | error_r | ) |
| inline

Definition at line 1051 of file Out.h.

## ◆ errorreset()

void ztui::Out::ProgressBar::errorreset | ( |  | ) |
| inline

Reset any error condition.

Definition at line 1055 of file Out.h.

## ◆ error() [3/4]

void ztui::Out::ProgressBar::error | ( | const std::string & | label_r | ) |
| inline

Definition at line 1059 of file Out.h.

## ◆ error() [4/4]

void ztui::Out::ProgressBar::error | ( | const char * | label_r | ) |
| inline

Definition at line 1063 of file Out.h.

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

zypp::ProgressData * ztui::Out::ProgressBar::operator-> | ( |  | ) |
| inline

Definition at line 1069 of file Out.h.

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

const zypp::ProgressData * ztui::Out::ProgressBar::operator-> | ( |  | ) | const
| inline

Definition at line 1072 of file Out.h.

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

zypp::ProgressData & ztui::Out::ProgressBar::operator* | ( |  | ) |
| inline

Definition at line 1075 of file Out.h.

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

const zypp::ProgressData & ztui::Out::ProgressBar::operator* | ( |  | ) | const
| inline

Definition at line 1078 of file Out.h.

## ◆ outLabel()

std::string ztui::Out::ProgressBar::outLabel | ( | const std::string & | msg_r | ) | const
| inlineprivate

Definition at line 1098 of file Out.h.

## ◆ numDigits()

int ztui::Out::ProgressBar::numDigits | ( | unsigned | num_r | ) | const
| inlineprivate

Definition at line 1101 of file Out.h.

## Member Data Documentation

## ◆ noStartBar

NoStartBar ztui::Out::ProgressBar::noStartBar = NoStartBar()
| staticconstexpr

Indicator argument for ctor not drawing an initial start bar.

Definition at line 988 of file Out.h.

## ◆ _out

Out& ztui::Out::ProgressBar::_out
| private

Definition at line 1105 of file Out.h.

## ◆ _donetag

std::optional<ProgressEnd> ztui::Out::ProgressBar::_donetag
| private

Definition at line 1106 of file Out.h.

## ◆ _progress

zypp::ProgressData ztui::Out::ProgressBar::_progress
| private

Definition at line 1107 of file Out.h.

## ◆ _progressId

std::string ztui::Out::ProgressBar::_progressId
| private

Definition at line 1108 of file Out.h.

## ◆ _labelPrefix

std::string ztui::Out::ProgressBar::_labelPrefix
| private

Definition at line 1109 of file Out.h.

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

- zypp-tui/output/Out.h