Skip to content

A flexible ASCII progress-bar for C++

License

Notifications You must be signed in to change notification settings

rc83/progress-cpp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Progress-CPP

A flexible ASCII progress bar for your console based C++ projects.

Usage

Progress is a header-only library and can be used by simply including the ProgressBar.hpp header file.

The bar takes the following options at initialization

  • Limit: the total number of ticks that need to be completed
  • Width: width of the bar
  • Complete Char: the character to indicate completion (defaults to =)
  • Incomplete Char: the character to indicate pending. (defaults to ' ')
#include "ProgressBar.hpp"

int main() {

    const int limit = 10000;

    // initialize the bar
    ProgressBar progressBar(limit, 70);

    for (int i = 0; i < limit; i++) {
        // record the tick
        ++progressBar;

        // display the bar
        progressBar.display();
    }

    // tell the bar to finish
    progressBar.done();
}

The above code results in the following output

[===================>                                                 ] 29% 0.821s

Example

Refer to main.cpp file for an example usage. To run it,

$ mkdir build && cd build
$ cmake ..
$ make
$ ./ProgressBar

Or without cmake

$ g++ -O3 -I. main.cpp -Wall -std=c++11 -o ProgressBar
$ ./ProgressBar

License

MIT

About

A flexible ASCII progress-bar for C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 94.8%
  • CMake 5.2%