1 #ifndef OSMIUM_UTIL_PROGRESS_BAR_HPP 2 #define OSMIUM_UTIL_PROGRESS_BAR_HPP 47 static const char*
bar() noexcept {
48 return "======================================================================";
51 static const char*
spc() noexcept {
55 static constexpr
const std::size_t
length = 70;
81 const std::size_t percent = 100 * (m_done_size +
m_current_size) / m_max_size;
82 if (m_prev_percent == percent) {
85 m_prev_percent = percent;
87 const auto num =
static_cast<std::size_t
>(percent * (length / 100.0));
92 std::cerr << (
bar() + length - num) <<
'>' << (
spc() + num);
101 std::cerr << percent <<
"% \r";
142 m_current_size = current_size;
167 m_do_cleanup =
false;
183 std::cerr <<
spc() <<
" \r";
184 m_prev_percent = 100 + 1;
192 #endif // OSMIUM_UTIL_PROGRESS_BAR_HPP ProgressBar(std::size_t max_size, bool enable) noexcept
Definition: progress_bar.hpp:113
std::size_t file_size(int fd)
Definition: file.hpp:109
void update(std::size_t current_size)
Definition: progress_bar.hpp:137
void done()
Definition: progress_bar.hpp:166
std::size_t m_max_size
Definition: progress_bar.hpp:60
std::size_t m_done_size
Definition: progress_bar.hpp:63
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53
~ProgressBar()
Definition: progress_bar.hpp:118
bool m_enable
Definition: progress_bar.hpp:74
Definition: progress_bar.hpp:45
static constexpr const std::size_t length
Definition: progress_bar.hpp:55
void file_done(std::size_t file_size)
Definition: progress_bar.hpp:153
static const char * spc() noexcept
Definition: progress_bar.hpp:51
static const char * bar() noexcept
Definition: progress_bar.hpp:47
bool m_do_cleanup
Definition: progress_bar.hpp:78
std::size_t m_prev_percent
Definition: progress_bar.hpp:71
void display()
Definition: progress_bar.hpp:80
std::size_t m_current_size
Definition: progress_bar.hpp:66