From ce9d2ca31e07679292f0a0378792050756d6ab26 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 29 Mar 2016 20:47:27 +0200 Subject: Move `LineAccumulator` into separate compilation unit --- src/line_accumulator.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/line_accumulator.h (limited to 'src/line_accumulator.h') 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 +#include + +#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 tokens_; + std::vector 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); + +}; + -- cgit v1.2.3