Joedb
9.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
src
joedb
ui
Progress_Bar.cpp
Go to the documentation of this file.
1
#include "
joedb/ui/Progress_Bar.h
"
2
3
#include <iostream>
4
5
namespace
joedb
6
{
7
//////////////////////////////////////////////////////////////////////////
8
Progress_Bar::Progress_Bar
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
//////////////////////////////////////////////////////////////////////////
48
Progress_Bar::~Progress_Bar
()
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
}
Progress_Bar.h
joedb::Progress_Bar::print
void print(int64_t current)
Definition
Progress_Bar.cpp:30
joedb::Progress_Bar::Progress_Bar
Progress_Bar(int64_t total, std::ostream *out)
Definition
Progress_Bar.cpp:10
joedb::Progress_Bar::~Progress_Bar
~Progress_Bar()
Definition
Progress_Bar.cpp:48
joedb
Definition
Blob.h:7
Generated by
1.9.8