summary refs log tree commit diff stats
path: root/generator/progress.h
diff options
context:
space:
mode:
Diffstat (limited to 'generator/progress.h')
-rw-r--r--generator/progress.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/generator/progress.h b/generator/progress.h index fcb680d..76cde48 100644 --- a/generator/progress.h +++ b/generator/progress.h
@@ -5,20 +5,20 @@
5 5
6namespace verbly { 6namespace verbly {
7 namespace generator { 7 namespace generator {
8 8
9 class progress { 9 class progress {
10 private: 10 private:
11 std::string message; 11 std::string message;
12 int total; 12 int total;
13 int cur = 0; 13 int cur = 0;
14 int lprint = 0; 14 int lprint = 0;
15 15
16 public: 16 public:
17 progress(std::string message, int total) : message(message), total(total) 17 progress(std::string message, int total) : message(message), total(total)
18 { 18 {
19 std::cout << message << " 0%" << std::flush; 19 std::cout << message << " 0%" << std::flush;
20 } 20 }
21 21
22 void update(int val) 22 void update(int val)
23 { 23 {
24 if (val <= total) 24 if (val <= total)
@@ -27,29 +27,29 @@ namespace verbly {
27 } else { 27 } else {
28 cur = total; 28 cur = total;
29 } 29 }
30 30
31 int pp = cur * 100 / total; 31 int pp = cur * 100 / total;
32 if (pp != lprint) 32 if (pp != lprint)
33 { 33 {
34 lprint = pp; 34 lprint = pp;
35 35
36 std::cout << "\b\b\b\b" << std::right; 36 std::cout << "\b\b\b\b" << std::right;
37 std::cout.width(3); 37 std::cout.width(3);
38 std::cout << pp << "%" << std::flush; 38 std::cout << pp << "%" << std::flush;
39 } 39 }
40 } 40 }
41 41
42 void update() 42 void update()
43 { 43 {
44 update(cur+1); 44 update(cur+1);
45 } 45 }
46 46
47 ~progress() 47 ~progress()
48 { 48 {
49 std::cout << "\b\b\b\b100%" << std::endl; 49 std::cout << "\b\b\b\b100%" << std::endl;
50 } 50 }
51 }; 51 };
52 52
53 }; 53 };
54}; 54};
55 55