A class for outputting a progress bar to the terminal.
More...
#include <progress.hpp>
|
| 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.
|
|
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.
◆ progress()
z::util::progress::progress |
( |
unsigned int |
update_freq_micros = 100000 | ) |
|
|
noexcept |
Constructor.
- Parameters
-
update_freq_micros | The shortest time frame between stream writes. The stream will not update more frequently than this. |
◆ 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
-
stream | The 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
-
stream | The stream to write to. |
item | The current item. Assumed to be in the range 0 to max-1 , inclusive. |
max | The total number of items. This will be 1 more than item can ever be. |
message | An optional message to display in front of the percent. |
force | If 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: