aboutsummaryrefslogtreecommitdiff
path: root/src/line_accumulator.h
blob: db75c8c2d0df94400d55f7d6c19a0bb5e6954815 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once

#include <tuple>
#include <string>
#include <vector>
#include <random>

namespace justify {

class LineAccumulator {
	public:
		LineAccumulator(
			const std::uint8_t  max_length,
			const std::uint8_t  offset,
			const std::uint32_t seed
		);
		~LineAccumulator();

		void operator()(const std::string& token);

	private:
		const std::uint8_t max_length_;
		const std::uint8_t offset_;

		std::mt19937 generator_;
		std::uint8_t length_;

		std::vector<
			std::pair<std::string, std::uint8_t>
		> tokens_;

		std::uint8_t getMissing() const;

		void justify();
		void discharge(const bool full);

};

}