44 : message_(message), progress_(0), max_(max), last_message_length_(0) {
87 int hours =
static_cast<int>(elapsed) / 3600;
88 int minutes = (
static_cast<int>(elapsed) - 3600 * hours) / 60;
89 int seconds =
static_cast<int>(elapsed) % 60;
92 ss << std::setfill(
'0') << std::setw(2) << hours <<
"h:";
93 ss << std::setfill(
'0') << std::setw(2) << minutes <<
"m:";
94 ss << std::setfill(
'0') << std::setw(2) << seconds <<
"s";
100 std::stringstream progress_bar;
102 progress_bar <<
"[" << equals <<
">";
104 std::string remainder(
bar_length_ - 3 - equals.length(),
' ');
105 progress_bar << remainder <<
"]";
107 return progress_bar.str();
114 std::stringstream ss;
117 <<
"%%), remaining: " << remaining_string <<
".";
122 printf(
"%s", std::string(num_backspaces,
'\b').c_str());
124 printf(
"%s", progress_bar.c_str());
125 printf(
"%s", ss.str().c_str());
127 last_message_length_ = ss.str().length();
std::string ProgressBarString() const
size_t last_message_length_
static const size_t bar_length_
std::string PrintProgress(double elapsed)
double GetPercentage() const
double GetProgress() const
double GetRemainingSeconds()
std::string FormatRemaining(double elapsed) const
std::string Update(double progress)
ProgressBar(const std::string &message, double max)
double ElapsedToRemaining(double elapsed) const