Repository navigation
Expand file tree
/
Copy pathtraits.cpp
More file actions
126 lines (100 loc) · 2.75 KB
/
Copy pathtraits.cpp
File metadata and controls
126 lines (100 loc) · 2.75 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include "bl.hpp"
#include <stdexcept>
#define T true
#define F false
#define X(enum_, ...) case e##enum_: return {__VA_ARGS__};
bl::block_name_traits bl::block_name_traits::doit(bl::block_name name) {
using enum bl::block_name;
switch (name) {
#include "block_name_db.txt"
}
throw std::invalid_argument("invalid enum");
}
bl::material_traits bl::material_traits::doit(material mat) {
using enum bl::material;
switch (mat) {
#include "material_db.txt"
}
throw std::invalid_argument("invalid enum");
}
bl::delay_interval_traits
bl::delay_interval_traits::doit(delay_interval interval) {
using enum bl::delay_interval;
switch (interval) {
#include "delay_interval_db.txt"
}
throw std::invalid_argument("invalid enum");
}
bl::timer_interval_traits
bl::timer_interval_traits::doit(timer_interval interval) {
using enum bl::timer_interval;
switch (interval) {
#include "timer_interval_db.txt"
}
throw std::invalid_argument("invalid enum");
}
bl::detection_shape_traits
bl::detection_shape_traits::doit(detection_shape shape) {
using enum bl::detection_shape;
switch (shape) {
#include "detection_shape_db.txt"
}
throw std::invalid_argument("invalid enum");
}
#undef X
bl::block_name bl::decode_block_name(std::string_view v) {
using enum bl::block_name;
static std::unordered_map<std::string, bl::block_name> map{
#define X(enum_, name_, enc_, id_, comp_) {enc_, e##enum_},
#include "block_name_db.txt"
#undef X
};
return map.at(std::string(v));
}
bl::block_name bl::block_name_from_block_id(std::size_t v) {
using enum bl::block_name;
static std::unordered_map<std::size_t, bl::block_name> map{
#define X(enum_, name_, enc_, id_, comp_) {id_, e##enum_},
#include "block_name_db.txt"
#undef X
};
return map.at(v);
}
bl::material bl::decode_material(char v) {
using enum bl::material;
static std::unordered_map<char, bl::material> map{
#define X(enum_, name_, enc_) {enc_, e##enum_},
#include "material_db.txt"
#undef X
};
return map.at(v);
}
bl::delay_interval bl::decode_delay_interval(char v) {
using enum bl::delay_interval;
static std::unordered_map<char, bl::delay_interval> map{
#define X(enum_, name_, enc_) {enc_, e##enum_},
#include "delay_interval_db.txt"
#undef X
};
return map.at(v);
}
bl::timer_interval bl::decode_timer_interval(char v) {
using enum bl::timer_interval;
static std::unordered_map<char, bl::timer_interval> map{
#define X(enum_, name_, enc_) {enc_, e##enum_},
#include "timer_interval_db.txt"
#undef X
};
return map.at(v);
}
bl::detection_shape bl::decode_detection_shape(std::size_t v) {
using enum bl::detection_shape;
static std::unordered_map<std::size_t, bl::detection_shape> map{
#define X(enum_, name_, enc_) {enc_, e##enum_},
#include "detection_shape_db.txt"
#undef X
};
return map.at(v);
}
#undef T
#undef F