1 #ifndef OSMIUM_UTIL_PROGRESS_BAR_HPP 2 #define OSMIUM_UTIL_PROGRESS_BAR_HPP 52 return "======================================================================" 92 const auto num =
static_cast<std::size_t
>(percent * (
full_length / 100.0));
97 std::cerr << bar(num) << '>
' << spc(full_length - num); 106 std::cerr << percent << "% \r"; 118 ProgressBar(std::size_t max_size, bool enable) noexcept : 119 m_max_size(max_size), 120 m_enable(max_size > 0 && enable) { 123 ProgressBar(const ProgressBar&) = delete; 124 ProgressBar& operator=(const ProgressBar&) = delete; 126 ProgressBar(ProgressBar&&) noexcept = default; 127 ProgressBar& operator=(ProgressBar&&) = default; 134 // Swallow any exceptions, because a destructor should 148 void update(std::size_t current_size) { 153 m_current_size = current_size; 164 void file_done(std::size_t file_size) { 166 m_done_size += file_size; 178 m_do_cleanup = false; 180 m_done_size = m_max_size; 194 std::cerr << spc() << " \r"; 195 m_prev_percent = 100 + 1; 199 }; // class ProgressBar 201 } // namespace osmium 203 #endif // OSMIUM_UTIL_PROGRESS_BAR_HPP static const char * spc(std::size_t len=full_length) noexcept
Definition: progress_bar.hpp:56
static const char * bar(std::size_t len=full_length) noexcept
Definition: progress_bar.hpp:50
std::size_t m_max_size
Definition: progress_bar.hpp:65
std::size_t m_done_size
Definition: progress_bar.hpp:68
static constexpr const std::size_t full_length
Definition: progress_bar.hpp:48
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53
bool m_enable
Definition: progress_bar.hpp:79
Definition: progress_bar.hpp:46
bool m_do_cleanup
Definition: progress_bar.hpp:83
std::size_t m_prev_percent
Definition: progress_bar.hpp:76
void display()
Definition: progress_bar.hpp:85
std::size_t m_current_size
Definition: progress_bar.hpp:71