diff --git a/dir_595f0268ff83821d3439fdccc6c5e3fd.html b/dir_595f0268ff83821d3439fdccc6c5e3fd.html index 652bc113..abbfad98 100644 --- a/dir_595f0268ff83821d3439fdccc6c5e3fd.html +++ b/dir_595f0268ff83821d3439fdccc6c5e3fd.html @@ -113,6 +113,8 @@   file  playlistorder.hpp [code]   +file  position.hpp [code] +  file  repeatstate.hpp [code]   file  resizemode.hpp [code] diff --git a/enums_8hpp_source.html b/enums_8hpp_source.html index 832ae834..a34ce184 100644 --- a/enums_8hpp_source.html +++ b/enums_8hpp_source.html @@ -83,263 +83,319 @@
3#include "lib/enum/mediatype.hpp"
4#include "lib/enum/devicetype.hpp"
5#include "lib/enum/playeraction.hpp"
-
6
-
7#include <string>
-
8
-
9namespace lib
-
10{
-
15 template<typename T>
-
16 class enums
-
17 {
-
18 public:
-
19 static auto to_string(T value) -> std::string
-
20 {
-
21 std::string str;
-
22 enum_to_string(value, str);
-
23 return str;
-
24 }
-
25
-
26 static auto parse(const std::string &str) -> T
-
27 {
-
28 T value;
-
29 enum_from_string(str, value);
-
30 return value;
-
31 }
-
32
-
39 static auto has_flag(T value, T flag) -> bool
-
40 {
-
41 const auto valueFlag = static_cast<unsigned int>(value);
-
42 const auto flagFlag = static_cast<unsigned int>(flag);
-
43 return (valueFlag & flagFlag) == flagFlag;
-
44 }
-
45
-
46 private:
-
47 // region media_type
-
48
-
49 static void enum_to_string(media_type media_type, std::string &str)
-
50 {
-
51 switch (media_type)
-
52 {
-
53 case media_type::unknown:
-
54 str = "unknown";
-
55 break;
-
56
-
57 case media_type::audio:
-
58 str = "audio";
-
59 break;
-
60 }
-
61 }
-
62
-
63 static void enum_from_string(const std::string &str, media_type &media_type)
-
64 {
-
65 if (str == "audio")
-
66 {
-
67 media_type = media_type::audio;
-
68 return;
-
69 }
-
70
-
71 media_type = media_type::unknown;
-
72 }
-
73
-
74 //endregion
-
75
-
76 //region device_type
-
77
-
78 static void enum_to_string(device_type device_type, std::string &str)
-
79 {
-
80 switch (device_type)
-
81 {
-
82 case device_type::unknown:
-
83 str = "unknown";
-
84 break;
-
85
-
86 case device_type::computer:
-
87 str = "computer";
-
88 break;
-
89
-
90 case device_type::tablet:
-
91 str = "tablet";
-
92 break;
-
93
-
94 case device_type::smartphone:
-
95 str = "smartphone";
-
96 break;
-
97
-
98 case device_type::speaker:
-
99 str = "speaker";
-
100 break;
-
101
-
102 case device_type::tv:
-
103 str = "tv";
-
104 break;
-
105
-
106 case device_type::avr:
-
107 str = "avr";
-
108 break;
-
109
-
110 case device_type::stb:
-
111 str = "stb";
-
112 break;
-
113
-
114 case device_type::audio_dongle:
-
115 str = "audio dongle";
-
116 break;
-
117
-
118 case device_type::game_console:
-
119 str = "game console";
-
120 break;
-
121
-
122 case device_type::cast_audio:
-
123 str = "cast audio";
-
124 break;
-
125
-
126 case device_type::cast_video:
-
127 str = "cast video";
-
128 break;
-
129
-
130 case device_type::automobile:
-
131 str = "automobile";
-
132 break;
-
133
-
134 case device_type::smartwatch:
-
135 str = "smartwatch";
-
136 break;
-
137
-
138 case device_type::chromebook:
-
139 str = "chromebook";
-
140 break;
-
141
-
142 case device_type::unknown_spotify:
-
143 str = "unknown spotify";
-
144 break;
-
145
-
146 case device_type::car_thing:
-
147 str = "car thing";
-
148 break;
-
149
-
150 case device_type::observer:
-
151 str = "observer";
-
152 break;
-
153
-
154 case device_type::home_thing:
-
155 str = "home thing";
-
156 break;
-
157 }
-
158 }
-
159
-
160 static void enum_from_string(const std::string &/*str*/, device_type &device_type)
-
161 {
-
162 // TODO: Not implemented yet
-
163 device_type = device_type::unknown;
-
164 }
-
165
-
166 //endregion
-
167
-
168 //region player_action
-
169
-
170 static void enum_to_string(player_action player_action, std::string &str)
-
171 {
-
172 switch (player_action)
-
173 {
-
174 case player_action::interrupting_playback:
-
175 str = "interrupting_playback";
-
176 break;
-
177
-
178 case player_action::pausing:
-
179 str = "pausing";
-
180 break;
-
181
-
182 case player_action::resuming:
-
183 str = "resuming";
-
184 break;
-
185
-
186 case player_action::seeking:
-
187 str = "seeking";
-
188 break;
-
189
-
190 case player_action::skipping_next:
-
191 str = "skipping_next";
-
192 break;
-
193
-
194 case player_action::skipping_prev:
-
195 str = "skipping_prev";
-
196 break;
-
197
-
198 case player_action::toggling_repeat_context:
-
199 str = "toggling_repeat_context";
-
200 break;
-
201
-
202 case player_action::toggling_shuffle:
-
203 str = "toggling_shuffle";
-
204 break;
-
205
-
206 case player_action::toggling_repeat_track:
-
207 str = "toggling_repeat_track";
-
208 break;
-
209
-
210 case player_action::transferring_playback:
-
211 str = "transferring_playback";
-
212 break;
-
213
-
214 case player_action::unknown:
-
215 str = "unknown";
-
216 break;
-
217 }
-
218 }
-
219
-
220 static void enum_from_string(const std::string &str, player_action &player_action)
-
221 {
-
222 if (str == "interrupting_playback")
-
223 {
-
224 player_action = player_action::interrupting_playback;
-
225 }
-
226 else if (str == "pausing")
-
227 {
-
228 player_action = player_action::pausing;
-
229 }
-
230 else if (str == "resuming")
-
231 {
-
232 player_action = player_action::resuming;
-
233 }
-
234 else if (str == "seeking")
-
235 {
-
236 player_action = player_action::seeking;
-
237 }
-
238 else if (str == "skipping_next")
-
239 {
-
240 player_action = player_action::skipping_next;
-
241 }
-
242 else if (str == "skipping_prev")
-
243 {
-
244 player_action = player_action::skipping_prev;
-
245 }
-
246 else if (str == "toggling_repeat_context")
-
247 {
-
248 player_action = player_action::toggling_repeat_context;
-
249 }
-
250 else if (str == "toggling_shuffle")
-
251 {
-
252 player_action = player_action::toggling_shuffle;
-
253 }
-
254 else if (str == "toggling_repeat_track")
-
255 {
-
256 player_action = player_action::toggling_repeat_track;
-
257 }
-
258 else if (str == "transferring_playback")
-
259 {
-
260 player_action = player_action::transferring_playback;
-
261 }
-
262 else
-
263 {
-
264 player_action = player_action::unknown;
-
265 }
-
266 }
-
267
-
268 //endregion
-
269 };
-
270}
-
lib::enums
Definition: enums.hpp:17
-
lib::enums::has_flag
static auto has_flag(T value, T flag) -> bool
Definition: enums.hpp:39
+
6#include "lib/enum/position.hpp"
+
7
+
8#include <string>
+
9
+
10namespace lib
+
11{
+
16 template<typename T>
+
17 class enums
+
18 {
+
19 public:
+
20 static auto to_string(T value) -> std::string
+
21 {
+
22 std::string str;
+
23 enum_to_string(value, str);
+
24 return str;
+
25 }
+
26
+
27 static auto parse(const std::string &str) -> T
+
28 {
+
29 T value;
+
30 enum_from_string(str, value);
+
31 return value;
+
32 }
+
33
+
40 static auto has_flag(T value, T flag) -> bool
+
41 {
+
42 const auto valueFlag = static_cast<unsigned int>(value);
+
43 const auto flagFlag = static_cast<unsigned int>(flag);
+
44 return (valueFlag & flagFlag) == flagFlag;
+
45 }
+
46
+
47 private:
+
48 // region media_type
+
49
+
50 static void enum_to_string(media_type media_type, std::string &str)
+
51 {
+
52 switch (media_type)
+
53 {
+
54 case media_type::unknown:
+
55 str = "unknown";
+
56 break;
+
57
+
58 case media_type::audio:
+
59 str = "audio";
+
60 break;
+
61 }
+
62 }
+
63
+
64 static void enum_from_string(const std::string &str, media_type &media_type)
+
65 {
+
66 if (str == "audio")
+
67 {
+
68 media_type = media_type::audio;
+
69 return;
+
70 }
+
71
+
72 media_type = media_type::unknown;
+
73 }
+
74
+
75 //endregion
+
76
+
77 //region device_type
+
78
+
79 static void enum_to_string(device_type device_type, std::string &str)
+
80 {
+
81 switch (device_type)
+
82 {
+
83 case device_type::unknown:
+
84 str = "unknown";
+
85 break;
+
86
+
87 case device_type::computer:
+
88 str = "computer";
+
89 break;
+
90
+
91 case device_type::tablet:
+
92 str = "tablet";
+
93 break;
+
94
+
95 case device_type::smartphone:
+
96 str = "smartphone";
+
97 break;
+
98
+
99 case device_type::speaker:
+
100 str = "speaker";
+
101 break;
+
102
+
103 case device_type::tv:
+
104 str = "tv";
+
105 break;
+
106
+
107 case device_type::avr:
+
108 str = "avr";
+
109 break;
+
110
+
111 case device_type::stb:
+
112 str = "stb";
+
113 break;
+
114
+
115 case device_type::audio_dongle:
+
116 str = "audio dongle";
+
117 break;
+
118
+
119 case device_type::game_console:
+
120 str = "game console";
+
121 break;
+
122
+
123 case device_type::cast_audio:
+
124 str = "cast audio";
+
125 break;
+
126
+
127 case device_type::cast_video:
+
128 str = "cast video";
+
129 break;
+
130
+
131 case device_type::automobile:
+
132 str = "automobile";
+
133 break;
+
134
+
135 case device_type::smartwatch:
+
136 str = "smartwatch";
+
137 break;
+
138
+
139 case device_type::chromebook:
+
140 str = "chromebook";
+
141 break;
+
142
+
143 case device_type::unknown_spotify:
+
144 str = "unknown spotify";
+
145 break;
+
146
+
147 case device_type::car_thing:
+
148 str = "car thing";
+
149 break;
+
150
+
151 case device_type::observer:
+
152 str = "observer";
+
153 break;
+
154
+
155 case device_type::home_thing:
+
156 str = "home thing";
+
157 break;
+
158 }
+
159 }
+
160
+
161 static void enum_from_string(const std::string &/*str*/, device_type &device_type)
+
162 {
+
163 // TODO: Not implemented yet
+
164 device_type = device_type::unknown;
+
165 }
+
166
+
167 //endregion
+
168
+
169 //region player_action
+
170
+
171 static void enum_to_string(player_action player_action, std::string &str)
+
172 {
+
173 switch (player_action)
+
174 {
+
175 case player_action::interrupting_playback:
+
176 str = "interrupting_playback";
+
177 break;
+
178
+
179 case player_action::pausing:
+
180 str = "pausing";
+
181 break;
+
182
+
183 case player_action::resuming:
+
184 str = "resuming";
+
185 break;
+
186
+
187 case player_action::seeking:
+
188 str = "seeking";
+
189 break;
+
190
+
191 case player_action::skipping_next:
+
192 str = "skipping_next";
+
193 break;
+
194
+
195 case player_action::skipping_prev:
+
196 str = "skipping_prev";
+
197 break;
+
198
+
199 case player_action::toggling_repeat_context:
+
200 str = "toggling_repeat_context";
+
201 break;
+
202
+
203 case player_action::toggling_shuffle:
+
204 str = "toggling_shuffle";
+
205 break;
+
206
+
207 case player_action::toggling_repeat_track:
+
208 str = "toggling_repeat_track";
+
209 break;
+
210
+
211 case player_action::transferring_playback:
+
212 str = "transferring_playback";
+
213 break;
+
214
+
215 case player_action::unknown:
+
216 str = "unknown";
+
217 break;
+
218 }
+
219 }
+
220
+
221 static void enum_from_string(const std::string &str, player_action &player_action)
+
222 {
+
223 if (str == "interrupting_playback")
+
224 {
+
225 player_action = player_action::interrupting_playback;
+
226 }
+
227 else if (str == "pausing")
+
228 {
+
229 player_action = player_action::pausing;
+
230 }
+
231 else if (str == "resuming")
+
232 {
+
233 player_action = player_action::resuming;
+
234 }
+
235 else if (str == "seeking")
+
236 {
+
237 player_action = player_action::seeking;
+
238 }
+
239 else if (str == "skipping_next")
+
240 {
+
241 player_action = player_action::skipping_next;
+
242 }
+
243 else if (str == "skipping_prev")
+
244 {
+
245 player_action = player_action::skipping_prev;
+
246 }
+
247 else if (str == "toggling_repeat_context")
+
248 {
+
249 player_action = player_action::toggling_repeat_context;
+
250 }
+
251 else if (str == "toggling_shuffle")
+
252 {
+
253 player_action = player_action::toggling_shuffle;
+
254 }
+
255 else if (str == "toggling_repeat_track")
+
256 {
+
257 player_action = player_action::toggling_repeat_track;
+
258 }
+
259 else if (str == "transferring_playback")
+
260 {
+
261 player_action = player_action::transferring_playback;
+
262 }
+
263 else
+
264 {
+
265 player_action = player_action::unknown;
+
266 }
+
267 }
+
268
+
269 //endregion
+
270
+
271 //region position
+
272
+
273 static void enum_to_string(position position, std::string &str)
+
274 {
+
275 switch (position)
+
276 {
+
277
+
278 case position::none:
+
279 str = "none";
+
280 break;
+
281
+
282 case position::top:
+
283 str = "top";
+
284 break;
+
285
+
286 case position::right:
+
287 str = "right";
+
288 break;
+
289
+
290 case position::bottom:
+
291 str = "bottom";
+
292 break;
+
293
+
294 case position::left:
+
295 str = "left";
+
296 break;
+
297 }
+
298 }
+
299
+
300 static void enum_from_string(const std::string &str, position &position)
+
301 {
+
302 if (str == "top")
+
303 {
+
304 position = position::top;
+
305 }
+
306 else if (str == "right")
+
307 {
+
308 position = position::right;
+
309 }
+
310 else if (str == "bottom")
+
311 {
+
312 position = position::bottom;
+
313 }
+
314 else if (str == "left")
+
315 {
+
316 position = position::left;
+
317 }
+
318 else
+
319 {
+
320 position = position::none;
+
321 }
+
322 }
+
323
+
324 //endregion
+
325 };
+
326}
+
lib::enums
Definition: enums.hpp:18
+
lib::enums::has_flag
static auto has_flag(T value, T flag) -> bool
Definition: enums.hpp:40