aboutsummaryrefslogtreecommitdiff
path: root/src/line_accumulator.h
blob: cb072104ea32612cf63bbe46b5baa8151f446a10 (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
#pragma once

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

namespace justify {

class LineAccumulator {
	public:
		LineAccumulator(const std::uint8_t max_length);
		~LineAccumulator();

		std::uint8_t getMissing() const;

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

	private:
		const std::uint8_t max_length_;

		std::random_device device_;
		std::mt19937       random_;
		std::uint8_t       length_;

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

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

};

}