Maze Builder Docs 6.0.1
Loading...
Searching...
No Matches
enums.h
Go to the documentation of this file.
1#ifndef ENUMS
2#define ENUMS
3
4#include <string>
5#include <stdexcept>
6
9
10namespace mazes {
11
13 static constexpr auto BARRIER1 = '|';
14 static constexpr auto BARRIER2 = '-';
15 static constexpr auto CORNER = '+';
16
18 enum class output : unsigned int {
19 PLAIN_TEXT = 0,
20 JSON = 1,
21 WAVEFRONT_OBJECT_FILE = 2,
22 PNG = 3,
23 JPEG = 4,
24 STDOUT = 5,
25 TOTAL = 6
26 };
27
31 static std::string to_string_from_outputs(output o) {
32 switch (o) {
33 case output::PLAIN_TEXT:
34 return "txt";
35 case output::JSON:
36 return "json";
37 case output::WAVEFRONT_OBJECT_FILE:
38 return "obj";
39 case output::PNG:
40 return "png";
41 case output::JPEG:
42 return "jpeg";
43 case output::STDOUT:
44 return "stdout";
45 default:
46 throw std::invalid_argument("Invalid output: " + std::to_string(static_cast<unsigned int>(o)));
47 }
48 };
49
53 static output to_output_from_string(const std::string& o) {
54 if (o.compare("txt") == 0) {
55 return output::PLAIN_TEXT;
56 } else if (o.compare("text") == 0) {
57 return output::PLAIN_TEXT;
58 } else if (o.compare("json") == 0) {
59 return output::JSON;
60 } else if (o.compare("obj") == 0) {
61 return output::WAVEFRONT_OBJECT_FILE;
62 } else if (o.compare("object") == 0) {
63 return output::WAVEFRONT_OBJECT_FILE;
64 } else if (o.compare("png") == 0) {
65 return output::PNG;
66 } else if (o.compare("jpeg") == 0) {
67 return output::JPEG;
68 } else if (o.compare("jpg") == 0) {
69 return output::JPEG;
70 } else if (o.compare("stdout") == 0) {
71 return output::STDOUT;
72 } else {
73 throw std::invalid_argument("Invalid output: " + o);
74 }
75 };
76
78 enum class algo : unsigned int {
79 BINARY_TREE = 0,
80 SIDEWINDER = 1,
81 DFS = 2,
82 TOTAL = 3
83 };
84
88 static std::string to_string_from_algo(algo a) {
89 switch (a) {
90 case algo::BINARY_TREE:
91 return "binary_tree";
92 case algo::SIDEWINDER:
93 return "sidewinder";
94 case algo::DFS:
95 return "dfs";
96 default:
97 throw std::invalid_argument("Invalid algo: " + std::to_string(static_cast<unsigned int>(a)));
98 }
99 };
100
104 static algo to_algo_from_string(const std::string& a) {
105 if (a.compare("binary_tree") == 0) {
106 return algo::BINARY_TREE;
107 } else if (a.compare("sidewinder") == 0) {
108 return algo::SIDEWINDER;
109 } else if (a.compare("dfs") == 0) {
110 return algo::DFS;
111 } else {
112 throw std::invalid_argument("Invalid algo: " + a);
113 }
114 };
115} // namespace
116
117#endif // ENUMS
Namespace for the maze builder.
Definition algo_interface.h:9
output
Enum class for output types.
Definition enums.h:18
algo
Enum class for maze types by the generating algorithm.
Definition enums.h:78