Joedb 9.1.4
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Progress_Bar.cpp
Go to the documentation of this file.
2
3#include <iostream>
4
5namespace joedb
6{
7 //////////////////////////////////////////////////////////////////////////
9 //////////////////////////////////////////////////////////////////////////
10 (
11 int64_t total,
12 std::ostream &out
13 ):
14 total(total),
15 out(out),
16 current_display(0)
17 {
18 out << '\n';
19 for (int i = length; --i >= 0;)
20 out << '.';
21 out << '\r';
22 out.flush();
23 }
24
25 //////////////////////////////////////////////////////////////////////////
26 void Progress_Bar::print(int64_t current)
27 //////////////////////////////////////////////////////////////////////////
28 {
29 const int display = int((current * length) / total);
30
31 if (display > current_display)
32 {
33 for (int i = display - current_display; --i >= 0;)
34 out << '#';
35 out.flush();
36
37 current_display = display;
38 }
39 }
40
41 //////////////////////////////////////////////////////////////////////////
43 //////////////////////////////////////////////////////////////////////////
44 {
45 try
46 {
47 out << '\n';
48 out.flush();
49 }
50 catch(...)
51 {
52 }
53 }
54}
void print(int64_t current)
Progress_Bar(int64_t total, std::ostream &out)
Definition Blob.h:7