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