1 #ifndef OSMIUM_UTIL_PROGRESS_BAR_HPP
2 #define OSMIUM_UTIL_PROGRESS_BAR_HPP
46 static const char*
bar() noexcept {
47 return "======================================================================";
50 static const char*
spc() noexcept {
54 static constexpr
const size_t length = 70;
80 const size_t percent = 100 * (m_done_size +
m_current_size) / m_max_size;
81 if (m_prev_percent == percent) {
84 m_prev_percent = percent;
86 const size_t num = size_t(percent * (length / 100.0));
91 std::cerr << (
bar() + length - num) <<
'>' << (
spc() + num);
100 std::cerr << percent <<
"% \r";
141 m_current_size = current_size;
166 m_do_cleanup =
false;
179 #endif // OSMIUM_UTIL_PROGRESS_BAR_HPP
size_t file_size(int fd)
Definition: file.hpp:67
size_t m_prev_percent
Definition: progress_bar.hpp:70
void update(size_t current_size)
Definition: progress_bar.hpp:136
void done()
Definition: progress_bar.hpp:165
size_t m_max_size
Definition: progress_bar.hpp:59
Namespace for everything in the Osmium library.
Definition: assembler.hpp:73
~ProgressBar()
Definition: progress_bar.hpp:117
bool m_enable
Definition: progress_bar.hpp:73
size_t m_current_size
Definition: progress_bar.hpp:65
ProgressBar(size_t max_size, bool enable) noexcept
Definition: progress_bar.hpp:112
Definition: progress_bar.hpp:44
static const char * spc() noexcept
Definition: progress_bar.hpp:50
static const char * bar() noexcept
Definition: progress_bar.hpp:46
static constexpr const size_t length
Definition: progress_bar.hpp:54
size_t m_done_size
Definition: progress_bar.hpp:62
bool m_do_cleanup
Definition: progress_bar.hpp:77
void display()
Definition: progress_bar.hpp:79
void file_done(size_t file_size)
Definition: progress_bar.hpp:152