Loading...
Searching...
No Matches
osmium::ProgressBar Class Reference

`#include <progress_bar.hpp>`

## Public Member Functions

| ProgressBar (std::size_t max_size, bool enable) noexcept
| ProgressBar (const ProgressBar &)=delete
ProgressBar & | operator= (const ProgressBar &)=delete
| ProgressBar (ProgressBar &&) noexcept=default
ProgressBar & | operator= (ProgressBar &&)=default
| ~ProgressBar ()
void | update (std::size_t current_size)
void | file_done (std::size_t file_size)
void | done ()
void | remove ()

## Private Types

enum | { full_length = 70 }

## Private Member Functions

void | display ()

## Static Private Member Functions

static const char * | bar (std::size_t len=full_length) noexcept
static const char * | spc (std::size_t len=full_length) noexcept

## Private Attributes

std::size_t | m_max_size
std::size_t | m_done_size = 0
std::size_t | m_current_size = 0
std::size_t | m_prev_percent = 100 + 1
bool | m_enable
bool | m_do_cleanup = true

## Detailed Description

Displays a progress bar on STDERR. Can be used together with the osmium::io::Reader class for instance.

## Member Enumeration Documentation

## anonymous enum

anonymous enum

private

Enumerator
full_length |

## Constructor & Destructor Documentation

## ProgressBar() [1/3]

osmium::ProgressBar::ProgressBar | ( | std::size_t | max_size,
|  | bool | enable )

inlinenoexcept

Initializes the progress bar. No output yet.

Parameters

  max_size | Max size equivalent to 100%.
  enable | Set to false to disable (for instance if stderr is not a TTY).

## ProgressBar() [2/3]

osmium::ProgressBar::ProgressBar | ( | const ProgressBar & |  | ) |

delete

## ProgressBar() [3/3]

osmium::ProgressBar::ProgressBar | ( | ProgressBar && |  | ) |

defaultnoexcept

## ~ProgressBar()

osmium::ProgressBar::~ProgressBar | ( |  | ) |

inline

## Member Function Documentation

## bar()

const char * osmium::ProgressBar::bar | ( | std::size_t | len = full_length | ) |

inlinestaticprivatenoexcept

## display()

void osmium::ProgressBar::display | ( |  | ) |

inlineprivate

## done()

void osmium::ProgressBar::done | ( |  | ) |

inline

Call this at the end. Will update the progress bar to 100% and print a final line feed. If this is not called explicitly the destructor will also call this.

## file_done()

void osmium::ProgressBar::file_done | ( | std::size_t | file_size | ) |

inline

If you are reading multiple files, call this function after each file is finished.

Parameters

  file_size | The size of the file just finished.

## operator=() [1/2]

ProgressBar & osmium::ProgressBar::operator= | ( | const ProgressBar & |  | ) |

delete

## operator=() [2/2]

ProgressBar & osmium::ProgressBar::operator= | ( | ProgressBar && |  | ) |

default

## remove()

void osmium::ProgressBar::remove | ( |  | ) |

inline

Removes the progress bar. Call this before doing any other output. The next time update() is called, the progress bar will be visible again.

## spc()

const char * osmium::ProgressBar::spc | ( | std::size_t | len = full_length | ) |

inlinestaticprivatenoexcept

## update()

void osmium::ProgressBar::update | ( | std::size_t | current_size | ) |

inline

Call this function to update the progress bar. Actual update will only happen if the percentage changed from the last time this function was called.

Parameters

  current_size | Current size. Used together with the max_size from constructor to calculate the percentage.

## Member Data Documentation

## m_current_size

std::size_t osmium::ProgressBar::m_current_size = 0

private

## m_do_cleanup

bool osmium::ProgressBar::m_do_cleanup = true

private

## m_done_size

std::size_t osmium::ProgressBar::m_done_size = 0

private

## m_enable

bool osmium::ProgressBar::m_enable

private

## m_max_size

std::size_t osmium::ProgressBar::m_max_size

private

## m_prev_percent

std::size_t osmium::ProgressBar::m_prev_percent = 100 + 1

private

The documentation for this class was generated from the following file:

- include/osmium/util/progress_bar.hpp