diff options
author | Adrian Kummerlaender | 2016-03-29 20:47:27 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2016-03-29 20:47:27 +0200 |
commit | ce9d2ca31e07679292f0a0378792050756d6ab26 (patch) | |
tree | 58e7fc46588e90b0cf30ce367e8470f6eecbdccb /src/line_accumulator.h | |
parent | 26101aeb8ea28bd180b30fc67cba81baadbba8ee (diff) | |
download | justify-ce9d2ca31e07679292f0a0378792050756d6ab26.tar justify-ce9d2ca31e07679292f0a0378792050756d6ab26.tar.gz justify-ce9d2ca31e07679292f0a0378792050756d6ab26.tar.bz2 justify-ce9d2ca31e07679292f0a0378792050756d6ab26.tar.lz justify-ce9d2ca31e07679292f0a0378792050756d6ab26.tar.xz justify-ce9d2ca31e07679292f0a0378792050756d6ab26.tar.zst justify-ce9d2ca31e07679292f0a0378792050756d6ab26.zip |
Move `LineAccumulator` into separate compilation unit
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); + +}; + |