diff options
Diffstat (limited to 'generator/progress.h')
-rw-r--r-- | generator/progress.h | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/generator/progress.h b/generator/progress.h deleted file mode 100644 index e5cc13d..0000000 --- a/generator/progress.h +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | #ifndef PROGRESS_H_A34EF856 | ||
2 | #define PROGRESS_H_A34EF856 | ||
3 | |||
4 | #include <string> | ||
5 | |||
6 | namespace cadence { | ||
7 | namespace generator { | ||
8 | |||
9 | class progress { | ||
10 | private: | ||
11 | std::string message; | ||
12 | int total; | ||
13 | int cur = 0; | ||
14 | int lprint = 0; | ||
15 | |||
16 | public: | ||
17 | progress(std::string message, int total) : message(message), total(total) | ||
18 | { | ||
19 | std::cout << message << " 0%" << std::flush; | ||
20 | } | ||
21 | |||
22 | void update(int val) | ||
23 | { | ||
24 | if (val <= total) | ||
25 | { | ||
26 | cur = val; | ||
27 | } else { | ||
28 | cur = total; | ||
29 | } | ||
30 | |||
31 | int pp = cur * 100 / total; | ||
32 | if (pp != lprint) | ||
33 | { | ||
34 | lprint = pp; | ||
35 | |||
36 | std::cout << "\b\b\b\b" << std::right; | ||
37 | std::cout.width(3); | ||
38 | std::cout << pp << "%" << std::flush; | ||
39 | } | ||
40 | } | ||
41 | |||
42 | void update() | ||
43 | { | ||
44 | update(cur+1); | ||
45 | } | ||
46 | |||
47 | ~progress() | ||
48 | { | ||
49 | std::cout << "\b\b\b\b100%" << std::endl; | ||
50 | } | ||
51 | }; | ||
52 | |||
53 | }; | ||
54 | }; | ||
55 | |||
56 | #endif /* end of include guard: PROGRESS_H_A34EF856 */ | ||