forked from kitanokitsune/ProgressBar.hpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.cpp
70 lines (60 loc) · 1.75 KB
/
example.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "../ProgressBar.hpp"
#include "millisleep.h"
#include <cstdio>
#define MSEC 14
int main(void) {
unsigned long i;
unsigned long total = 123L;
std::printf("\n* Progressbar examples *\n\n");
/* (1) default style */
ProgressBar pbar(total, "[DEFAULT]: ");
pbar.start(); /* pbar.start() resets internal counter and disables a cursor */
for (i=0; i<total; ++i) {
millisleep(MSEC);
pbar.update();
}
/* (2) change ratio style */
pbar.set_title("[CHANGE RATIO STYLE]: ");
pbar.use_ratiostyle();
pbar.start();
for (i=0; i<total; ++i) {
millisleep(MSEC);
pbar++; /* pbar++ and ++pbar are equivalent to pbar.update() */
}
/* (3) change bracket style */
pbar.set_title("[CHANGE BRACKET STYLE]: ");
pbar.use_percentstyle();
pbar.set_bracketstyle('<', '>');
pbar.start();
for (i=0; i<total; ++i) {
millisleep(MSEC);
++pbar;
}
/* (4) change bar style 1 */
pbar.set_title("[CHANGE BAR STYLE 1]: ");
pbar.set_bracketstyle(); /* reset bracket style */
pbar.set_barstyle('-', '>', ' ');
pbar.start();
for (i=0; i<total; ++i) {
millisleep(MSEC);
pbar.update();
}
/* (5) change bar style 2 */
pbar.set_title("[CHANGE BAR STYLE 2]: ");
pbar.set_bracketstyle(); /* reset bracket style */
pbar.set_barstyle('#', ' ', ' ');
pbar.start();
for (i=0; i<total; ++i) {
millisleep(MSEC);
pbar.update();
}
/* (6) tricky example: growing bar */
pbar.set_title("[TRICKY EXAMPLE]: ");
pbar.set_barstyle('=', '>', '\0'); /* NOTE: the 3rd argument is NUL. */
pbar.start();
for (i=0; i<total; ++i) {
millisleep(MSEC);
pbar.update();
}
return 0;
}