added md
This commit is contained in:
parent
3c393c42bb
commit
44a3cb1621
3 changed files with 41 additions and 3 deletions
26
logging/README.md.txt
Normal file
26
logging/README.md.txt
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
Usage:
|
||||||
|
======
|
||||||
|
|
||||||
|
Wrap your for loop in an extra scope with a progressbar, like this:
|
||||||
|
|
||||||
|
{ // extra scope
|
||||||
|
Progressbar p(std::cout);
|
||||||
|
for(i = 0; i < 1000; ++i){
|
||||||
|
...
|
||||||
|
p.show(i, 999);
|
||||||
|
}
|
||||||
|
} // end extra scope (destructor of Progressbar will be used).
|
||||||
|
|
||||||
|
You can give extra information to show in the constructor:
|
||||||
|
`Progressbar p(stream, "prefix", "Start message", " End message");`
|
||||||
|
this will look like:
|
||||||
|
|
||||||
|
Start message
|
||||||
|
prefix [===============> ]
|
||||||
|
End message
|
||||||
|
|
||||||
|
You may leave these things empty (`""`).
|
||||||
|
|
||||||
|
NOTE: the width of the bar (incl. prefix) is fixed ATM.
|
||||||
|
NOTE: pass the maximum-value to the function show, not the bound of the for-loop (this way the function also works nicely for floating types)
|
||||||
|
|
12
logging/main.cpp
Normal file
12
logging/main.cpp
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "Progressbar.hpp"
|
||||||
|
|
||||||
|
int main () {
|
||||||
|
// lame example
|
||||||
|
progressbar p(std::cout, "doing magic");
|
||||||
|
for (int i = 0; i < 1000; ++i) {
|
||||||
|
p.show(i, 999);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ struct progressbar {
|
||||||
, end(end)
|
, end(end)
|
||||||
{
|
{
|
||||||
if (begin != "") {
|
if (begin != "") {
|
||||||
out << begin << "\n";
|
out << begin << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
show(0, 1, ' ');
|
show(0, 1, ' ');
|
||||||
|
@ -54,9 +54,9 @@ struct progressbar {
|
||||||
show(1, 1, '=');
|
show(1, 1, '=');
|
||||||
|
|
||||||
if (end != "") {
|
if (end != "") {
|
||||||
out << "\n" << end << "\n";
|
out << "\n" << end << std::endl;
|
||||||
} else {
|
} else {
|
||||||
out << "\n";
|
out << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue