Skip to content

Commit 005f388

Browse files
ProgressBar: the percent-percent as replacement for backslash percent was clearly not right. Now just one percent, and in a c++ string it won't have the problems the percent sign had when used in a possible template string in C
1 parent 2b2f64c commit 005f388

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

smithlab_utils.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,11 @@ kmer_counts(const std::vector<std::string> &seqs,
397397
* How to use the ProgressBar:
398398
*
399399
* //====================================
400-
* const size_t lim = v.size();
400+
* const uint64_t lim = v.size();
401401
* ProgressBar progress(lim);
402402
* if (VERBOSE)
403403
* progress.report(cerr, 0);
404-
* for (size_t i = 0; i < lim; ++i) {
404+
* for (uint64_t i = 0; i < lim; ++i) {
405405
* if (VERBOSE && progress.time_to_report(i))
406406
* progress.report(cerr, i);
407407
* v[i] += x;
@@ -413,6 +413,9 @@ class ProgressBar {
413413
public:
414414
ProgressBar(const size_t x, const std::string message = "completion") :
415415
total(x), prev(0), mid_tag(message) {
416+
// the 3 below is for the default left_tag and right_tag printed
417+
// width and the 5 is for the width of the percent (up to 100)
418+
// plus two pipes ('|')
416419
bar_width = max_bar_width - message.length() - 3 - 5;
417420
bar = std::string(bar_width, ' ');
418421
}
@@ -424,13 +427,13 @@ class ProgressBar {
424427

425428
private:
426429

427-
size_t total;
428-
size_t prev;
429-
size_t bar_width;
430+
size_t total{};
431+
size_t prev{};
432+
size_t bar_width{};
430433
std::string left_tag = "\r[";
431434
std::string mid_tag;
432435
std::string bar;
433-
std::string right_tag = "%%]";
436+
std::string right_tag = "%]";
434437

435438
static const size_t max_bar_width = 72;
436439
};

0 commit comments

Comments
 (0)