-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move progressbar to shared lib
- Loading branch information
Showing
4 changed files
with
45 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// progress_bar.h | ||
|
||
#ifndef PROGRESS_BAR_H | ||
#define PROGRESS_BAR_H | ||
|
||
#include <iostream> | ||
|
||
// Function to display a simple progress bar | ||
void displayProgressBar(size_t current, size_t total); | ||
|
||
#endif // PROGRESS_BAR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "progress_bar.h" | ||
|
||
void displayProgressBar(size_t current, size_t total) { | ||
const int barWidth = 50; // Width of the progress bar | ||
float progress = static_cast<float>(current) / total; | ||
int pos = static_cast<int>(barWidth * progress); | ||
|
||
std::cout << "["; | ||
for (int i = 0; i < barWidth; ++i) { | ||
if (i < pos) | ||
std::cout << "="; | ||
else if (i == pos) | ||
std::cout << ">"; | ||
else | ||
std::cout << " "; | ||
} | ||
std::cout << "] " << int(progress * 100.0) << "%\r"; | ||
std::cout.flush(); | ||
} |