24 #ifndef _TPIE_PROGRESS_INDICATOR_ARROW_H
25 #define _TPIE_PROGRESS_INDICATOR_ARROW_H
70 void push_breadcrumb(
const char * crumb, description_importance ) {
71 m_crumbs.push_back(crumb);
74 void pop_breadcrumb() {
86 memory_size_type progress = (
m_range != 0) ?
89 std::string newStatus;
91 std::stringstream status;
94 if (progress >= l) progress = l -1;
101 status << std::string(progress,
'=');
104 // Print blank space.
105 status << std::string(l-progress-1, ' ');
108 status << m_current * 100 / m_range << '%
';
110 for (std::deque<std::string>::iterator i = m_crumbs.begin(); i != m_crumbs.end(); ++i) {
111 if (i == m_crumbs.begin()) status << ' ';
112 else status << " > ";
116 status << ' ' << estimated_remaining_time();
118 newStatus = status.str();
121 if (newStatus != m_status) {
123 m_os << '\r
' << std::string(m_status.size(), ' ') << '\r
'
124 << newStatus << std::flush;
126 m_os << "\r\x1B[K" << newStatus << std::flush;
128 std::swap(newStatus, m_status);
135 memory_size_type m_indicatorLength;
138 std::string m_status;
143 std::deque<std::string> m_crumbs;
147 progress_indicator_arrow();
152 #endif // _TPIE_PROGRESS_INDICATOR_ARROW
A class that indicates the progress by expanding an arrow.
stream_size_type m_current
The current progress count [m_minRange...m_maxRange].
memory_size_type m_indicatorLength
The maximal length of the indicator.
stream_size_type m_range
The upper bound of the counting range.
A class that indicates the progress by a simple counter that is printed to the terminal.
void set_indicator_length(int indicatorLength)
Set the maximum length of the indicator.
std::ostream & m_os
ostream on which to display the progress indicator
progress_indicator_arrow(const char *title, stream_size_type range, std::ostream &os=std::cout)
Initializes the indicator.
virtual void refresh()
Display the indicator.
Indicate progress by a simple counter.
std::string m_title
A string holding the description of the title.
virtual void reset()
Reset the current state of the indicator and its current length.