Joedb 9.5.0
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 if (out)
19 {
20 if (total > threshold)
21 *out << '\n' << std::string(length, '.') << '\r';
22 else
23 *out << ": size = " << total << '\n';
24
25 out->flush();
26 }
27 }
28
29 //////////////////////////////////////////////////////////////////////////
30 void Progress_Bar::print(int64_t current)
31 //////////////////////////////////////////////////////////////////////////
32 {
33 if (out && total > threshold)
34 {
35 const int display = int((current * length) / total);
36
37 if (display > current_display)
38 {
39 *out << std::string(display - current_display, '#');
40 out->flush();
41
42 current_display = display;
43 }
44 }
45 }
46
47 //////////////////////////////////////////////////////////////////////////
49 //////////////////////////////////////////////////////////////////////////
50 {
51 try
52 {
53 if (out)
54 {
55 if (total > threshold)
56 *out << '\n';
57 out->flush();
58 }
59 }
60 catch(...)
61 {
62 }
63 }
64}
void print(int64_t current)
Progress_Bar(int64_t total, std::ostream *out)
Definition Blob.h:7