diff options
Diffstat (limited to 'src/line_accumulator.h')
-rw-r--r-- | src/line_accumulator.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/line_accumulator.h b/src/line_accumulator.h new file mode 100644 index 0000000..ea813a9 --- /dev/null +++ b/src/line_accumulator.h @@ -0,0 +1,32 @@ +#pragma once + +#include <string> +#include <vector> + +#include "random.h" + +class LineAccumulator { + public: + LineAccumulator(const std::size_t max_length); + ~LineAccumulator(); + + void operator()(const std::string& word); + + private: + const std::size_t max_length_; + + utility::Random random_; + std::size_t length_; + std::vector<std::string> tokens_; + std::vector<std::size_t> spaces_; + + void add_token(const std::string& token); + void add_space(); + + void increase_space_at(const std::size_t index); + void pop_trailing_token(); + + void discharge(const bool full); + +}; + |