aboutsummaryrefslogtreecommitdiff
path: root/src/engine/graphics/string_matrix.hpp
blob: 40fbb1125488c9c19f5b4e94978e95f1ee513df9 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once

#include "interfaces/matrix.hpp"

#include "engine/data/bounds.hpp"
#include "engine/data/vector2.hpp"

#include <string_view>
#include <vector>

/**
 * A Matrix.
 */
class StringMatrix : public IMatrix<std::string_view>
{
public:
	/**
	 * Creates a matrix.
	 *
	 * @param bounds The bounds of the matrix
	 */
	explicit StringMatrix(const Bounds &bounds) noexcept;

	/**
	 * Fills the matrix with a element.
	 *
	 * @param element A element
	 */
	void fill(std::string_view element) noexcept override;

	/**
	 * Returns a element of the matrix.
	 *
	 * @param pos The position of a element
	 */
	[[nodiscard]] std::string_view get(const Vector2 &pos) const noexcept override;

	/**
	 * Sets a element of the matrix.
	 *
	 * @param pos The position of a element
	 * @param element A new element
	 */
	void set(const Vector2 &pos, std::string_view element) noexcept override;

	/**
	 * Returns the number of rows the matrix has.
	 */
	[[nodiscard]] uint32_t rows() const noexcept override;

	/**
	 * Returns the number of columns the matrix has.
	 */
	[[nodiscard]] uint32_t columns() const noexcept override;

private:
	std::vector<std::vector<std::string_view>> _matrix;

	uint32_t _rows;
	uint32_t _columns;
};