From 5fa2a4f9d40d401e5fc681738387e328dd8bfdd0 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Tue, 30 Jun 2026 23:32:29 +0200 Subject: [PATCH 01/37] Added indicators library to the project --- cmake/load_dependencies.cmake | 3 ++- conanfile.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/load_dependencies.cmake b/cmake/load_dependencies.cmake index bd67d89a..8f0e669a 100644 --- a/cmake/load_dependencies.cmake +++ b/cmake/load_dependencies.cmake @@ -3,7 +3,8 @@ find_package(magic_enum REQUIRED CONFIG) find_package(CLI11 REQUIRED CONFIG) find_package(Eigen3 REQUIRED CONFIG) find_package(GSL REQUIRED) +find_package(indicators REQUIRED) if(ENABLE_TEST) - find_package(GTest CONFIG REQUIRED) + find_package(GTest CONFIG REQUIRED) endif() diff --git a/conanfile.py b/conanfile.py index 662b4bb5..59f9ffee 100644 --- a/conanfile.py +++ b/conanfile.py @@ -15,6 +15,7 @@ def requirements(self): self.requires("magic_enum/0.9.7") # type: ignore self.requires("cli11/2.6.0") # type: ignore self.requires("eigen/5.0.1") # type: ignore + self.requires("indicators/2.3") # type: ignore # Conditions on cmake variables set from cmake/project_options if os.environ["CMAKE_ENABLE_TEST"] == "ON": From 6eef63bc56f32ec84226a0384858aae61b53d2e5 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Tue, 30 Jun 2026 23:33:07 +0200 Subject: [PATCH 02/37] first implementation of ProgressAdaptor class --- source/centipede/util/progress_indicator.hpp | 106 +++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 source/centipede/util/progress_indicator.hpp diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp new file mode 100644 index 00000000..ac1fbdc8 --- /dev/null +++ b/source/centipede/util/progress_indicator.hpp @@ -0,0 +1,106 @@ +#include +#include +#include + +using namespace indicators; +class ProgressAdaptor; + +template +struct ProgressClosure : std::ranges::range_adaptor_closure> +{ + ProgressAdaptor* adaptor; + std::size_t total_size_n; + IncrementFunT increment_fun; + + template + auto operator()(RangeT range) + { + return (*adaptor)(std::forward(range), total_size_n, increment_fun); + } +}; + +class ProgressAdaptor +{ + public: + template + auto operator()(RangeT&& range, std::size_t total_size_n, IncrementFunT increment_fun) + { + return ProgressView{ this, std::forward(range), total_size_n, increment_fun }; + } + + template + auto operator()(std::size_t total_size_n, IncrementFunT increment_fun) + { + return ProgressClosure{ {}, this, total_size_n, increment_fun }; + } + + template + struct ProgressView + { + using IteratorType = std::ranges::iterator_t; + + ProgressView(ProgressAdaptor* progress_adaptor, + RangeT&& base_range, + std::size_t total_size_n, + IncrementFunT increment_fun) + : progress_adaptor_(progress_adaptor) + , base_range_(std::move(base_range)) + , total_size_n_(total_size_n) + , increment_fun_(increment_fun) + { + } + + auto begin() { return Iterator{ progress_adaptor_, this, base_range_.begin() }; } + + auto end() { return base_range_.end(); } + + class Iterator + { + public: + Iterator(ProgressAdaptor* progress_adaptor, ProgressView* progress_view, IteratorType current_it) + : progress_adaptor_(progress_adaptor) + , progress_view_(progress_view) + , current_it_(current_it) + { + } + + auto operator++() + { + ++current_it_; + count_n_ += progress_view_->increment_fun_(); + progress_adaptor_->bar_.set_progress(100 * count_n_ / progress_view_->total_size_n_); + } + + auto operator*() { return *current_it_; } + + auto operator==(auto& other) { return current_it_ == other; } + auto operator!=(auto& other) { return current_it_ != other; } + auto operator==(const auto& other) const { return current_it_ == other; } + auto operator!=(const auto& other) const { return current_it_ != other; } + + private: + ProgressAdaptor* progress_adaptor_; + ProgressView* progress_view_; + IteratorType current_it_; + std::size_t count_n_{}; + }; + + private: + RangeT base_range_; + std::size_t total_size_n_; + IncrementFunT increment_fun_; + ProgressAdaptor* progress_adaptor_; + }; + + private: + ProgressBar bar_{ option::BarWidth{ 50 }, + option::Start{ "[" }, + option::Fill{ "=" }, + option::Lead{ ">" }, + option::Remainder{ " " }, + option::End{ "]" }, + option::PostfixText{ "Extracting Archive" }, + option::ForegroundColor{ Color::green }, + option::ShowPercentage{ true }, + option::FontStyles{ std::vector{ FontStyle::bold } } }; +}; From 5e1837e40fa4508b01be56f28e9ad315d1082623 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 1 Jul 2026 00:38:01 +0200 Subject: [PATCH 03/37] Further implementation of progress indicator with cmake integration --- source/centipede/util/CMakeLists.txt | 4 +- source/centipede/util/progress_indicator.hpp | 188 +++++++++++-------- 2 files changed, 114 insertions(+), 78 deletions(-) diff --git a/source/centipede/util/CMakeLists.txt b/source/centipede/util/CMakeLists.txt index 9034c594..8e985f7c 100644 --- a/source/centipede/util/CMakeLists.txt +++ b/source/centipede/util/CMakeLists.txt @@ -3,5 +3,7 @@ target_sources( PUBLIC FILE_SET publicHeaders TYPE HEADERS - FILES common_traits.hpp error_types.hpp return_types.hpp + FILES common_traits.hpp error_types.hpp return_types.hpp progress_indicator.hpp ) + +target_link_libraries(core PUBLIC indicators::indicators) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index ac1fbdc8..d6710471 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -1,106 +1,140 @@ #include +#include +#include #include +#include #include +#include -using namespace indicators; -class ProgressAdaptor; - -template -struct ProgressClosure : std::ranges::range_adaptor_closure> +namespace centipede::progress { - ProgressAdaptor* adaptor; - std::size_t total_size_n; - IncrementFunT increment_fun; - - template - auto operator()(RangeT range) - { - return (*adaptor)(std::forward(range), total_size_n, increment_fun); - } -}; - -class ProgressAdaptor -{ - public: - template - auto operator()(RangeT&& range, std::size_t total_size_n, IncrementFunT increment_fun) - { - return ProgressView{ this, std::forward(range), total_size_n, increment_fun }; - } + class ProgressAdaptor; template - auto operator()(std::size_t total_size_n, IncrementFunT increment_fun) + struct ProgressClosure : std::ranges::range_adaptor_closure> { - return ProgressClosure{ {}, this, total_size_n, increment_fun }; - } + ProgressAdaptor* adaptor; + std::size_t total_size_n; + IncrementFunT increment_fun; - template - struct ProgressView - { - using IteratorType = std::ranges::iterator_t; - - ProgressView(ProgressAdaptor* progress_adaptor, - RangeT&& base_range, - std::size_t total_size_n, - IncrementFunT increment_fun) - : progress_adaptor_(progress_adaptor) - , base_range_(std::move(base_range)) - , total_size_n_(total_size_n) - , increment_fun_(increment_fun) + template + auto operator()(RangeT&& range) { + return (*adaptor)(std::forward(range), total_size_n, increment_fun); } + }; - auto begin() { return Iterator{ progress_adaptor_, this, base_range_.begin() }; } + class ProgressAdaptor + { + public: + template + auto operator()(RangeT&& range, std::size_t total_size_n, IncrementFunT increment_fun) + { + return ProgressView{ + this, std::forward(range), total_size_n, increment_fun + }; + } - auto end() { return base_range_.end(); } + template + auto operator()(std::size_t total_size_n, IncrementFunT increment_fun) + { + return ProgressClosure{ {}, this, total_size_n, increment_fun }; + } - class Iterator + template + struct ProgressView { - public: - Iterator(ProgressAdaptor* progress_adaptor, ProgressView* progress_view, IteratorType current_it) - : progress_adaptor_(progress_adaptor) - , progress_view_(progress_view) - , current_it_(current_it) + using IteratorType = std::ranges::iterator_t; + + ProgressView(ProgressAdaptor* progress_adaptor, + RangeT&& base_range, + std::size_t total_size_n, + IncrementFunT increment_fun) + : base_range_(base_range) + , total_size_n_(total_size_n) + , increment_fun_(increment_fun) + , progress_adaptor_(progress_adaptor) { } - auto operator++() + auto begin() { - ++current_it_; - count_n_ += progress_view_->increment_fun_(); - progress_adaptor_->bar_.set_progress(100 * count_n_ / progress_view_->total_size_n_); + auto it = Iterator{ progress_adaptor_, this, base_range_.begin() }; + + it.add_progress(); + + return it; } - auto operator*() { return *current_it_; } + auto end() { return base_range_.end(); } - auto operator==(auto& other) { return current_it_ == other; } - auto operator!=(auto& other) { return current_it_ != other; } - auto operator==(const auto& other) const { return current_it_ == other; } - auto operator!=(const auto& other) const { return current_it_ != other; } + class Iterator + { + public: + Iterator(ProgressAdaptor* progress_adaptor, ProgressView* progress_view, IteratorType current_it) + : progress_adaptor_(progress_adaptor) + , progress_view_(progress_view) + , current_it_(current_it) + { + } + + auto operator++() + { + ++current_it_; + add_progress(); + return *this; + } + + auto operator*() { return *current_it_; } + + auto operator==(auto& other) { return current_it_ == other; } + + auto operator!=(auto& other) { return current_it_ != other; } + + auto operator==(const auto& other) const { return current_it_ == other; } + + auto operator!=(const auto& other) const { return current_it_ != other; } + + void add_progress() + { + if (finished_) + { + return; + } + count_n_ += progress_view_->increment_fun_(); + const auto percent = 100 * count_n_ / progress_view_->total_size_n_; + progress_adaptor_->bar_.set_progress(percent); + if (percent == 100) + { + finished_ = true; + } + } + + private: + ProgressAdaptor* progress_adaptor_; + ProgressView* progress_view_; + IteratorType current_it_; + std::size_t count_n_{}; + bool finished_{ false }; + }; private: + RangeT base_range_; + std::size_t total_size_n_; + IncrementFunT increment_fun_; ProgressAdaptor* progress_adaptor_; - ProgressView* progress_view_; - IteratorType current_it_; - std::size_t count_n_{}; }; private: - RangeT base_range_; - std::size_t total_size_n_; - IncrementFunT increment_fun_; - ProgressAdaptor* progress_adaptor_; + indicators::ProgressBar bar_{ indicators::option::BarWidth{ 50 }, + indicators::option::Start{ "[" }, + indicators::option::Fill{ "=" }, + indicators::option::Lead{ ">" }, + indicators::option::Remainder{ " " }, + indicators::option::End{ "]" }, + indicators::option::ForegroundColor{ indicators::Color::green }, + indicators::option::ShowPercentage{ true }, + indicators::option::FontStyles{ + std::vector{ indicators::FontStyle::bold } } }; }; - - private: - ProgressBar bar_{ option::BarWidth{ 50 }, - option::Start{ "[" }, - option::Fill{ "=" }, - option::Lead{ ">" }, - option::Remainder{ " " }, - option::End{ "]" }, - option::PostfixText{ "Extracting Archive" }, - option::ForegroundColor{ Color::green }, - option::ShowPercentage{ true }, - option::FontStyles{ std::vector{ FontStyle::bold } } }; -}; +} // namespace centipede::progress From b498e97f6146a76f1dcc63e5d382620de76be81e Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 1 Jul 2026 00:38:32 +0200 Subject: [PATCH 04/37] Added functions to access file size, as well as the size of last read entry in bytes --- source/centipede/reader/binary.cpp | 1 + source/centipede/reader/binary.hpp | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/source/centipede/reader/binary.cpp b/source/centipede/reader/binary.cpp index 7ac5e3ee..490ab3b9 100644 --- a/source/centipede/reader/binary.cpp +++ b/source/centipede/reader/binary.cpp @@ -224,6 +224,7 @@ namespace centipede::reader { return std::unexpected{ size.error() }; } + last_entry_bytes_ = (read_size + 1U) * sizeof(uint32_t); ++n_entries_; size_ = size.value(); return size.value(); diff --git a/source/centipede/reader/binary.hpp b/source/centipede/reader/binary.hpp index 2873318c..646870ee 100644 --- a/source/centipede/reader/binary.hpp +++ b/source/centipede/reader/binary.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -169,6 +170,15 @@ namespace centipede::reader */ [[nodiscard]] constexpr auto get_n_entries() const -> std::size_t { return n_entries_; } + // TODO: Add documentation + [[nodiscard]] auto get_file_size() const -> std::size_t + { + return static_cast(std::filesystem::file_size(config_.in_filename)); + } + + // TODO: Add documentation + [[nodiscard]] auto get_last_entry_bytes() const -> std::size_t { return last_entry_bytes_; } + /** * @brief Checks if last read operation reached end of file. * @return Returns true if end of file is reached. @@ -298,6 +308,9 @@ namespace centipede::reader */ auto operator!=(const Sentinel&) const -> bool { return reader_->status_ == ErrorCode::invalid; } + // TODO: add documentation + bool operator==(Sentinel) const { return reader_->status_ != ErrorCode::invalid; } + private: Binary* reader_{}; //!< Associated Binary reader instance. EntrySpan current_{}; //!< Current iterator value. @@ -324,7 +337,9 @@ namespace centipede::reader std::ifstream input_file_; //!< Input file handler std::size_t size_{}; //!< Number of Entrypoints in the current entry std::size_t n_entries_{}; //!< Total number of entries read by this instance - bool end_of_file_{ false }; //!< Indicates if end of file is reached. Gets updated on read. + std::size_t last_entry_bytes_{}; // TODO: Add documentation + + bool end_of_file_{ false }; //!< Indicates if end of file is reached. Gets updated on read. ErrorCode status_{ ErrorCode::invalid }; void reset(); From 578f598b89cc668de80807f08fb619c6dce86c42 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 1 Jul 2026 00:39:17 +0200 Subject: [PATCH 05/37] Testing the progress indicator! --- test/integration_tests/test_reader.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/integration_tests/test_reader.cpp b/test/integration_tests/test_reader.cpp index e3ba3fde..405fd339 100644 --- a/test/integration_tests/test_reader.cpp +++ b/test/integration_tests/test_reader.cpp @@ -1,9 +1,13 @@ #include "centipede/reader/binary.hpp" +#include "centipede/util/progress_indicator.hpp" #include #include +#include auto main() -> int { + static_assert(std::ranges::range); + static_assert(std::ranges::input_range); auto reader = centipede::reader::Binary{ centipede::reader::Binary::Config{ .in_filename = "output.bin" } }; auto init_err = reader.init(); if (not init_err.has_value()) @@ -12,7 +16,9 @@ auto main() -> int return EXIT_FAILURE; } - for ([[maybe_unused]] const auto& entry : reader) + auto progress_adaotor = centipede::progress::ProgressAdaptor{}; + for ([[maybe_unused]] const auto& entry : + reader | progress_adaotor(reader.get_file_size(), [&reader]() { return reader.get_last_entry_bytes(); })) { } From e7b487860f120cde004c22d8b2ff2fe180bd112d Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 1 Jul 2026 01:05:01 +0200 Subject: [PATCH 06/37] Added some important todos I want to implement soon --- source/centipede/util/progress_indicator.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index d6710471..a1200837 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -8,6 +8,12 @@ namespace centipede::progress { + // TODO: + // Overload ProgressAdaptor () to: + // 1) iterate over n elements (instead of increment_fun) + // 2) iterate by 1 (for standard ranges) + // harden templates: use concepts, use std::function + // ProgressAdaptor constructor that takes some config struct (to config the prog bar) class ProgressAdaptor; template From 9e04ed8fc1d4a766ec062be8bd783222c3b97aa9 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 1 Jul 2026 11:29:33 +0200 Subject: [PATCH 07/37] Removed template arguments for IncrementFunT and replaced it with std::function --- source/centipede/util/progress_indicator.hpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index a1200837..897263f1 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -16,8 +17,9 @@ namespace centipede::progress // ProgressAdaptor constructor that takes some config struct (to config the prog bar) class ProgressAdaptor; - template - struct ProgressClosure : std::ranges::range_adaptor_closure> + using IncrementFunT = std::function; + + struct ProgressClosure : std::ranges::range_adaptor_closure { ProgressAdaptor* adaptor; std::size_t total_size_n; @@ -33,21 +35,18 @@ namespace centipede::progress class ProgressAdaptor { public: - template + template auto operator()(RangeT&& range, std::size_t total_size_n, IncrementFunT increment_fun) { - return ProgressView{ - this, std::forward(range), total_size_n, increment_fun - }; + return ProgressView{ this, std::forward(range), total_size_n, increment_fun }; } - template auto operator()(std::size_t total_size_n, IncrementFunT increment_fun) { - return ProgressClosure{ {}, this, total_size_n, increment_fun }; + return ProgressClosure{ {}, this, total_size_n, increment_fun }; } - template + template struct ProgressView { using IteratorType = std::ranges::iterator_t; From c388547ba640df4cc88b206d03b641b8d8a02030 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 1 Jul 2026 11:32:51 +0200 Subject: [PATCH 08/37] Using concept range --- source/centipede/util/progress_indicator.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 897263f1..cc332537 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -36,6 +36,7 @@ namespace centipede::progress { public: template + requires std::ranges::range auto operator()(RangeT&& range, std::size_t total_size_n, IncrementFunT increment_fun) { return ProgressView{ this, std::forward(range), total_size_n, increment_fun }; @@ -47,6 +48,7 @@ namespace centipede::progress } template + requires std::ranges::range struct ProgressView { using IteratorType = std::ranges::iterator_t; From 978b6a7f63b855950ea8c14a7c3d9a2a9a078de0 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 1 Jul 2026 11:33:18 +0200 Subject: [PATCH 09/37] Removed TODO --- source/centipede/util/progress_indicator.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index cc332537..2e7b92f9 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -13,7 +13,6 @@ namespace centipede::progress // Overload ProgressAdaptor () to: // 1) iterate over n elements (instead of increment_fun) // 2) iterate by 1 (for standard ranges) - // harden templates: use concepts, use std::function // ProgressAdaptor constructor that takes some config struct (to config the prog bar) class ProgressAdaptor; From 178381504a88fc22146e9dd4e6ec5bbbe8d0d659 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 1 Jul 2026 12:32:53 +0200 Subject: [PATCH 10/37] Added () overload to iterate up to a certain number of elements. Needs fixing --- source/centipede/util/progress_indicator.hpp | 52 +++++++++++++++----- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 2e7b92f9..11f54ef9 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -14,6 +14,7 @@ namespace centipede::progress // 1) iterate over n elements (instead of increment_fun) // 2) iterate by 1 (for standard ranges) // ProgressAdaptor constructor that takes some config struct (to config the prog bar) + // Error Handling! class ProgressAdaptor; using IncrementFunT = std::function; @@ -41,6 +42,20 @@ namespace centipede::progress return ProgressView{ this, std::forward(range), total_size_n, increment_fun }; } + template + requires std::ranges::range + auto operator()(RangeT&& range, std::size_t total_size_n) + { + return ProgressView{ + this, std::forward(range), total_size_n, []() -> std::size_t { return 1; } + }; + } + + auto operator()(std::size_t total_size_n) + { + return ProgressClosure{ {}, this, total_size_n, []() -> std::size_t { return 1; } }; + } + auto operator()(std::size_t total_size_n, IncrementFunT increment_fun) { return ProgressClosure{ {}, this, total_size_n, increment_fun }; @@ -51,6 +66,7 @@ namespace centipede::progress struct ProgressView { using IteratorType = std::ranges::iterator_t; + using SentinelType = std::ranges::sentinel_t; ProgressView(ProgressAdaptor* progress_adaptor, RangeT&& base_range, @@ -65,41 +81,53 @@ namespace centipede::progress auto begin() { - auto it = Iterator{ progress_adaptor_, this, base_range_.begin() }; - - it.add_progress(); - - return it; + return Iterator{ + progress_adaptor_, this, std::ranges::begin(base_range_), std::ranges::end(base_range_) + }; } - auto end() { return base_range_.end(); } + auto end() { return Sentinel{}; } + struct Sentinel + { + }; class Iterator { public: - Iterator(ProgressAdaptor* progress_adaptor, ProgressView* progress_view, IteratorType current_it) + Iterator(ProgressAdaptor* progress_adaptor, + ProgressView* progress_view, + IteratorType current_it, + SentinelType end_it) : progress_adaptor_(progress_adaptor) , progress_view_(progress_view) , current_it_(current_it) + , end_it_(end_it) { } auto operator++() { ++current_it_; + ++element_count_; add_progress(); return *this; } auto operator*() { return *current_it_; } - auto operator==(auto& other) { return current_it_ == other; } + bool operator==(Sentinel) + { + return current_it_ == end_it_ || element_count_ >= progress_view_->total_size_n_; + } - auto operator!=(auto& other) { return current_it_ != other; } + bool operator!=(Sentinel s) { return !(*this == s); } - auto operator==(const auto& other) const { return current_it_ == other; } + bool operator==(Sentinel) const + { + return current_it_ == end_it_ || element_count_ >= progress_view_->total_size_n_; + } - auto operator!=(const auto& other) const { return current_it_ != other; } + bool operator!=(Sentinel s) const { return !(*this == s); } void add_progress() { @@ -120,6 +148,8 @@ namespace centipede::progress ProgressAdaptor* progress_adaptor_; ProgressView* progress_view_; IteratorType current_it_; + SentinelType end_it_; + std::size_t element_count_{}; std::size_t count_n_{}; bool finished_{ false }; }; From 1c99adc5f8965c281f9a2bf7f80fac89b187ae52 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 1 Jul 2026 17:54:39 +0200 Subject: [PATCH 11/37] Added concept, marked as complete when finished --- source/centipede/util/progress_indicator.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 11f54ef9..e8e58982 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -26,6 +27,7 @@ namespace centipede::progress IncrementFunT increment_fun; template + requires std::ranges::range auto operator()(RangeT&& range) { return (*adaptor)(std::forward(range), total_size_n, increment_fun); @@ -141,6 +143,7 @@ namespace centipede::progress if (percent == 100) { finished_ = true; + progress_adaptor_->bar_.mark_as_completed(); } } From 446571332e8664ca64046c071f280361791250cf Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 1 Jul 2026 18:06:30 +0200 Subject: [PATCH 12/37] ProgressView now has a view to the base range, instead of the range itself.. Not sure about all the move/forward stuff --- source/centipede/util/progress_indicator.hpp | 25 +++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index e8e58982..ce5dddad 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include namespace centipede::progress @@ -19,6 +20,8 @@ namespace centipede::progress class ProgressAdaptor; using IncrementFunT = std::function; + template + using BaseView = std::views::all_t; struct ProgressClosure : std::ranges::range_adaptor_closure { @@ -41,16 +44,19 @@ namespace centipede::progress requires std::ranges::range auto operator()(RangeT&& range, std::size_t total_size_n, IncrementFunT increment_fun) { - return ProgressView{ this, std::forward(range), total_size_n, increment_fun }; + return ProgressView>{ + this, std::views::all(std::forward(range)), total_size_n, std::move(increment_fun) + }; } template requires std::ranges::range auto operator()(RangeT&& range, std::size_t total_size_n) { - return ProgressView{ - this, std::forward(range), total_size_n, []() -> std::size_t { return 1; } - }; + return ProgressView>{ this, + std::views::all(std::forward(range)), + total_size_n, + std::move([]() -> std::size_t { return 1; }) }; } auto operator()(std::size_t total_size_n) @@ -60,21 +66,22 @@ namespace centipede::progress auto operator()(std::size_t total_size_n, IncrementFunT increment_fun) { - return ProgressClosure{ {}, this, total_size_n, increment_fun }; + return ProgressClosure{ {}, this, total_size_n, std::move(increment_fun) }; } template requires std::ranges::range struct ProgressView { + using BaseView = std::views::all_t; using IteratorType = std::ranges::iterator_t; using SentinelType = std::ranges::sentinel_t; ProgressView(ProgressAdaptor* progress_adaptor, - RangeT&& base_range, + BaseView base_view, std::size_t total_size_n, IncrementFunT increment_fun) - : base_range_(base_range) + : base_view_(std::move(base_view)) , total_size_n_(total_size_n) , increment_fun_(increment_fun) , progress_adaptor_(progress_adaptor) @@ -84,7 +91,7 @@ namespace centipede::progress auto begin() { return Iterator{ - progress_adaptor_, this, std::ranges::begin(base_range_), std::ranges::end(base_range_) + progress_adaptor_, this, std::ranges::begin(base_view_), std::ranges::end(base_view_) }; } @@ -158,7 +165,7 @@ namespace centipede::progress }; private: - RangeT base_range_; + BaseView base_view_; std::size_t total_size_n_; IncrementFunT increment_fun_; ProgressAdaptor* progress_adaptor_; From 11176df1610ae89eae763f74236eab0d5412403e Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 1 Jul 2026 19:07:36 +0200 Subject: [PATCH 13/37] Added new error type "incomplete" to determine between an complete vs incomplete read. --- source/centipede/reader/binary.hpp | 12 ++++++------ source/centipede/util/error_types.hpp | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/source/centipede/reader/binary.hpp b/source/centipede/reader/binary.hpp index 646870ee..935d1d22 100644 --- a/source/centipede/reader/binary.hpp +++ b/source/centipede/reader/binary.hpp @@ -191,7 +191,7 @@ namespace centipede::reader * The status is updated during iteration and after manual read operations. * * @return - * - ErrorCode::invalid while iteration/reading is in progress. + * - ErrorCode::incomplete while iteration/reading is in progress. * - ErrorCode::success if iteration finished successfully. * - Any other ErrorCode if a read or parsing error occurred. */ @@ -245,7 +245,7 @@ namespace centipede::reader explicit Iterator(Binary* reader_ptr) : reader_{ reader_ptr } { - reader_->status_ = ErrorCode::invalid; + reader_->status_ = ErrorCode::incomplete; ++(*this); } @@ -286,7 +286,7 @@ namespace centipede::reader } current_ = reader_->get_current_entry(); - reader_->status_ = ErrorCode::invalid; + reader_->status_ = ErrorCode::incomplete; return *this; } /** @@ -306,10 +306,10 @@ namespace centipede::reader * * @return Returns true while iteration is not finished. */ - auto operator!=(const Sentinel&) const -> bool { return reader_->status_ == ErrorCode::invalid; } + auto operator!=(const Sentinel&) const -> bool { return reader_->status_ == ErrorCode::incomplete; } // TODO: add documentation - bool operator==(Sentinel) const { return reader_->status_ != ErrorCode::invalid; } + bool operator==(Sentinel) const { return reader_->status_ != ErrorCode::incomplete; } private: Binary* reader_{}; //!< Associated Binary reader instance. @@ -340,7 +340,7 @@ namespace centipede::reader std::size_t last_entry_bytes_{}; // TODO: Add documentation bool end_of_file_{ false }; //!< Indicates if end of file is reached. Gets updated on read. - ErrorCode status_{ ErrorCode::invalid }; + ErrorCode status_{ ErrorCode::incomplete }; void reset(); auto read_entry_to_buffer(uint32_t read_size) -> EnumError<>; diff --git a/source/centipede/util/error_types.hpp b/source/centipede/util/error_types.hpp index 81010444..0d758bb5 100644 --- a/source/centipede/util/error_types.hpp +++ b/source/centipede/util/error_types.hpp @@ -13,6 +13,7 @@ namespace centipede // TODO: duplication of comments invalid, //!< Error due to no evaluation! success, //!< No error. All good! + incomplete, //!< Operation incomplete! handler_incomp_n_locals, //!< Incompatible number of local variables from the current entrypoint. writer_neg_or_zero_sigma, //!< Zero or negative sigma occurs. See @ref writer::Binary. writer_buffer_overflow, //!< Buffer size is too small for a new entry occurs. See @ref writer::Binary. @@ -99,6 +100,8 @@ struct std::formatter return std::format_to(ctx.out(), "Reader: Filename is either empty or invalid!"); case invalid: return std::format_to(ctx.out(), "Error due to no evaluation!"); + case incomplete: + return std::format_to(ctx.out(), "Operation incomplete!"); default: break; } From d5850a897386cbdd3b28a8dc5bcf4adba0f62798 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 1 Jul 2026 19:08:05 +0200 Subject: [PATCH 14/37] Added integration test for test coverage. Unit tests? --- source/centipede/util/progress_indicator.hpp | 2 +- test/integration_tests/test_reader.cpp | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index ce5dddad..624f5a0d 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -17,6 +16,7 @@ namespace centipede::progress // 2) iterate by 1 (for standard ranges) // ProgressAdaptor constructor that takes some config struct (to config the prog bar) // Error Handling! + // Ehm, testing? class ProgressAdaptor; using IncrementFunT = std::function; diff --git a/test/integration_tests/test_reader.cpp b/test/integration_tests/test_reader.cpp index 405fd339..1f5a0f06 100644 --- a/test/integration_tests/test_reader.cpp +++ b/test/integration_tests/test_reader.cpp @@ -1,5 +1,7 @@ #include "centipede/reader/binary.hpp" +#include "centipede/util/error_types.hpp" #include "centipede/util/progress_indicator.hpp" +#include #include #include #include @@ -16,16 +18,19 @@ auto main() -> int return EXIT_FAILURE; } - auto progress_adaotor = centipede::progress::ProgressAdaptor{}; + auto progress_adaptor = centipede::progress::ProgressAdaptor{}; for ([[maybe_unused]] const auto& entry : - reader | progress_adaotor(reader.get_file_size(), [&reader]() { return reader.get_last_entry_bytes(); })) + reader | progress_adaptor(reader.get_file_size(), [&reader]() { return reader.get_last_entry_bytes(); })) { } if (not reader.is_ok()) { - std::println(stderr, "Error: {}", reader.get_status()); - return EXIT_FAILURE; + if (reader.get_status() != centipede::ErrorCode::incomplete) + { + std::println(stderr, "Error: {}", reader.get_status()); + return EXIT_FAILURE; + } } if (reader.get_n_entries() == 0U) @@ -34,5 +39,11 @@ auto main() -> int return EXIT_FAILURE; } + auto array = std::array{ 1, 2, 3, 4 }; + + for ([[maybe_unused]] auto elem : array | progress_adaptor(array.size())) + { + } + return EXIT_SUCCESS; } From c42d1ebeaf661cb21a593998f43763c0212be2ec Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 1 Jul 2026 19:13:40 +0200 Subject: [PATCH 15/37] Removed finished_ because it's never reached anyways. --- source/centipede/util/progress_indicator.hpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 624f5a0d..8198365d 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -140,16 +140,11 @@ namespace centipede::progress void add_progress() { - if (finished_) - { - return; - } count_n_ += progress_view_->increment_fun_(); const auto percent = 100 * count_n_ / progress_view_->total_size_n_; progress_adaptor_->bar_.set_progress(percent); if (percent == 100) { - finished_ = true; progress_adaptor_->bar_.mark_as_completed(); } } @@ -161,7 +156,6 @@ namespace centipede::progress SentinelType end_it_; std::size_t element_count_{}; std::size_t count_n_{}; - bool finished_{ false }; }; private: From 8c02fb2866dfdf8fbd0e0b772823ae0a90a80a27 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 1 Jul 2026 19:18:58 +0200 Subject: [PATCH 16/37] Forgot to add the range concept to closure --- source/centipede/util/progress_indicator.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 8198365d..32d3e3c0 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -20,7 +20,9 @@ namespace centipede::progress class ProgressAdaptor; using IncrementFunT = std::function; + template + requires std::ranges::range using BaseView = std::views::all_t; struct ProgressClosure : std::ranges::range_adaptor_closure From 03ef1bb131c4d4baecd6c697f6a1ff38b3877823 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 1 Jul 2026 19:21:55 +0200 Subject: [PATCH 17/37] renamed s to sentinel, since it doesn't fit the style --- source/centipede/util/progress_indicator.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 32d3e3c0..0d23f1d3 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -131,14 +131,14 @@ namespace centipede::progress return current_it_ == end_it_ || element_count_ >= progress_view_->total_size_n_; } - bool operator!=(Sentinel s) { return !(*this == s); } + bool operator!=(Sentinel sentinel) { return !(*this == sentinel); } bool operator==(Sentinel) const { return current_it_ == end_it_ || element_count_ >= progress_view_->total_size_n_; } - bool operator!=(Sentinel s) const { return !(*this == s); } + bool operator!=(Sentinel sentinel) const { return !(*this == sentinel); } void add_progress() { From 657714bdccc2a36470faa9f342089cdf2dc73084 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 22 Jul 2026 09:40:38 +0200 Subject: [PATCH 18/37] Added Config struct and error handling --- source/centipede/util/error_types.hpp | 9 ++ source/centipede/util/progress_indicator.hpp | 112 +++++++++++++------ 2 files changed, 89 insertions(+), 32 deletions(-) diff --git a/source/centipede/util/error_types.hpp b/source/centipede/util/error_types.hpp index 0d758bb5..bf82f7e7 100644 --- a/source/centipede/util/error_types.hpp +++ b/source/centipede/util/error_types.hpp @@ -34,6 +34,9 @@ namespace centipede reader_uninitialized, //!< Reader is not initialized. reader_buffer_overflow, //!< Buffer size is too small for a new entry occurs. See @ref reader::Binary. reader_invalid_filename, //!< Filename is invalid or empty + progress_zero_size, //!< Given size is zero + progress_inc_exceeds_size, //!< Increment exceeds given size + progress_inc_returns_zero //!< Increment returns zero }; } // namespace centipede @@ -98,6 +101,12 @@ struct std::formatter return std::format_to(ctx.out(), "Reader: Cannot read the file. Buffer size will be exceeded!"); case reader_invalid_filename: return std::format_to(ctx.out(), "Reader: Filename is either empty or invalid!"); + case progress_zero_size: + return std::format_to(ctx.out(), "Progress: Given size is 0!"); + case progress_inc_exceeds_size: + return std::format_to(ctx.out(), "Progress: Increment exceeds given size!"); + case progress_inc_returns_zero: + return std::format_to(ctx.out(), "Progress: Increment returns 0!"); case invalid: return std::format_to(ctx.out(), "Error due to no evaluation!"); case incomplete: diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 0d23f1d3..5f37818a 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -1,3 +1,4 @@ +#include "centipede/util/error_types.hpp" #include #include #include @@ -17,31 +18,60 @@ namespace centipede::progress // ProgressAdaptor constructor that takes some config struct (to config the prog bar) // Error Handling! // Ehm, testing? - class ProgressAdaptor; - using IncrementFunT = std::function; + class ProgressAdaptor + { + public: + using IncrementFunT = std::function; - template - requires std::ranges::range - using BaseView = std::views::all_t; + ProgressAdaptor() = default; - struct ProgressClosure : std::ranges::range_adaptor_closure - { - ProgressAdaptor* adaptor; - std::size_t total_size_n; - IncrementFunT increment_fun; + struct Config + { + indicators::option::BarWidth bar_width{ 50 }; + indicators::option::PrefixText prefix_text{ "=" }; + indicators::option::PostfixText postfix_text{ "=" }; + indicators::option::Start start{}; + indicators::option::End end{}; + indicators::option::Fill fill{}; + indicators::option::Lead lead{}; + indicators::option::Remainder remainder{}; + indicators::option::MaxPostfixTextLen max_postfix_text_len{}; + indicators::option::Completed completed{}; + indicators::option::ShowPercentage show_percentage{}; + indicators::option::ShowElapsedTime show_elapsed_time{}; + // indicators::option::ShowRemainingTime show_remaining_time; + indicators::option::SavedStartTime saved_start_time{}; + indicators::option::ForegroundColor fore_ground_color{}; + std::vector font_style{ indicators::FontStyle::bold }; + // indicators::option::FontStyles font_styles{}; + // indicators::option::MinProgress min_progress; + // indicators::option::MaxProgress max_progress; + indicators::option::ProgressType progress_type{}; + // indicators::option::Stream stream{}; + }; + + ProgressAdaptor(Config config) + : config_(config) + { + } template requires std::ranges::range - auto operator()(RangeT&& range) + using BaseView = std::views::all_t; + struct ProgressClosure : std::ranges::range_adaptor_closure { - return (*adaptor)(std::forward(range), total_size_n, increment_fun); - } - }; + ProgressAdaptor* adaptor; + std::size_t total_size_n; + IncrementFunT increment_fun; - class ProgressAdaptor - { - public: + template + requires std::ranges::range + auto operator()(RangeT&& range) + { + return (*adaptor)(std::forward(range), total_size_n, increment_fun); + } + }; template requires std::ranges::range auto operator()(RangeT&& range, std::size_t total_size_n, IncrementFunT increment_fun) @@ -58,12 +88,12 @@ namespace centipede::progress return ProgressView>{ this, std::views::all(std::forward(range)), total_size_n, - std::move([]() -> std::size_t { return 1; }) }; + std::move([]() -> std::size_t { return 1UZ; }) }; } auto operator()(std::size_t total_size_n) { - return ProgressClosure{ {}, this, total_size_n, []() -> std::size_t { return 1; } }; + return ProgressClosure{ {}, this, total_size_n, []() -> std::size_t { return 1UZ; } }; } auto operator()(std::size_t total_size_n, IncrementFunT increment_fun) @@ -71,6 +101,8 @@ namespace centipede::progress return ProgressClosure{ {}, this, total_size_n, std::move(increment_fun) }; } + [[nodiscard]] auto get_status() const -> ErrorCode { return status_; } + template requires std::ranges::range struct ProgressView @@ -128,27 +160,50 @@ namespace centipede::progress bool operator==(Sentinel) { - return current_it_ == end_it_ || element_count_ >= progress_view_->total_size_n_; + return current_it_ == end_it_ or element_count_ >= progress_view_->total_size_n_; } bool operator!=(Sentinel sentinel) { return !(*this == sentinel); } bool operator==(Sentinel) const { - return current_it_ == end_it_ || element_count_ >= progress_view_->total_size_n_; + return current_it_ == end_it_ or element_count_ >= progress_view_->total_size_n_; } bool operator!=(Sentinel sentinel) const { return !(*this == sentinel); } void add_progress() { + auto percent = std::size_t{ 0 }; count_n_ += progress_view_->increment_fun_(); - const auto percent = 100 * count_n_ / progress_view_->total_size_n_; + if (progress_view_->increment_fun_() == 0UZ) + { + progress_adaptor_->status_ = ErrorCode::progress_inc_returns_zero; + percent = 0UZ; + progress_adaptor_->bar_.mark_as_completed(); + return; + } + if (progress_view_->total_size_n_ == 0UZ) + { + progress_adaptor_->status_ = ErrorCode::progress_zero_size; + percent = 100UZ; + progress_adaptor_->bar_.mark_as_completed(); + return; + } + if (count_n_ > progress_view_->total_size_n_) + { + progress_adaptor_->status_ = ErrorCode::progress_inc_exceeds_size; + percent = 100UZ; + progress_adaptor_->bar_.mark_as_completed(); + return; + } + percent = 100 * count_n_ / progress_view_->total_size_n_; progress_adaptor_->bar_.set_progress(percent); if (percent == 100) { progress_adaptor_->bar_.mark_as_completed(); } + progress_adaptor_->status_ = ErrorCode::success; } private: @@ -168,15 +223,8 @@ namespace centipede::progress }; private: - indicators::ProgressBar bar_{ indicators::option::BarWidth{ 50 }, - indicators::option::Start{ "[" }, - indicators::option::Fill{ "=" }, - indicators::option::Lead{ ">" }, - indicators::option::Remainder{ " " }, - indicators::option::End{ "]" }, - indicators::option::ForegroundColor{ indicators::Color::green }, - indicators::option::ShowPercentage{ true }, - indicators::option::FontStyles{ - std::vector{ indicators::FontStyle::bold } } }; + Config config_{}; + indicators::ProgressBar bar_{ std::move(config_.bar_width), std::move(config_.start), std::move(config_.fill) }; + ErrorCode status_ = ErrorCode::success; }; } // namespace centipede::progress From 185221062a154a15eea764f455c647f6dc63e74e Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 22 Jul 2026 11:21:29 +0200 Subject: [PATCH 19/37] Using forward variadic template constructor instead of config struct. Moved error handling to more fitting places --- source/centipede/util/progress_indicator.hpp | 94 ++++++++++---------- 1 file changed, 45 insertions(+), 49 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 5f37818a..15e5f792 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -19,6 +19,10 @@ namespace centipede::progress // Error Handling! // Ehm, testing? + namespace config = indicators::option; + using ProgressFontStyle = indicators::FontStyle; + using ProgressColor = indicators::Color; + class ProgressAdaptor { public: @@ -26,33 +30,9 @@ namespace centipede::progress ProgressAdaptor() = default; - struct Config - { - indicators::option::BarWidth bar_width{ 50 }; - indicators::option::PrefixText prefix_text{ "=" }; - indicators::option::PostfixText postfix_text{ "=" }; - indicators::option::Start start{}; - indicators::option::End end{}; - indicators::option::Fill fill{}; - indicators::option::Lead lead{}; - indicators::option::Remainder remainder{}; - indicators::option::MaxPostfixTextLen max_postfix_text_len{}; - indicators::option::Completed completed{}; - indicators::option::ShowPercentage show_percentage{}; - indicators::option::ShowElapsedTime show_elapsed_time{}; - // indicators::option::ShowRemainingTime show_remaining_time; - indicators::option::SavedStartTime saved_start_time{}; - indicators::option::ForegroundColor fore_ground_color{}; - std::vector font_style{ indicators::FontStyle::bold }; - // indicators::option::FontStyles font_styles{}; - // indicators::option::MinProgress min_progress; - // indicators::option::MaxProgress max_progress; - indicators::option::ProgressType progress_type{}; - // indicators::option::Stream stream{}; - }; - - ProgressAdaptor(Config config) - : config_(config) + template + explicit ProgressAdaptor(Options&&... options) + : bar_{ std::forward(options)... } { } @@ -117,19 +97,27 @@ namespace centipede::progress IncrementFunT increment_fun) : base_view_(std::move(base_view)) , total_size_n_(total_size_n) - , increment_fun_(increment_fun) + , increment_fun_(std::move(increment_fun)) , progress_adaptor_(progress_adaptor) { } auto begin() { + if (total_size_n_ == 0UZ) + { + progress_adaptor_->status_ = ErrorCode::progress_zero_size; + + progress_adaptor_->bar_.mark_as_completed(); + } + return Iterator{ progress_adaptor_, this, std::ranges::begin(base_view_), std::ranges::end(base_view_) }; } auto end() { return Sentinel{}; } + struct Sentinel { }; @@ -174,36 +162,35 @@ namespace centipede::progress void add_progress() { - auto percent = std::size_t{ 0 }; - count_n_ += progress_view_->increment_fun_(); - if (progress_view_->increment_fun_() == 0UZ) + const auto increment = progress_view_->increment_fun_(); + + if (increment == 0UZ) { progress_adaptor_->status_ = ErrorCode::progress_inc_returns_zero; - percent = 0UZ; - progress_adaptor_->bar_.mark_as_completed(); return; } - if (progress_view_->total_size_n_ == 0UZ) + + if (increment > progress_view_->total_size_n_ - count_n_) { - progress_adaptor_->status_ = ErrorCode::progress_zero_size; - percent = 100UZ; - progress_adaptor_->bar_.mark_as_completed(); - return; + progress_adaptor_->status_ = ErrorCode::progress_inc_exceeds_size; + + count_n_ = progress_view_->total_size_n_; } - if (count_n_ > progress_view_->total_size_n_) + else { - progress_adaptor_->status_ = ErrorCode::progress_inc_exceeds_size; - percent = 100UZ; - progress_adaptor_->bar_.mark_as_completed(); - return; + count_n_ += increment; + progress_adaptor_->status_ = ErrorCode::success; } - percent = 100 * count_n_ / progress_view_->total_size_n_; + + const auto percent = 100UZ * count_n_ / progress_view_->total_size_n_; + progress_adaptor_->bar_.set_progress(percent); - if (percent == 100) + + if (count_n_ >= progress_view_->total_size_n_) { progress_adaptor_->bar_.mark_as_completed(); + progress_adaptor_->status_ = ErrorCode::success; } - progress_adaptor_->status_ = ErrorCode::success; } private: @@ -223,8 +210,17 @@ namespace centipede::progress }; private: - Config config_{}; - indicators::ProgressBar bar_{ std::move(config_.bar_width), std::move(config_.start), std::move(config_.fill) }; - ErrorCode status_ = ErrorCode::success; + indicators::ProgressBar bar_{ config::BarWidth{ 50 }, + config::Start{ "[" }, + config::Fill{ "=" }, + config::Lead{ ">" }, + config::Remainder{ " " }, + config::End{ "]" }, + config::PostfixText{ "Reading binary data" }, + config::ForegroundColor{ ProgressColor::green }, + config::ShowPercentage{ true }, + config::FontStyles{ + std::vector{ ProgressFontStyle::bold } } }; + ErrorCode status_ = ErrorCode::incomplete; }; } // namespace centipede::progress From 2dab3c8f0a557813000a6818ac54f43e0fd6bff2 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 22 Jul 2026 11:21:51 +0200 Subject: [PATCH 20/37] Adjusted integration tests for ProgressAdaptor in reader::Binary --- test/integration_tests/test_reader.cpp | 34 +++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/test/integration_tests/test_reader.cpp b/test/integration_tests/test_reader.cpp index 1f5a0f06..982f8bba 100644 --- a/test/integration_tests/test_reader.cpp +++ b/test/integration_tests/test_reader.cpp @@ -3,8 +3,13 @@ #include "centipede/util/progress_indicator.hpp" #include #include +#include +#include +#include +#include #include #include +#include auto main() -> int { @@ -18,7 +23,20 @@ auto main() -> int return EXIT_FAILURE; } - auto progress_adaptor = centipede::progress::ProgressAdaptor{}; + auto progress_adaptor = centipede::progress::ProgressAdaptor{ + centipede::progress::config::BarWidth{ 50 }, + centipede::progress::config::Start{ "[" }, + centipede::progress::config::Fill{ "=" }, + centipede::progress::config::Lead{ ">" }, + centipede::progress::config::Remainder{ " " }, + centipede::progress::config::End{ "]" }, + centipede::progress::config::PostfixText{ "Reading binary data" }, + centipede::progress::config::ForegroundColor{ centipede::progress::ProgressColor::green }, + centipede::progress::config::ShowPercentage{ true }, + centipede::progress::config::FontStyles{ + std::vector{ centipede::progress::ProgressFontStyle::bold } } + }; + for ([[maybe_unused]] const auto& entry : reader | progress_adaptor(reader.get_file_size(), [&reader]() { return reader.get_last_entry_bytes(); })) { @@ -39,11 +57,25 @@ auto main() -> int return EXIT_FAILURE; } + if (const auto progress_adaptor_status = progress_adaptor.get_status(); + progress_adaptor_status != centipede::ErrorCode::success) + { + std::println(stderr, "Error: {}", progress_adaptor_status); + return EXIT_FAILURE; + } + auto array = std::array{ 1, 2, 3, 4 }; for ([[maybe_unused]] auto elem : array | progress_adaptor(array.size())) { } + if (const auto progress_adaptor_status = progress_adaptor.get_status(); + progress_adaptor_status != centipede::ErrorCode::success) + { + std::println(stderr, "Error: {}", progress_adaptor_status); + return EXIT_FAILURE; + } + return EXIT_SUCCESS; } From 0f0559a6e02767536a1f6ece9a272956d0603e74 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 22 Jul 2026 11:44:46 +0200 Subject: [PATCH 21/37] Testing direct closure. --- source/centipede/util/progress_indicator.hpp | 12 +++++++++++- test/integration_tests/test_reader.cpp | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 15e5f792..a7844e7b 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -23,7 +23,7 @@ namespace centipede::progress using ProgressFontStyle = indicators::FontStyle; using ProgressColor = indicators::Color; - class ProgressAdaptor + class ProgressAdaptor : public std::ranges::range_adaptor_closure { public: using IncrementFunT = std::function; @@ -71,6 +71,16 @@ namespace centipede::progress std::move([]() -> std::size_t { return 1UZ; }) }; } + template + requires std::ranges::sized_range + auto operator()(RangeT&& range) + { + return ProgressView>{ this, + std::views::all(std::forward(range)), + std::ranges::size(range), + std::move([]() -> std::size_t { return 1UZ; }) }; + } + auto operator()(std::size_t total_size_n) { return ProgressClosure{ {}, this, total_size_n, []() -> std::size_t { return 1UZ; } }; diff --git a/test/integration_tests/test_reader.cpp b/test/integration_tests/test_reader.cpp index 982f8bba..887bcd13 100644 --- a/test/integration_tests/test_reader.cpp +++ b/test/integration_tests/test_reader.cpp @@ -66,7 +66,7 @@ auto main() -> int auto array = std::array{ 1, 2, 3, 4 }; - for ([[maybe_unused]] auto elem : array | progress_adaptor(array.size())) + for ([[maybe_unused]] auto elem : array | centipede::progress::ProgressAdaptor{}) { } From 091088803709284c3631e565230810c33ea8859c Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 22 Jul 2026 13:23:56 +0200 Subject: [PATCH 22/37] RangeAdaptor pointer is dangling if expression `auto view = range | ProgressAdaptor` is used. Used Ref qualifier. --- source/centipede/util/progress_indicator.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index a7844e7b..6751223c 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -54,7 +54,7 @@ namespace centipede::progress }; template requires std::ranges::range - auto operator()(RangeT&& range, std::size_t total_size_n, IncrementFunT increment_fun) + auto operator()(RangeT&& range, std::size_t total_size_n, IncrementFunT increment_fun) & { return ProgressView>{ this, std::views::all(std::forward(range)), total_size_n, std::move(increment_fun) @@ -63,7 +63,7 @@ namespace centipede::progress template requires std::ranges::range - auto operator()(RangeT&& range, std::size_t total_size_n) + auto operator()(RangeT&& range, std::size_t total_size_n) & { return ProgressView>{ this, std::views::all(std::forward(range)), @@ -73,7 +73,7 @@ namespace centipede::progress template requires std::ranges::sized_range - auto operator()(RangeT&& range) + auto operator()(RangeT&& range) & { return ProgressView>{ this, std::views::all(std::forward(range)), From e0acccaac0eff5551e22ff72c3eac5fcda516342 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 22 Jul 2026 14:54:55 +0200 Subject: [PATCH 23/37] ProgressView and ProgressAdaptor share state and bar via shared_ptr to avoid dangling pointer when using auto `view = range | ProgressAdaptor{}` --- source/centipede/util/progress_indicator.hpp | 107 ++++++++----------- 1 file changed, 46 insertions(+), 61 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 6751223c..e91dff2d 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -5,17 +5,13 @@ #include #include #include +#include #include #include -#include namespace centipede::progress { // TODO: - // Overload ProgressAdaptor () to: - // 1) iterate over n elements (instead of increment_fun) - // 2) iterate by 1 (for standard ranges) - // ProgressAdaptor constructor that takes some config struct (to config the prog bar) // Error Handling! // Ehm, testing? @@ -32,7 +28,7 @@ namespace centipede::progress template explicit ProgressAdaptor(Options&&... options) - : bar_{ std::forward(options)... } + : bar_ptr_{ std::make_shared(std::forward(options)...) } { } @@ -54,31 +50,35 @@ namespace centipede::progress }; template requires std::ranges::range - auto operator()(RangeT&& range, std::size_t total_size_n, IncrementFunT increment_fun) & + auto operator()(RangeT&& range, std::size_t total_size_n, IncrementFunT increment_fun) { - return ProgressView>{ - this, std::views::all(std::forward(range)), total_size_n, std::move(increment_fun) - }; + return ProgressView>{ std::views::all(std::forward(range)), + total_size_n, + std::move(increment_fun), + bar_ptr_, + status_ptr_ }; } template requires std::ranges::range - auto operator()(RangeT&& range, std::size_t total_size_n) & + auto operator()(RangeT&& range, std::size_t total_size_n) { - return ProgressView>{ this, - std::views::all(std::forward(range)), + return ProgressView>{ std::views::all(std::forward(range)), total_size_n, - std::move([]() -> std::size_t { return 1UZ; }) }; + []() -> std::size_t { return 1UZ; }, + bar_ptr_, + status_ptr_ }; } template requires std::ranges::sized_range - auto operator()(RangeT&& range) & + auto operator()(RangeT&& range) { - return ProgressView>{ this, - std::views::all(std::forward(range)), + return ProgressView>{ std::views::all(std::forward(range)), std::ranges::size(range), - std::move([]() -> std::size_t { return 1UZ; }) }; + []() -> std::size_t { return 1UZ; }, + bar_ptr_, + status_ptr_ }; } auto operator()(std::size_t total_size_n) @@ -91,7 +91,7 @@ namespace centipede::progress return ProgressClosure{ {}, this, total_size_n, std::move(increment_fun) }; } - [[nodiscard]] auto get_status() const -> ErrorCode { return status_; } + [[nodiscard]] auto get_status() const -> ErrorCode { return *status_ptr_; } template requires std::ranges::range @@ -101,29 +101,31 @@ namespace centipede::progress using IteratorType = std::ranges::iterator_t; using SentinelType = std::ranges::sentinel_t; - ProgressView(ProgressAdaptor* progress_adaptor, - BaseView base_view, + ProgressView(BaseView base_view, std::size_t total_size_n, - IncrementFunT increment_fun) + IncrementFunT increment_fun, + std::shared_ptr bar_ptr, + std::shared_ptr status_ptr) : base_view_(std::move(base_view)) , total_size_n_(total_size_n) , increment_fun_(std::move(increment_fun)) - , progress_adaptor_(progress_adaptor) + , bar_ptr_(std::move(bar_ptr)) + , status_ptr_(std::move(status_ptr)) { } + auto get_status() -> ErrorCode { return *status_ptr_; } + auto begin() { if (total_size_n_ == 0UZ) { - progress_adaptor_->status_ = ErrorCode::progress_zero_size; + *status_ptr_ = ErrorCode::progress_zero_size; - progress_adaptor_->bar_.mark_as_completed(); + bar_ptr_->mark_as_completed(); } - return Iterator{ - progress_adaptor_, this, std::ranges::begin(base_view_), std::ranges::end(base_view_) - }; + return Iterator{ this, std::ranges::begin(base_view_), std::ranges::end(base_view_) }; } auto end() { return Sentinel{}; } @@ -135,12 +137,8 @@ namespace centipede::progress class Iterator { public: - Iterator(ProgressAdaptor* progress_adaptor, - ProgressView* progress_view, - IteratorType current_it, - SentinelType end_it) - : progress_adaptor_(progress_adaptor) - , progress_view_(progress_view) + Iterator(ProgressView* progress_view, IteratorType current_it, SentinelType end_it) + : progress_view_(progress_view) , current_it_(current_it) , end_it_(end_it) { @@ -148,9 +146,9 @@ namespace centipede::progress auto operator++() { + add_progress(); ++current_it_; ++element_count_; - add_progress(); return *this; } @@ -176,35 +174,31 @@ namespace centipede::progress if (increment == 0UZ) { - progress_adaptor_->status_ = ErrorCode::progress_inc_returns_zero; + *progress_view_->status_ptr_ = ErrorCode::progress_inc_returns_zero; return; } - if (increment > progress_view_->total_size_n_ - count_n_) - { - progress_adaptor_->status_ = ErrorCode::progress_inc_exceeds_size; + const auto remaining = progress_view_->total_size_n_ - count_n_; + if (increment > remaining) + { count_n_ = progress_view_->total_size_n_; + + *progress_view_->status_ptr_ = ErrorCode::progress_inc_exceeds_size; } else { count_n_ += increment; - progress_adaptor_->status_ = ErrorCode::success; + + *progress_view_->status_ptr_ = ErrorCode::success; } const auto percent = 100UZ * count_n_ / progress_view_->total_size_n_; - progress_adaptor_->bar_.set_progress(percent); - - if (count_n_ >= progress_view_->total_size_n_) - { - progress_adaptor_->bar_.mark_as_completed(); - progress_adaptor_->status_ = ErrorCode::success; - } + progress_view_->bar_ptr_->set_progress(percent); } private: - ProgressAdaptor* progress_adaptor_; ProgressView* progress_view_; IteratorType current_it_; SentinelType end_it_; @@ -216,21 +210,12 @@ namespace centipede::progress BaseView base_view_; std::size_t total_size_n_; IncrementFunT increment_fun_; - ProgressAdaptor* progress_adaptor_; + std::shared_ptr bar_ptr_ = nullptr; + std::shared_ptr status_ptr_ = nullptr; }; private: - indicators::ProgressBar bar_{ config::BarWidth{ 50 }, - config::Start{ "[" }, - config::Fill{ "=" }, - config::Lead{ ">" }, - config::Remainder{ " " }, - config::End{ "]" }, - config::PostfixText{ "Reading binary data" }, - config::ForegroundColor{ ProgressColor::green }, - config::ShowPercentage{ true }, - config::FontStyles{ - std::vector{ ProgressFontStyle::bold } } }; - ErrorCode status_ = ErrorCode::incomplete; + std::shared_ptr bar_ptr_{ std::make_shared() }; + std::shared_ptr status_ptr_ = std::make_shared(ErrorCode::incomplete); }; } // namespace centipede::progress From b7ec488bfeea6f8f99b3e83e97d4fde583fc6b5b Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 22 Jul 2026 14:55:12 +0200 Subject: [PATCH 24/37] Experimental testing environment. Move to unit tests --- test/integration_tests/test_reader.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/test/integration_tests/test_reader.cpp b/test/integration_tests/test_reader.cpp index 887bcd13..8f765f88 100644 --- a/test/integration_tests/test_reader.cpp +++ b/test/integration_tests/test_reader.cpp @@ -30,16 +30,25 @@ auto main() -> int centipede::progress::config::Lead{ ">" }, centipede::progress::config::Remainder{ " " }, centipede::progress::config::End{ "]" }, - centipede::progress::config::PostfixText{ "Reading binary data" }, + centipede::progress::config::PostfixText{ "Reading binary data..." }, centipede::progress::config::ForegroundColor{ centipede::progress::ProgressColor::green }, centipede::progress::config::ShowPercentage{ true }, centipede::progress::config::FontStyles{ std::vector{ centipede::progress::ProgressFontStyle::bold } } }; + std::size_t total_read{}; + for ([[maybe_unused]] const auto& entry : reader | progress_adaptor(reader.get_file_size(), [&reader]() { return reader.get_last_entry_bytes(); })) { + total_read += reader.get_last_entry_bytes(); + } + + if (total_read != reader.get_file_size()) + { + std::println(stderr, "Error: not all reads counted"); + return EXIT_FAILURE; } if (not reader.is_ok()) @@ -66,10 +75,19 @@ auto main() -> int auto array = std::array{ 1, 2, 3, 4 }; - for ([[maybe_unused]] auto elem : array | centipede::progress::ProgressAdaptor{}) + auto progress_view = array | centipede::progress::ProgressAdaptor{}; + + for ([[maybe_unused]] auto elem : progress_view) { } + if (const auto progress_view_status = progress_view.get_status(); + progress_view_status != centipede::ErrorCode::success) + { + std::println(stderr, "Error: {}", progress_view_status); + return EXIT_FAILURE; + } + if (const auto progress_adaptor_status = progress_adaptor.get_status(); progress_adaptor_status != centipede::ErrorCode::success) { From 5fd8a1fe435a9d4ee0ab37f9d03556a2ab3972cc Mon Sep 17 00:00:00 2001 From: Baryonics Date: Wed, 22 Jul 2026 15:18:21 +0200 Subject: [PATCH 25/37] ProgressClosure now also has shared_pointer instead of pointer --- source/centipede/util/progress_indicator.hpp | 52 +++++++++++++------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index e91dff2d..07d6ffd6 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -1,4 +1,5 @@ #include "centipede/util/error_types.hpp" +#include #include #include #include @@ -35,19 +36,27 @@ namespace centipede::progress template requires std::ranges::range using BaseView = std::views::all_t; + struct ProgressClosure : std::ranges::range_adaptor_closure { - ProgressAdaptor* adaptor; std::size_t total_size_n; IncrementFunT increment_fun; + std::shared_ptr bar_ptr; + std::shared_ptr status_ptr; + template requires std::ranges::range auto operator()(RangeT&& range) { - return (*adaptor)(std::forward(range), total_size_n, increment_fun); + using ViewT = std::views::all_t; + + return ProgressView{ + std::views::all(std::forward(range)), total_size_n, increment_fun, bar_ptr, status_ptr + }; } }; + template requires std::ranges::range auto operator()(RangeT&& range, std::size_t total_size_n, IncrementFunT increment_fun) @@ -83,12 +92,12 @@ namespace centipede::progress auto operator()(std::size_t total_size_n) { - return ProgressClosure{ {}, this, total_size_n, []() -> std::size_t { return 1UZ; } }; + return ProgressClosure{ {}, total_size_n, []() -> std::size_t { return 1UZ; }, bar_ptr_, status_ptr_ }; } auto operator()(std::size_t total_size_n, IncrementFunT increment_fun) { - return ProgressClosure{ {}, this, total_size_n, std::move(increment_fun) }; + return ProgressClosure{ {}, total_size_n, std::move(increment_fun), bar_ptr_, status_ptr_ }; } [[nodiscard]] auto get_status() const -> ErrorCode { return *status_ptr_; } @@ -112,6 +121,9 @@ namespace centipede::progress , bar_ptr_(std::move(bar_ptr)) , status_ptr_(std::move(status_ptr)) { + assert(bar_ptr_); + assert(status_ptr_); + assert(increment_fun_); } auto get_status() -> ErrorCode { return *status_ptr_; } @@ -142,34 +154,38 @@ namespace centipede::progress , current_it_(current_it) , end_it_(end_it) { + assert(progress_view_); } - auto operator++() + auto operator++() -> Iterator& { + assert(current_it_ != end_it_); add_progress(); ++current_it_; - ++element_count_; return *this; } - auto operator*() { return *current_it_; } - - bool operator==(Sentinel) + auto operator*() { - return current_it_ == end_it_ or element_count_ >= progress_view_->total_size_n_; + assert(current_it_ != end_it_); + return *current_it_; } + bool operator==(Sentinel) { return current_it_ == end_it_; } + bool operator!=(Sentinel sentinel) { return !(*this == sentinel); } - bool operator==(Sentinel) const - { - return current_it_ == end_it_ or element_count_ >= progress_view_->total_size_n_; - } + bool operator==(Sentinel) const { return current_it_ == end_it_; } bool operator!=(Sentinel sentinel) const { return !(*this == sentinel); } void add_progress() { + assert(progress_view_); + assert(progress_view_->bar_ptr_); + assert(progress_view_->status_ptr_); + assert(progress_view_->increment_fun_); + assert(count_n_ <= progress_view_->total_size_n_); const auto increment = progress_view_->increment_fun_(); if (increment == 0UZ) @@ -189,20 +205,22 @@ namespace centipede::progress else { count_n_ += increment; - - *progress_view_->status_ptr_ = ErrorCode::success; } const auto percent = 100UZ * count_n_ / progress_view_->total_size_n_; progress_view_->bar_ptr_->set_progress(percent); + + if (count_n_ == progress_view_->total_size_n_) + { + *(progress_view_->status_ptr_) = ErrorCode::success; + } } private: ProgressView* progress_view_; IteratorType current_it_; SentinelType end_it_; - std::size_t element_count_{}; std::size_t count_n_{}; }; From db12c1e7a1a348a173d423e34778aa1dcce194f8 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Sun, 16 Aug 2026 12:24:29 +0200 Subject: [PATCH 26/37] New API --- source/centipede/util/progress_indicator.hpp | 499 ++++++++++++------- 1 file changed, 314 insertions(+), 185 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 07d6ffd6..9dd8dbb6 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -1,5 +1,6 @@ #include "centipede/util/error_types.hpp" #include +#include #include #include #include @@ -8,232 +9,360 @@ #include #include #include +#include #include -namespace centipede::progress +namespace centipede { // TODO: // Error Handling! // Ehm, testing? - namespace config = indicators::option; - using ProgressFontStyle = indicators::FontStyle; - using ProgressColor = indicators::Color; + template + concept is_increment_function = std::invocable && std::same_as, std::size_t>; - class ProgressAdaptor : public std::ranges::range_adaptor_closure - { - public: - using IncrementFunT = std::function; + template + concept is_range = std::ranges::range; - ProgressAdaptor() = default; - - template - explicit ProgressAdaptor(Options&&... options) - : bar_ptr_{ std::make_shared(std::forward(options)...) } + class ProgressIndicator + { + private: + template + struct ProgressView { - } + using BaseView = std::views::all_t; - template - requires std::ranges::range - using BaseView = std::views::all_t; + ProgressView(BaseView&& view, + std::size_t total_size, + IncrementFunctionT&& inc_func, + ProgressIndicator* indicator) + : base_view(std::move(view)) + , total_size_n(total_size) + , increment_function(std::move(inc_func)) + , progress_indicator(indicator) + { + } - struct ProgressClosure : std::ranges::range_adaptor_closure - { - std::size_t total_size_n; - IncrementFunT increment_fun; + auto begin() {} - std::shared_ptr bar_ptr; - std::shared_ptr status_ptr; + auto end() {} - template - requires std::ranges::range - auto operator()(RangeT&& range) + struct Sentinel { - using ViewT = std::views::all_t; + }; - return ProgressView{ - std::views::all(std::forward(range)), total_size_n, increment_fun, bar_ptr, status_ptr - }; - } - }; + struct Iterator + { - template - requires std::ranges::range - auto operator()(RangeT&& range, std::size_t total_size_n, IncrementFunT increment_fun) - { - return ProgressView>{ std::views::all(std::forward(range)), - total_size_n, - std::move(increment_fun), - bar_ptr_, - status_ptr_ }; - } - - template - requires std::ranges::range - auto operator()(RangeT&& range, std::size_t total_size_n) - { - return ProgressView>{ std::views::all(std::forward(range)), - total_size_n, - []() -> std::size_t { return 1UZ; }, - bar_ptr_, - status_ptr_ }; - } - - template - requires std::ranges::sized_range - auto operator()(RangeT&& range) - { - return ProgressView>{ std::views::all(std::forward(range)), - std::ranges::size(range), - []() -> std::size_t { return 1UZ; }, - bar_ptr_, - status_ptr_ }; - } - - auto operator()(std::size_t total_size_n) - { - return ProgressClosure{ {}, total_size_n, []() -> std::size_t { return 1UZ; }, bar_ptr_, status_ptr_ }; - } + auto operator++() -> Iterator& {} - auto operator()(std::size_t total_size_n, IncrementFunT increment_fun) - { - return ProgressClosure{ {}, total_size_n, std::move(increment_fun), bar_ptr_, status_ptr_ }; - } + auto operator*() {} - [[nodiscard]] auto get_status() const -> ErrorCode { return *status_ptr_; } + bool operator==(Sentinel) {} - template - requires std::ranges::range - struct ProgressView + bool operator!=(Sentinel sentinel) {} + + bool operator==(Sentinel) const {} + + bool operator!=(Sentinel sentinel) const {} + }; + + std::size_t total_size_n{}; + BaseView base_view{}; + IncrementFunctionT increment_function{}; + ProgressIndicator* progress_indicator = nullptr; + }; + + struct ProgressAdaptor : std::ranges::range_adaptor_closure { - using BaseView = std::views::all_t; - using IteratorType = std::ranges::iterator_t; - using SentinelType = std::ranges::sentinel_t; - - ProgressView(BaseView base_view, - std::size_t total_size_n, - IncrementFunT increment_fun, - std::shared_ptr bar_ptr, - std::shared_ptr status_ptr) - : base_view_(std::move(base_view)) - , total_size_n_(total_size_n) - , increment_fun_(std::move(increment_fun)) - , bar_ptr_(std::move(bar_ptr)) - , status_ptr_(std::move(status_ptr)) + ProgressAdaptor(ProgressIndicator* indicator) + : progress_indicator(indicator) { - assert(bar_ptr_); - assert(status_ptr_); - assert(increment_fun_); } - auto get_status() -> ErrorCode { return *status_ptr_; } - - auto begin() + auto operator()(is_range auto&& range) { - if (total_size_n_ == 0UZ) - { - *status_ptr_ = ErrorCode::progress_zero_size; - - bar_ptr_->mark_as_completed(); - } - - return Iterator{ this, std::ranges::begin(base_view_), std::ranges::end(base_view_) }; + return ProgressView{ std::views::all(std::forward(range)), + std::ranges::size(range), + []() { return 1UZ; }, + progress_indicator }; } - auto end() { return Sentinel{}; } + auto operator()(is_range auto&& range, std::size_t total_size, is_increment_function auto&& inc_func) + { + return ProgressView{ std::views::all(std::forward(range), total_size, std::move(inc_func)) }; + } - struct Sentinel + auto operator()(is_range auto&& range, std::size_t total_size) { - }; + return ProgressView{ std::views::all(std::forward(range), total_size, []() { return 1UZ; }) }; + } - class Iterator + auto operator()(std::size_t total_size) { - public: - Iterator(ProgressView* progress_view, IteratorType current_it, SentinelType end_it) - : progress_view_(progress_view) - , current_it_(current_it) - , end_it_(end_it) - { - assert(progress_view_); - } + return ProgressClosure{ this, total_size, []() { return 1UZ; } }; + } - auto operator++() -> Iterator& - { - assert(current_it_ != end_it_); - add_progress(); - ++current_it_; - return *this; - } + auto operator()(std::size_t total_size, is_increment_function auto&& inc_func) + { + return ProgressClosure{ this, total_size, std::move(inc_func) }; + } - auto operator*() + template + struct ProgressClosure : std::ranges::range_adaptor_closure> + { + ProgressClosure(ProgressAdaptor* adaptor, std::size_t total_size, IncrementFunctionT&& inc_func) + : progress_adaptor(adaptor) + , total_size_n(total_size) + , increment_function(std::move(inc_func)) { - assert(current_it_ != end_it_); - return *current_it_; } - bool operator==(Sentinel) { return current_it_ == end_it_; } - - bool operator!=(Sentinel sentinel) { return !(*this == sentinel); } - - bool operator==(Sentinel) const { return current_it_ == end_it_; } - - bool operator!=(Sentinel sentinel) const { return !(*this == sentinel); } - - void add_progress() + auto operator()(is_range auto&& range) { - assert(progress_view_); - assert(progress_view_->bar_ptr_); - assert(progress_view_->status_ptr_); - assert(progress_view_->increment_fun_); - assert(count_n_ <= progress_view_->total_size_n_); - const auto increment = progress_view_->increment_fun_(); - - if (increment == 0UZ) - { - *progress_view_->status_ptr_ = ErrorCode::progress_inc_returns_zero; - return; - } - - const auto remaining = progress_view_->total_size_n_ - count_n_; - - if (increment > remaining) - { - count_n_ = progress_view_->total_size_n_; - - *progress_view_->status_ptr_ = ErrorCode::progress_inc_exceeds_size; - } - else - { - count_n_ += increment; - } - - const auto percent = 100UZ * count_n_ / progress_view_->total_size_n_; - - progress_view_->bar_ptr_->set_progress(percent); - - if (count_n_ == progress_view_->total_size_n_) - { - *(progress_view_->status_ptr_) = ErrorCode::success; - } + return ProgressView{ + std::views::all(std::forward(range)), + total_size_n, + std::move(increment_function), + }; } - private: - ProgressView* progress_view_; - IteratorType current_it_; - SentinelType end_it_; - std::size_t count_n_{}; + ProgressAdaptor* progress_adaptor = nullptr; + std::size_t total_size_n{}; + IncrementFunctionT increment_function{}; }; - private: - BaseView base_view_; - std::size_t total_size_n_; - IncrementFunT increment_fun_; - std::shared_ptr bar_ptr_ = nullptr; - std::shared_ptr status_ptr_ = nullptr; + ProgressIndicator* progress_indicator = nullptr; }; - private: - std::shared_ptr bar_ptr_{ std::make_shared() }; - std::shared_ptr status_ptr_ = std::make_shared(ErrorCode::incomplete); + indicators::ProgressBar bar_{}; + ErrorCode status_{}; + + public: + ProgressAdaptor adaptor{ this }; }; -} // namespace centipede::progress + + /********************* OLD *************************/ + + // using ProgressFontStyle = indicators::FontStyle; + // using ProgressColor = indicators::Color; + // + // class ProgressAdaptor : public std::ranges::range_adaptor_closure + // { + // public: + // using IncrementFunT = std::function; + // + // ProgressAdaptor() = default; + // + // template + // explicit ProgressAdaptor(Options&&... options) + // : bar_ptr_{ std::make_shared(std::forward(options)...) } + // { + // } + // + // template + // requires std::ranges::range + // using BaseView = std::views::all_t; + // + // struct ProgressClosure : std::ranges::range_adaptor_closure + // { + // std::size_t total_size_n; + // IncrementFunT increment_fun; + // + // std::shared_ptr bar_ptr; + // std::shared_ptr status_ptr; + // + // template + // requires std::ranges::range + // auto operator()(RangeT&& range) + // { + // using ViewT = std::views::all_t; + // + // return ProgressView{ + // std::views::all(std::forward(range)), total_size_n, increment_fun, bar_ptr, + // status_ptr + // }; + // } + // }; + // + // template + // requires std::ranges::range + // auto operator()(RangeT&& range, std::size_t total_size_n, IncrementFunT increment_fun) + // { + // return ProgressView>{ std::views::all(std::forward(range)), + // total_size_n, + // std::move(increment_fun), + // bar_ptr_, + // status_ptr_ }; + // } + // + // template + // requires std::ranges::range + // auto operator()(RangeT&& range, std::size_t total_size_n) + // { + // return ProgressView>{ std::views::all(std::forward(range)), + // total_size_n, + // []() -> std::size_t { return 1UZ; }, + // bar_ptr_, + // status_ptr_ }; + // } + // + // template + // requires std::ranges::sized_range + // auto operator()(RangeT&& range) + // { + // return ProgressView>{ std::views::all(std::forward(range)), + // std::ranges::size(range), + // []() -> std::size_t { return 1UZ; }, + // bar_ptr_, + // status_ptr_ }; + // } + // + // auto operator()(std::size_t total_size_n) + // { + // return ProgressClosure{ {}, total_size_n, []() -> std::size_t { return 1UZ; }, bar_ptr_, status_ptr_ + // }; + // } + // + // auto operator()(std::size_t total_size_n, IncrementFunT increment_fun) + // { + // return ProgressClosure{ {}, total_size_n, std::move(increment_fun), bar_ptr_, status_ptr_ }; + // } + // + // [[nodiscard]] auto get_status() const -> ErrorCode { return *status_ptr_; } + // + // template + // requires std::ranges::range + // struct ProgressView + // { + // using BaseView = std::views::all_t; + // using IteratorType = std::ranges::iterator_t; + // using SentinelType = std::ranges::sentinel_t; + // + // ProgressView(BaseView base_view, + // std::size_t total_size_n, + // IncrementFunT increment_fun, + // std::shared_ptr bar_ptr, + // std::shared_ptr status_ptr) + // : base_view_(std::move(base_view)) + // , total_size_n_(total_size_n) + // , increment_fun_(std::move(increment_fun)) + // , bar_ptr_(std::move(bar_ptr)) + // , status_ptr_(std::move(status_ptr)) + // { + // assert(bar_ptr_); + // assert(status_ptr_); + // assert(increment_fun_); + // } + // + // auto get_status() -> ErrorCode { return *status_ptr_; } + // + // auto begin() + // { + // if (total_size_n_ == 0UZ) + // { + // *status_ptr_ = ErrorCode::progress_zero_size; + // + // bar_ptr_->mark_as_completed(); + // } + // + // return Iterator{ this, std::ranges::begin(base_view_), std::ranges::end(base_view_) }; + // } + // + // auto end() { return Sentinel{}; } + // + // struct Sentinel + // { + // }; + // + // class Iterator + // { + // public: + // Iterator(ProgressView* progress_view, IteratorType current_it, SentinelType end_it) + // : progress_view_(progress_view) + // , current_it_(current_it) + // , end_it_(end_it) + // { + // assert(progress_view_); + // } + // + // auto operator++() -> Iterator& + // { + // assert(current_it_ != end_it_); + // add_progress(); + // ++current_it_; + // return *this; + // } + // + // auto operator*() + // { + // assert(current_it_ != end_it_); + // return *current_it_; + // } + // + // bool operator==(Sentinel) { return current_it_ == end_it_; } + // + // bool operator!=(Sentinel sentinel) { return !(*this == sentinel); } + // + // bool operator==(Sentinel) const { return current_it_ == end_it_; } + // + // bool operator!=(Sentinel sentinel) const { return !(*this == sentinel); } + // + // void add_progress() + // { + // assert(progress_view_); + // assert(progress_view_->bar_ptr_); + // assert(progress_view_->status_ptr_); + // assert(progress_view_->increment_fun_); + // assert(count_n_ <= progress_view_->total_size_n_); + // const auto increment = progress_view_->increment_fun_(); + // + // if (increment == 0UZ) + // { + // *progress_view_->status_ptr_ = ErrorCode::progress_inc_returns_zero; + // return; + // } + // + // const auto remaining = progress_view_->total_size_n_ - count_n_; + // + // if (increment > remaining) + // { + // count_n_ = progress_view_->total_size_n_; + // + // *progress_view_->status_ptr_ = ErrorCode::progress_inc_exceeds_size; + // } + // else + // { + // count_n_ += increment; + // } + // + // const auto percent = 100UZ * count_n_ / progress_view_->total_size_n_; + // + // progress_view_->bar_ptr_->set_progress(percent); + // + // if (count_n_ == progress_view_->total_size_n_) + // { + // *(progress_view_->status_ptr_) = ErrorCode::success; + // } + // } + // + // private: + // ProgressView* progress_view_; + // IteratorType current_it_; + // SentinelType end_it_; + // std::size_t count_n_{}; + // }; + // + // private: + // BaseView base_view_; + // std::size_t total_size_n_; + // IncrementFunT increment_fun_; + // std::shared_ptr bar_ptr_ = nullptr; + // std::shared_ptr status_ptr_ = nullptr; + // }; + // + // private: + // std::shared_ptr bar_ptr_{ std::make_shared() }; + // std::shared_ptr status_ptr_ = std::make_shared(ErrorCode::incomplete); + // }; +} // namespace centipede From 7581abdc7f859e8bff5127c997ec78a1796f9325 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Sun, 16 Aug 2026 12:38:32 +0200 Subject: [PATCH 27/37] fixes --- source/centipede/util/progress_indicator.hpp | 35 +++++++++++--------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 9dd8dbb6..854bf792 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -22,7 +22,7 @@ namespace centipede concept is_increment_function = std::invocable && std::same_as, std::size_t>; template - concept is_range = std::ranges::range; + concept is_range = std::ranges::sized_range; class ProgressIndicator { @@ -82,7 +82,7 @@ namespace centipede auto operator()(is_range auto&& range) { - return ProgressView{ std::views::all(std::forward(range)), + return ProgressView{ std::views::all(std::forward(range)), std::ranges::size(range), []() { return 1UZ; }, progress_indicator }; @@ -90,46 +90,51 @@ namespace centipede auto operator()(is_range auto&& range, std::size_t total_size, is_increment_function auto&& inc_func) { - return ProgressView{ std::views::all(std::forward(range), total_size, std::move(inc_func)) }; + return ProgressView{ std::views::all(std::forward(range)), + total_size, + std::move(inc_func), + progress_indicator }; } auto operator()(is_range auto&& range, std::size_t total_size) { - return ProgressView{ std::views::all(std::forward(range), total_size, []() { return 1UZ; }) }; + return ProgressView{ std::views::all(std::forward(range)), + total_size, + []() { return 1UZ; }, + progress_indicator }; } auto operator()(std::size_t total_size) { - return ProgressClosure{ this, total_size, []() { return 1UZ; } }; + return ProgressClosure{ total_size, []() { return 1UZ; }, progress_indicator }; } auto operator()(std::size_t total_size, is_increment_function auto&& inc_func) { - return ProgressClosure{ this, total_size, std::move(inc_func) }; + return ProgressClosure{ progress_indicator, total_size, std::move(inc_func), progress_indicator }; } template struct ProgressClosure : std::ranges::range_adaptor_closure> { - ProgressClosure(ProgressAdaptor* adaptor, std::size_t total_size, IncrementFunctionT&& inc_func) - : progress_adaptor(adaptor) - , total_size_n(total_size) + ProgressClosure(std::size_t total_size, IncrementFunctionT&& inc_func, ProgressIndicator* indicator) + : total_size_n(total_size) , increment_function(std::move(inc_func)) + , progress_indicator(indicator) { } auto operator()(is_range auto&& range) { - return ProgressView{ - std::views::all(std::forward(range)), - total_size_n, - std::move(increment_function), - }; + return ProgressView{ std::views::all(std::forward(range)), + total_size_n, + std::move(increment_function), + progress_indicator }; } - ProgressAdaptor* progress_adaptor = nullptr; std::size_t total_size_n{}; IncrementFunctionT increment_function{}; + ProgressIndicator* progress_indicator = nullptr; }; ProgressIndicator* progress_indicator = nullptr; From 6a489a4f92a7a3c62b9292e4be03170d8b63bca1 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Sun, 16 Aug 2026 13:20:40 +0200 Subject: [PATCH 28/37] added standard config for progressbar --- source/centipede/util/common_definitions.hpp | 1 + source/centipede/util/progress_indicator.hpp | 523 ++++++++++--------- 2 files changed, 276 insertions(+), 248 deletions(-) diff --git a/source/centipede/util/common_definitions.hpp b/source/centipede/util/common_definitions.hpp index 1854c256..50c09233 100644 --- a/source/centipede/util/common_definitions.hpp +++ b/source/centipede/util/common_definitions.hpp @@ -6,4 +6,5 @@ namespace centipede::common { constexpr auto DEFAULT_BUFFER_SIZE = std::size_t{ 10000 }; //!< Default maximum buffer size for binary readers/writers. + constexpr auto DEFAULT_INDICATOR_BAR_WIDTH = std::size_t{ 50 }; } // namespace centipede::common diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 854bf792..0c56f0a5 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -1,16 +1,17 @@ +#include "centipede/util/common_definitions.hpp" #include "centipede/util/error_types.hpp" #include #include #include -#include #include #include #include #include -#include #include +#include #include #include +#include namespace centipede { @@ -21,17 +22,33 @@ namespace centipede template concept is_increment_function = std::invocable && std::same_as, std::size_t>; - template - concept is_range = std::ranges::sized_range; - class ProgressIndicator { - private: - template - struct ProgressView + public: + struct Config + { + bool enable_percentage = true; + std::size_t bar_width = common::DEFAULT_INDICATOR_BAR_WIDTH; + std::string label_text; + }; + + explicit ProgressIndicator(Config config) + : config_(std::move(config)) { - using BaseView = std::views::all_t; + } + + ProgressIndicator(ProgressIndicator&&) = delete; + ProgressIndicator& operator=(ProgressIndicator&&) = delete; + ProgressIndicator(const ProgressIndicator&) = delete; + ProgressIndicator& operator=(const ProgressIndicator&) = delete; + + auto adaptor() & { return ProgressAdaptor{ this }; } + auto adaptor() && = delete; + private: + template + struct ProgressView : std::ranges::view_interface> + { ProgressView(BaseView&& view, std::size_t total_size, IncrementFunctionT&& inc_func, @@ -44,7 +61,6 @@ namespace centipede } auto begin() {} - auto end() {} struct Sentinel @@ -53,23 +69,20 @@ namespace centipede struct Iterator { - auto operator++() -> Iterator& {} auto operator*() {} bool operator==(Sentinel) {} - bool operator!=(Sentinel sentinel) {} bool operator==(Sentinel) const {} - bool operator!=(Sentinel sentinel) const {} }; + BaseView base_view; std::size_t total_size_n{}; - BaseView base_view{}; - IncrementFunctionT increment_function{}; + IncrementFunctionT increment_function; ProgressIndicator* progress_indicator = nullptr; }; @@ -80,7 +93,7 @@ namespace centipede { } - auto operator()(is_range auto&& range) + auto operator()(std::ranges::sized_range auto&& range) { return ProgressView{ std::views::all(std::forward(range)), std::ranges::size(range), @@ -88,7 +101,9 @@ namespace centipede progress_indicator }; } - auto operator()(is_range auto&& range, std::size_t total_size, is_increment_function auto&& inc_func) + auto operator()(std::ranges::viewable_range auto&& range, + std::size_t total_size, + is_increment_function auto&& inc_func) { return ProgressView{ std::views::all(std::forward(range)), total_size, @@ -96,7 +111,7 @@ namespace centipede progress_indicator }; } - auto operator()(is_range auto&& range, std::size_t total_size) + auto operator()(std::ranges::viewable_range auto&& range, std::size_t total_size) { return ProgressView{ std::views::all(std::forward(range)), total_size, @@ -111,7 +126,7 @@ namespace centipede auto operator()(std::size_t total_size, is_increment_function auto&& inc_func) { - return ProgressClosure{ progress_indicator, total_size, std::move(inc_func), progress_indicator }; + return ProgressClosure{ total_size, std::move(inc_func), progress_indicator }; } template @@ -124,7 +139,7 @@ namespace centipede { } - auto operator()(is_range auto&& range) + auto operator()(std::ranges::viewable_range auto&& range) { return ProgressView{ std::views::all(std::forward(range)), total_size_n, @@ -133,241 +148,253 @@ namespace centipede } std::size_t total_size_n{}; - IncrementFunctionT increment_function{}; + IncrementFunctionT increment_function; ProgressIndicator* progress_indicator = nullptr; }; ProgressIndicator* progress_indicator = nullptr; }; - indicators::ProgressBar bar_{}; + Config config_{}; + indicators::ProgressBar bar_{ indicators::option::BarWidth{ config_.bar_width }, + indicators::option::Start{ " [" }, + indicators::option::Fill{ "█" }, + indicators::option::Lead{ "█" }, + indicators::option::Remainder{ "-" }, + indicators::option::End{ "]" }, + indicators::option::PrefixText{ config_.label_text }, + indicators::option::ForegroundColor{ indicators::Color::yellow }, + indicators::option::ShowPercentage{ true }, + indicators::option::ShowElapsedTime{ true }, + indicators::option::ShowRemainingTime{ true }, + indicators::option::FontStyles{ + std::vector{ indicators::FontStyle::bold } } }; ErrorCode status_{}; - - public: - ProgressAdaptor adaptor{ this }; }; +} // namespace centipede - /********************* OLD *************************/ +/********************* OLD *************************/ - // using ProgressFontStyle = indicators::FontStyle; - // using ProgressColor = indicators::Color; - // - // class ProgressAdaptor : public std::ranges::range_adaptor_closure - // { - // public: - // using IncrementFunT = std::function; - // - // ProgressAdaptor() = default; - // - // template - // explicit ProgressAdaptor(Options&&... options) - // : bar_ptr_{ std::make_shared(std::forward(options)...) } - // { - // } - // - // template - // requires std::ranges::range - // using BaseView = std::views::all_t; - // - // struct ProgressClosure : std::ranges::range_adaptor_closure - // { - // std::size_t total_size_n; - // IncrementFunT increment_fun; - // - // std::shared_ptr bar_ptr; - // std::shared_ptr status_ptr; - // - // template - // requires std::ranges::range - // auto operator()(RangeT&& range) - // { - // using ViewT = std::views::all_t; - // - // return ProgressView{ - // std::views::all(std::forward(range)), total_size_n, increment_fun, bar_ptr, - // status_ptr - // }; - // } - // }; - // - // template - // requires std::ranges::range - // auto operator()(RangeT&& range, std::size_t total_size_n, IncrementFunT increment_fun) - // { - // return ProgressView>{ std::views::all(std::forward(range)), - // total_size_n, - // std::move(increment_fun), - // bar_ptr_, - // status_ptr_ }; - // } - // - // template - // requires std::ranges::range - // auto operator()(RangeT&& range, std::size_t total_size_n) - // { - // return ProgressView>{ std::views::all(std::forward(range)), - // total_size_n, - // []() -> std::size_t { return 1UZ; }, - // bar_ptr_, - // status_ptr_ }; - // } - // - // template - // requires std::ranges::sized_range - // auto operator()(RangeT&& range) - // { - // return ProgressView>{ std::views::all(std::forward(range)), - // std::ranges::size(range), - // []() -> std::size_t { return 1UZ; }, - // bar_ptr_, - // status_ptr_ }; - // } - // - // auto operator()(std::size_t total_size_n) - // { - // return ProgressClosure{ {}, total_size_n, []() -> std::size_t { return 1UZ; }, bar_ptr_, status_ptr_ - // }; - // } - // - // auto operator()(std::size_t total_size_n, IncrementFunT increment_fun) - // { - // return ProgressClosure{ {}, total_size_n, std::move(increment_fun), bar_ptr_, status_ptr_ }; - // } - // - // [[nodiscard]] auto get_status() const -> ErrorCode { return *status_ptr_; } - // - // template - // requires std::ranges::range - // struct ProgressView - // { - // using BaseView = std::views::all_t; - // using IteratorType = std::ranges::iterator_t; - // using SentinelType = std::ranges::sentinel_t; - // - // ProgressView(BaseView base_view, - // std::size_t total_size_n, - // IncrementFunT increment_fun, - // std::shared_ptr bar_ptr, - // std::shared_ptr status_ptr) - // : base_view_(std::move(base_view)) - // , total_size_n_(total_size_n) - // , increment_fun_(std::move(increment_fun)) - // , bar_ptr_(std::move(bar_ptr)) - // , status_ptr_(std::move(status_ptr)) - // { - // assert(bar_ptr_); - // assert(status_ptr_); - // assert(increment_fun_); - // } - // - // auto get_status() -> ErrorCode { return *status_ptr_; } - // - // auto begin() - // { - // if (total_size_n_ == 0UZ) - // { - // *status_ptr_ = ErrorCode::progress_zero_size; - // - // bar_ptr_->mark_as_completed(); - // } - // - // return Iterator{ this, std::ranges::begin(base_view_), std::ranges::end(base_view_) }; - // } - // - // auto end() { return Sentinel{}; } - // - // struct Sentinel - // { - // }; - // - // class Iterator - // { - // public: - // Iterator(ProgressView* progress_view, IteratorType current_it, SentinelType end_it) - // : progress_view_(progress_view) - // , current_it_(current_it) - // , end_it_(end_it) - // { - // assert(progress_view_); - // } - // - // auto operator++() -> Iterator& - // { - // assert(current_it_ != end_it_); - // add_progress(); - // ++current_it_; - // return *this; - // } - // - // auto operator*() - // { - // assert(current_it_ != end_it_); - // return *current_it_; - // } - // - // bool operator==(Sentinel) { return current_it_ == end_it_; } - // - // bool operator!=(Sentinel sentinel) { return !(*this == sentinel); } - // - // bool operator==(Sentinel) const { return current_it_ == end_it_; } - // - // bool operator!=(Sentinel sentinel) const { return !(*this == sentinel); } - // - // void add_progress() - // { - // assert(progress_view_); - // assert(progress_view_->bar_ptr_); - // assert(progress_view_->status_ptr_); - // assert(progress_view_->increment_fun_); - // assert(count_n_ <= progress_view_->total_size_n_); - // const auto increment = progress_view_->increment_fun_(); - // - // if (increment == 0UZ) - // { - // *progress_view_->status_ptr_ = ErrorCode::progress_inc_returns_zero; - // return; - // } - // - // const auto remaining = progress_view_->total_size_n_ - count_n_; - // - // if (increment > remaining) - // { - // count_n_ = progress_view_->total_size_n_; - // - // *progress_view_->status_ptr_ = ErrorCode::progress_inc_exceeds_size; - // } - // else - // { - // count_n_ += increment; - // } - // - // const auto percent = 100UZ * count_n_ / progress_view_->total_size_n_; - // - // progress_view_->bar_ptr_->set_progress(percent); - // - // if (count_n_ == progress_view_->total_size_n_) - // { - // *(progress_view_->status_ptr_) = ErrorCode::success; - // } - // } - // - // private: - // ProgressView* progress_view_; - // IteratorType current_it_; - // SentinelType end_it_; - // std::size_t count_n_{}; - // }; - // - // private: - // BaseView base_view_; - // std::size_t total_size_n_; - // IncrementFunT increment_fun_; - // std::shared_ptr bar_ptr_ = nullptr; - // std::shared_ptr status_ptr_ = nullptr; - // }; - // - // private: - // std::shared_ptr bar_ptr_{ std::make_shared() }; - // std::shared_ptr status_ptr_ = std::make_shared(ErrorCode::incomplete); - // }; -} // namespace centipede +// using ProgressFontStyle = indicators::FontStyle; +// using ProgressColor = indicators::Color; +// +// class ProgressAdaptor : public std::ranges::range_adaptor_closure +// { +// public: +// using IncrementFunT = std::function; +// +// ProgressAdaptor() = default; +// +// template +// explicit ProgressAdaptor(iopts&&... options) +// : bar_ptr_{ std::make_shared(std::forward(options)...) } +// { +// } +// +// template +// requires std::ranges::range +// using BaseView = std::views::all_t; +// +// struct ProgressClosure : std::ranges::range_adaptor_closure +// { +// std::size_t total_size_n; +// IncrementFunT increment_fun; +// +// std::shared_ptr bar_ptr; +// std::shared_ptr status_ptr; +// +// template +// requires std::ranges::range +// auto operator()(RangeT&& range) +// { +// using ViewT = std::views::all_t; +// +// return ProgressView{ +// std::views::all(std::forward(range)), total_size_n, increment_fun, bar_ptr, +// status_ptr +// }; +// } +// }; +// +// template +// requires std::ranges::range +// auto operator()(RangeT&& range, std::size_t total_size_n, IncrementFunT increment_fun) +// { +// return ProgressView>{ std::views::all(std::forward(range)), +// total_size_n, +// std::move(increment_fun), +// bar_ptr_, +// status_ptr_ }; +// } +// +// template +// requires std::ranges::range +// auto operator()(RangeT&& range, std::size_t total_size_n) +// { +// return ProgressView>{ std::views::all(std::forward(range)), +// total_size_n, +// []() -> std::size_t { return 1UZ; }, +// bar_ptr_, +// status_ptr_ }; +// } +// +// template +// requires std::ranges::sized_range +// auto operator()(RangeT&& range) +// { +// return ProgressView>{ std::views::all(std::forward(range)), +// std::ranges::size(range), +// []() -> std::size_t { return 1UZ; }, +// bar_ptr_, +// status_ptr_ }; +// } +// +// auto operator()(std::size_t total_size_n) +// { +// return ProgressClosure{ {}, total_size_n, []() -> std::size_t { return 1UZ; }, bar_ptr_, status_ptr_ +// }; +// } +// +// auto operator()(std::size_t total_size_n, IncrementFunT increment_fun) +// { +// return ProgressClosure{ {}, total_size_n, std::move(increment_fun), bar_ptr_, status_ptr_ }; +// } +// +// [[nodiscard]] auto get_status() const -> ErrorCode { return *status_ptr_; } +// +// template +// requires std::ranges::range +// struct ProgressView +// { +// using BaseView = std::views::all_t; +// using IteratorType = std::ranges::iterator_t; +// using SentinelType = std::ranges::sentinel_t; +// +// ProgressView(BaseView base_view, +// std::size_t total_size_n, +// IncrementFunT increment_fun, +// std::shared_ptr bar_ptr, +// std::shared_ptr status_ptr) +// : base_view_(std::move(base_view)) +// , total_size_n_(total_size_n) +// , increment_fun_(std::move(increment_fun)) +// , bar_ptr_(std::move(bar_ptr)) +// , status_ptr_(std::move(status_ptr)) +// { +// assert(bar_ptr_); +// assert(status_ptr_); +// assert(increment_fun_); +// } +// +// auto get_status() -> ErrorCode { return *status_ptr_; } +// +// auto begin() +// { +// if (total_size_n_ == 0UZ) +// { +// *status_ptr_ = ErrorCode::progress_zero_size; +// +// bar_ptr_->mark_as_completed(); +// } +// +// return Iterator{ this, std::ranges::begin(base_view_), std::ranges::end(base_view_) }; +// } +// +// auto end() { return Sentinel{}; } +// +// struct Sentinel +// { +// }; +// +// class Iterator +// { +// public: +// Iterator(ProgressView* progress_view, IteratorType current_it, SentinelType end_it) +// : progress_view_(progress_view) +// , current_it_(current_it) +// , end_it_(end_it) +// { +// assert(progress_view_); +// } +// +// auto operator++() -> Iterator& +// { +// assert(current_it_ != end_it_); +// add_progress(); +// ++current_it_; +// return *this; +// } +// +// auto operator*() +// { +// assert(current_it_ != end_it_); +// return *current_it_; +// } +// +// bool operator==(Sentinel) { return current_it_ == end_it_; } +// +// bool operator!=(Sentinel sentinel) { return !(*this == sentinel); } +// +// bool operator==(Sentinel) const { return current_it_ == end_it_; } +// +// bool operator!=(Sentinel sentinel) const { return !(*this == sentinel); } +// +// void add_progress() +// { +// assert(progress_view_); +// assert(progress_view_->bar_ptr_); +// assert(progress_view_->status_ptr_); +// assert(progress_view_->increment_fun_); +// assert(count_n_ <= progress_view_->total_size_n_); +// const auto increment = progress_view_->increment_fun_(); +// +// if (increment == 0UZ) +// { +// *progress_view_->status_ptr_ = ErrorCode::progress_inc_returns_zero; +// return; +// } +// +// const auto remaining = progress_view_->total_size_n_ - count_n_; +// +// if (increment > remaining) +// { +// count_n_ = progress_view_->total_size_n_; +// +// *progress_view_->status_ptr_ = ErrorCode::progress_inc_exceeds_size; +// } +// else +// { +// count_n_ += increment; +// } +// +// const auto percent = 100UZ * count_n_ / progress_view_->total_size_n_; +// +// progress_view_->bar_ptr_->set_progress(percent); +// +// if (count_n_ == progress_view_->total_size_n_) +// { +// *(progress_view_->status_ptr_) = ErrorCode::success; +// } +// } +// +// private: +// ProgressView* progress_view_; +// IteratorType current_it_; +// SentinelType end_it_; +// std::size_t count_n_{}; +// }; +// +// private: +// BaseView base_view_; +// std::size_t total_size_n_; +// IncrementFunT increment_fun_; +// std::shared_ptr bar_ptr_ = nullptr; +// std::shared_ptr status_ptr_ = nullptr; +// }; +// +// private: +// std::shared_ptr bar_ptr_{ std::make_shared() }; +// std::shared_ptr status_ptr_ = std::make_shared(ErrorCode::incomplete); +// }; + +// } // namespace centipede From cf355c53bab2f6a22efc18a70c15ecb735e2681e Mon Sep 17 00:00:00 2001 From: Baryonics Date: Sun, 16 Aug 2026 13:30:23 +0200 Subject: [PATCH 29/37] Implemented new Iterator --- source/centipede/util/progress_indicator.hpp | 115 +++++++++++++++++-- 1 file changed, 104 insertions(+), 11 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 0c56f0a5..055209f4 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -32,6 +32,8 @@ namespace centipede std::string label_text; }; + ProgressIndicator() = default; + explicit ProgressIndicator(Config config) : config_(std::move(config)) { @@ -42,13 +44,16 @@ namespace centipede ProgressIndicator(const ProgressIndicator&) = delete; ProgressIndicator& operator=(const ProgressIndicator&) = delete; - auto adaptor() & { return ProgressAdaptor{ this }; } - auto adaptor() && = delete; + // auto adaptor() & { return ProgressAdaptor{ this }; } + // auto adaptor() && = delete; private: template struct ProgressView : std::ranges::view_interface> { + using IteratorType = std::ranges::iterator_t; + using SentinelType = std::ranges::sentinel_t; + ProgressView(BaseView&& view, std::size_t total_size, IncrementFunctionT&& inc_func, @@ -58,26 +63,111 @@ namespace centipede , increment_function(std::move(inc_func)) , progress_indicator(indicator) { + assert(progress_indicator); + } + + auto begin() + { + assert(progress_indicator); + + if (total_size_n == 0UZ) + { + progress_indicator->status_ = ErrorCode::progress_zero_size; + progress_indicator->bar_.mark_as_completed(); + } + + return Iterator{ this, std::ranges::begin(base_view), std::ranges::end(base_view) }; } - auto begin() {} - auto end() {} + auto end() { return Sentinel{}; } struct Sentinel { }; - struct Iterator + class Iterator { - auto operator++() -> Iterator& {} + public: + Iterator(ProgressView* progress_view, IteratorType current_it, SentinelType end_it) + : progress_view_(progress_view) + , current_it_(std::move(current_it)) + , end_it_(std::move(end_it)) + { + assert(progress_view_); + assert(progress_view_->progress_indicator); + } + + auto operator++() -> Iterator& + { + assert(current_it_ != end_it_); + + add_progress(); + ++current_it_; - auto operator*() {} + return *this; + } + + decltype(auto) operator*() const + { + assert(current_it_ != end_it_); + return *current_it_; + } - bool operator==(Sentinel) {} - bool operator!=(Sentinel sentinel) {} + bool operator==(Sentinel) const { return current_it_ == end_it_; } - bool operator==(Sentinel) const {} - bool operator!=(Sentinel sentinel) const {} + bool operator!=(Sentinel sentinel) const { return !(*this == sentinel); } + + private: + void add_progress() + { + assert(progress_view_); + assert(progress_view_->progress_indicator); + + auto& indicator = *progress_view_->progress_indicator; + + if (progress_view_->total_size_n == 0UZ) + { + indicator.status_ = ErrorCode::progress_zero_size; + return; + } + + assert(count_n_ <= progress_view_->total_size_n); + + const auto increment = progress_view_->increment_function(); // NOTE: std::invoke? + + if (increment == 0UZ) + { + indicator.status_ = ErrorCode::progress_inc_returns_zero; + return; + } + + const auto remaining = progress_view_->total_size_n - count_n_; + + if (increment > remaining) + { + count_n_ = progress_view_->total_size_n; + + indicator.status_ = ErrorCode::progress_inc_exceeds_size; + } + else + { + count_n_ += increment; + } + + const auto percent = 100UZ * count_n_ / progress_view_->total_size_n; + + indicator.bar_.set_progress(percent); + + if (count_n_ == progress_view_->total_size_n) + { + indicator.status_ = ErrorCode::success; + } + } + + ProgressView* progress_view_ = nullptr; + IteratorType current_it_; + SentinelType end_it_; + std::size_t count_n_{}; }; BaseView base_view; @@ -170,6 +260,9 @@ namespace centipede indicators::option::FontStyles{ std::vector{ indicators::FontStyle::bold } } }; ErrorCode status_{}; + + public: + ProgressAdaptor adaptor{ this }; }; } // namespace centipede From 48d5330c303779981d19d1e4c38620e5945cb4ac Mon Sep 17 00:00:00 2001 From: Baryonics Date: Sun, 16 Aug 2026 13:30:42 +0200 Subject: [PATCH 30/37] temporary integration test adjustments --- test/integration_tests/test_reader.cpp | 73 +++++++++++--------------- 1 file changed, 31 insertions(+), 42 deletions(-) diff --git a/test/integration_tests/test_reader.cpp b/test/integration_tests/test_reader.cpp index 8f765f88..2d89c3e2 100644 --- a/test/integration_tests/test_reader.cpp +++ b/test/integration_tests/test_reader.cpp @@ -23,24 +23,13 @@ auto main() -> int return EXIT_FAILURE; } - auto progress_adaptor = centipede::progress::ProgressAdaptor{ - centipede::progress::config::BarWidth{ 50 }, - centipede::progress::config::Start{ "[" }, - centipede::progress::config::Fill{ "=" }, - centipede::progress::config::Lead{ ">" }, - centipede::progress::config::Remainder{ " " }, - centipede::progress::config::End{ "]" }, - centipede::progress::config::PostfixText{ "Reading binary data..." }, - centipede::progress::config::ForegroundColor{ centipede::progress::ProgressColor::green }, - centipede::progress::config::ShowPercentage{ true }, - centipede::progress::config::FontStyles{ - std::vector{ centipede::progress::ProgressFontStyle::bold } } - }; + auto progress_indicator = centipede::ProgressIndicator{}; std::size_t total_read{}; for ([[maybe_unused]] const auto& entry : - reader | progress_adaptor(reader.get_file_size(), [&reader]() { return reader.get_last_entry_bytes(); })) + reader | + progress_indicator.adaptor(reader.get_file_size(), [&reader]() { return reader.get_last_entry_bytes(); })) { total_read += reader.get_last_entry_bytes(); } @@ -66,34 +55,34 @@ auto main() -> int return EXIT_FAILURE; } - if (const auto progress_adaptor_status = progress_adaptor.get_status(); - progress_adaptor_status != centipede::ErrorCode::success) - { - std::println(stderr, "Error: {}", progress_adaptor_status); - return EXIT_FAILURE; - } - - auto array = std::array{ 1, 2, 3, 4 }; - - auto progress_view = array | centipede::progress::ProgressAdaptor{}; - - for ([[maybe_unused]] auto elem : progress_view) - { - } - - if (const auto progress_view_status = progress_view.get_status(); - progress_view_status != centipede::ErrorCode::success) - { - std::println(stderr, "Error: {}", progress_view_status); - return EXIT_FAILURE; - } - - if (const auto progress_adaptor_status = progress_adaptor.get_status(); - progress_adaptor_status != centipede::ErrorCode::success) - { - std::println(stderr, "Error: {}", progress_adaptor_status); - return EXIT_FAILURE; - } + // if (const auto progress_adaptor_status = progress_adaptor.get_status(); + // progress_adaptor_status != centipede::ErrorCode::success) + // { + // std::println(stderr, "Error: {}", progress_adaptor_status); + // return EXIT_FAILURE; + // } + // + // auto array = std::array{ 1, 2, 3, 4 }; + // + // auto progress_view = array | centipede::progress::ProgressAdaptor{}; + // + // for ([[maybe_unused]] auto elem : progress_view) + // { + // } + // + // if (const auto progress_view_status = progress_view.get_status(); + // progress_view_status != centipede::ErrorCode::success) + // { + // std::println(stderr, "Error: {}", progress_view_status); + // return EXIT_FAILURE; + // } + // + // if (const auto progress_adaptor_status = progress_adaptor.get_status(); + // progress_adaptor_status != centipede::ErrorCode::success) + // { + // std::println(stderr, "Error: {}", progress_adaptor_status); + // return EXIT_FAILURE; + // } return EXIT_SUCCESS; } From 013d8cbc814aee8af6cb9c16b91717d83a1d6fed Mon Sep 17 00:00:00 2001 From: Baryonics Date: Sun, 16 Aug 2026 13:45:00 +0200 Subject: [PATCH 31/37] Removed public member adaptor and replaced with a getter --- source/centipede/util/progress_indicator.hpp | 16 +++++++++++----- test/integration_tests/test_reader.cpp | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 055209f4..7bebfd98 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -44,8 +44,16 @@ namespace centipede ProgressIndicator(const ProgressIndicator&) = delete; ProgressIndicator& operator=(const ProgressIndicator&) = delete; - // auto adaptor() & { return ProgressAdaptor{ this }; } - // auto adaptor() && = delete; + auto get_adaptor() & { return adaptor_; } + + template + auto get_adaptor(Args&&... args) & + { + return adaptor_(std::forward(args)...); + } + + template + auto get_adaptor(Args&&...) && = delete; private: template @@ -260,9 +268,7 @@ namespace centipede indicators::option::FontStyles{ std::vector{ indicators::FontStyle::bold } } }; ErrorCode status_{}; - - public: - ProgressAdaptor adaptor{ this }; + ProgressAdaptor adaptor_{ this }; }; } // namespace centipede diff --git a/test/integration_tests/test_reader.cpp b/test/integration_tests/test_reader.cpp index 2d89c3e2..026a4d9f 100644 --- a/test/integration_tests/test_reader.cpp +++ b/test/integration_tests/test_reader.cpp @@ -28,8 +28,8 @@ auto main() -> int std::size_t total_read{}; for ([[maybe_unused]] const auto& entry : - reader | - progress_indicator.adaptor(reader.get_file_size(), [&reader]() { return reader.get_last_entry_bytes(); })) + reader | progress_indicator.get_adaptor(reader.get_file_size(), + [&reader]() { return reader.get_last_entry_bytes(); })) { total_read += reader.get_last_entry_bytes(); } From cdb24727db8d465cbcc447a9751449cd95a9c123 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Sun, 16 Aug 2026 14:31:16 +0200 Subject: [PATCH 32/37] Fixing address sanitizer errors --- source/centipede/util/progress_indicator.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 7bebfd98..6e0245a4 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -98,8 +98,8 @@ namespace centipede public: Iterator(ProgressView* progress_view, IteratorType current_it, SentinelType end_it) : progress_view_(progress_view) - , current_it_(std::move(current_it)) - , end_it_(std::move(end_it)) + , current_it_(current_it) + , end_it_(end_it) { assert(progress_view_); assert(progress_view_->progress_indicator); From 7b0576f356deb03736d290a9ccf1cfdc5ac32ccb Mon Sep 17 00:00:00 2001 From: Baryonics Date: Sun, 16 Aug 2026 14:46:33 +0200 Subject: [PATCH 33/37] Testing --- source/centipede/util/progress_indicator.hpp | 27 ++++++++++---------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 6e0245a4..88d8767b 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -254,19 +254,20 @@ namespace centipede }; Config config_{}; - indicators::ProgressBar bar_{ indicators::option::BarWidth{ config_.bar_width }, - indicators::option::Start{ " [" }, - indicators::option::Fill{ "█" }, - indicators::option::Lead{ "█" }, - indicators::option::Remainder{ "-" }, - indicators::option::End{ "]" }, - indicators::option::PrefixText{ config_.label_text }, - indicators::option::ForegroundColor{ indicators::Color::yellow }, - indicators::option::ShowPercentage{ true }, - indicators::option::ShowElapsedTime{ true }, - indicators::option::ShowRemainingTime{ true }, - indicators::option::FontStyles{ - std::vector{ indicators::FontStyle::bold } } }; + indicators::ProgressBar bar_{}; + // indicators::ProgressBar bar_{ indicators::option::BarWidth{ config_.bar_width }, + // indicators::option::Start{ " [" }, + // indicators::option::Fill{ "█" }, + // indicators::option::Lead{ "█" }, + // indicators::option::Remainder{ "-" }, + // indicators::option::End{ "]" }, + // indicators::option::PrefixText{ config_.label_text }, + // indicators::option::ForegroundColor{ indicators::Color::yellow }, + // indicators::option::ShowPercentage{ true }, + // indicators::option::ShowElapsedTime{ true }, + // indicators::option::ShowRemainingTime{ true }, + // indicators::option::FontStyles{ + // std::vector{ indicators::FontStyle::bold } } }; ErrorCode status_{}; ProgressAdaptor adaptor_{ this }; }; From bc1d12fc20c324cdfffc5ea881114feb7c32d766 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Sun, 16 Aug 2026 17:55:36 +0200 Subject: [PATCH 34/37] Testing --- source/centipede/util/progress_indicator.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 88d8767b..717f027c 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -254,7 +254,7 @@ namespace centipede }; Config config_{}; - indicators::ProgressBar bar_{}; + indicators::ProgressBar bar_{ indicators::option::BarWidth{ config_.bar_width } }; // indicators::ProgressBar bar_{ indicators::option::BarWidth{ config_.bar_width }, // indicators::option::Start{ " [" }, // indicators::option::Fill{ "█" }, From 49f63bab7f5d689e059f551ec2fde83f88a4d014 Mon Sep 17 00:00:00 2001 From: Baryonics Date: Sun, 16 Aug 2026 17:58:38 +0200 Subject: [PATCH 35/37] testing. pleasing the sanitizers --- source/centipede/util/progress_indicator.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 717f027c..8561180a 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -254,7 +254,13 @@ namespace centipede }; Config config_{}; - indicators::ProgressBar bar_{ indicators::option::BarWidth{ config_.bar_width } }; + indicators::ProgressBar bar_{ + indicators::option::BarWidth{ config_.bar_width }, + indicators::option::Start{ " [" }, + indicators::option::Fill{ "█" }, + indicators::option::Lead{ "█" }, + + }; // indicators::ProgressBar bar_{ indicators::option::BarWidth{ config_.bar_width }, // indicators::option::Start{ " [" }, // indicators::option::Fill{ "█" }, From 48bb54b7916d647251494a9a1e5a48dc1679b02e Mon Sep 17 00:00:00 2001 From: Baryonics Date: Sun, 16 Aug 2026 18:01:14 +0200 Subject: [PATCH 36/37] all hail the memory sanatizer --- source/centipede/util/progress_indicator.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 8561180a..765a02c4 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -257,8 +257,8 @@ namespace centipede indicators::ProgressBar bar_{ indicators::option::BarWidth{ config_.bar_width }, indicators::option::Start{ " [" }, - indicators::option::Fill{ "█" }, - indicators::option::Lead{ "█" }, + indicators::option::Fill{ "=" }, + indicators::option::Lead{ ">" }, }; // indicators::ProgressBar bar_{ indicators::option::BarWidth{ config_.bar_width }, From 8915af7af4e6d3099cdd6285c9fd710176f3d87d Mon Sep 17 00:00:00 2001 From: Baryonics Date: Sun, 16 Aug 2026 18:27:32 +0200 Subject: [PATCH 37/37] Unfortunately we can only use ASCII? --- source/centipede/util/progress_indicator.hpp | 32 ++++++++------------ 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/source/centipede/util/progress_indicator.hpp b/source/centipede/util/progress_indicator.hpp index 765a02c4..25dd4a91 100644 --- a/source/centipede/util/progress_indicator.hpp +++ b/source/centipede/util/progress_indicator.hpp @@ -254,26 +254,20 @@ namespace centipede }; Config config_{}; - indicators::ProgressBar bar_{ - indicators::option::BarWidth{ config_.bar_width }, - indicators::option::Start{ " [" }, - indicators::option::Fill{ "=" }, - indicators::option::Lead{ ">" }, - }; - // indicators::ProgressBar bar_{ indicators::option::BarWidth{ config_.bar_width }, - // indicators::option::Start{ " [" }, - // indicators::option::Fill{ "█" }, - // indicators::option::Lead{ "█" }, - // indicators::option::Remainder{ "-" }, - // indicators::option::End{ "]" }, - // indicators::option::PrefixText{ config_.label_text }, - // indicators::option::ForegroundColor{ indicators::Color::yellow }, - // indicators::option::ShowPercentage{ true }, - // indicators::option::ShowElapsedTime{ true }, - // indicators::option::ShowRemainingTime{ true }, - // indicators::option::FontStyles{ - // std::vector{ indicators::FontStyle::bold } } }; + indicators::ProgressBar bar_{ indicators::option::BarWidth{ config_.bar_width }, + indicators::option::Start{ " [" }, + indicators::option::Fill{ "=" }, + indicators::option::Lead{ ">" }, + indicators::option::Remainder{ "-" }, + indicators::option::End{ "]" }, + indicators::option::PrefixText{ config_.label_text }, + indicators::option::ForegroundColor{ indicators::Color::yellow }, + indicators::option::ShowPercentage{ true }, + indicators::option::ShowElapsedTime{ true }, + indicators::option::ShowRemainingTime{ true }, + indicators::option::FontStyles{ + std::vector{ indicators::FontStyle::bold } } }; ErrorCode status_{}; ProgressAdaptor adaptor_{ this }; };