libzed 1.9.9
A general-purpose library for quick and simple data manipulation.
 
Loading...
Searching...
No Matches
z::util::progress Class Reference

A class for outputting a progress bar to the terminal. More...

#include <progress.hpp>

Public Member Functions

 progress (unsigned int update_freq_micros=100000) noexcept
 Constructor.
 
void set (std::ostream &stream, long item, long max, const zstring &message="", bool force=false) noexcept
 Update the progress bar.
 
void done (std::ostream &stream) noexcept
 Mark the progress bar as finished.
 

Detailed Description

A class for outputting a progress bar to the terminal.

This class allows for easy progress bar displaying, and automatically limits the frequency of stream writes for performance.

Examples
range.cpp.

Constructor & Destructor Documentation

◆ progress()

z::util::progress::progress ( unsigned int  update_freq_micros = 100000)
noexcept

Constructor.

Parameters
update_freq_microsThe shortest time frame between stream writes. The stream will not update more frequently than this.

Member Function Documentation

◆ done()

void z::util::progress::done ( std::ostream &  stream)
noexcept

Mark the progress bar as finished.

If the progress bar has displayed any info, then this method appends a newline to the stream. If no info has been displayed, this method does nothing.

Parameters
streamThe stream to write to.

◆ set()

void z::util::progress::set ( std::ostream &  stream,
long  item,
long  max,
const zstring message = "",
bool  force = false 
)
noexcept

Update the progress bar.

Parameters
streamThe stream to write to.
itemThe current item. Assumed to be in the range 0 to max-1, inclusive.
maxThe total number of items. This will be 1 more than item can ever be.
messageAn optional message to display in front of the percent.
forceIf true, ignore frequency limit and force the stream to be updated.
Examples
range.cpp.

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