scifir-units 2.0.0
scifir-units is a library of units of measurement, angles, coordinates, fields, and related data, all lightweight, that help in the development of scientific software and scientific machines
Loading...
Searching...
No Matches
direction.cpp
Go to the documentation of this file.
1#include "./direction.hpp"
2
3#include "boost/algorithm/string.hpp"
4
5#include <sstream>
6
7using namespace std;
8
9namespace scifir
10{
13
15 {}
16
17 direction::direction(direction&& x) : direction(std::move(x.value))
18 {}
19
22
25
27 {
28 value = x.value;
29 return *this;
30 }
31
33 {
34 value = std::move(x.value);
35 return *this;
36 }
37
43
45 {
47 return *this;
48 }
49
54
56 {
57 if (x == "left")
58 {
59 return direction::LEFT;
60 }
61 else if (x == "right")
62 {
63 return direction::RIGHT;
64 }
65 else if (x == "top")
66 {
67 return direction::TOP;
68 }
69 else if (x == "bottom")
70 {
71 return direction::BOTTOM;
72 }
73 else if (x == "front")
74 {
75 return direction::FRONT;
76 }
77 else if (x == "back")
78 {
79 return direction::BACK;
80 }
81 else if (x == "left-top")
82 {
84 }
85 else if (x == "left-bottom")
86 {
88 }
89 else if (x == "right-top")
90 {
92 }
93 else if (x == "right-bottom")
94 {
96 }
97 else if (x == "left-front")
98 {
100 }
101 else if (x == "left-back")
102 {
104 }
105 else if (x == "right-front")
106 {
108 }
109 else if (x == "right-back")
110 {
112 }
113 else if (x == "top-front")
114 {
116 }
117 else if (x == "top-back")
118 {
119 return direction::TOP_BACK;
120 }
121 else if (x == "bottom-front")
122 {
124 }
125 else if (x == "bottom-back")
126 {
128 }
129 else if (x == "left-top-front")
130 {
132 }
133 else if (x == "left-top-back")
134 {
136 }
137 else if (x == "left-bottom-front")
138 {
140 }
141 else if (x == "left-bottom-back")
142 {
144 }
145 else if (x == "right-top-front")
146 {
148 }
149 else if (x == "right-top-back")
150 {
152 }
153 else if (x == "right-bottom-front")
154 {
156 }
157 else if (x == "right-bottom-back")
158 {
160 }
161 else
162 {
163 return direction::NONE;
164 }
165 }
166
168 {
169 if (x == direction::LEFT)
170 {
171 return direction::RIGHT;
172 }
173 else if (x == direction::RIGHT)
174 {
175 return direction::LEFT;
176 }
177 else if (x == direction::TOP)
178 {
179 return direction::BOTTOM;
180 }
181 else if (x == direction::BOTTOM)
182 {
183 return direction::TOP;
184 }
185 else if (x == direction::FRONT)
186 {
187 return direction::BACK;
188 }
189 else if (x == direction::BACK)
190 {
191 return direction::FRONT;
192 }
193 else if (x == direction::LEFT_TOP)
194 {
196 }
197 else if (x == direction::LEFT_BOTTOM)
198 {
200 }
201 else if (x == direction::RIGHT_TOP)
202 {
204 }
205 else if (x == direction::RIGHT_BOTTOM)
206 {
207 return direction::LEFT_TOP;
208 }
209 else if (x == direction::LEFT_FRONT)
210 {
212 }
213 else if (x == direction::LEFT_BACK)
214 {
216 }
217 else if (x == direction::RIGHT_FRONT)
218 {
220 }
221 else if (x == direction::RIGHT_BACK)
222 {
224 }
225 else if (x == direction::TOP_FRONT)
226 {
228 }
229 else if (x == direction::TOP_BACK)
230 {
232 }
233 else if (x == direction::BOTTOM_FRONT)
234 {
235 return direction::TOP_BACK;
236 }
237 else if (x == direction::BOTTOM_BACK)
238 {
240 }
241 else if (x == direction::LEFT_TOP_FRONT)
242 {
244 }
245 else if (x == direction::LEFT_TOP_BACK)
246 {
248 }
249 else if (x == direction::LEFT_BOTTOM_FRONT)
250 {
252 }
253 else if (x == direction::LEFT_BOTTOM_BACK)
254 {
256 }
257 else if (x == direction::RIGHT_TOP_FRONT)
258 {
260 }
261 else if (x == direction::RIGHT_TOP_BACK)
262 {
264 }
265 else if (x == direction::RIGHT_BOTTOM_FRONT)
266 {
268 }
269 else if (x == direction::RIGHT_BOTTOM_BACK)
270 {
272 }
273 else
274 {
275 return direction::NONE;
276 }
277 }
278
280 {
281 switch (x)
282 {
283 case direction::NONE:
284 return "";
285 case direction::LEFT:
286 return "left";
287 case direction::RIGHT:
288 return "right";
289 case direction::TOP:
290 return "top";
292 return "bottom";
293 case direction::FRONT:
294 return "front";
295 case direction::BACK:
296 return "back";
298 return "left-top";
300 return "left-bottom";
302 return "right-top";
304 return "right-bottom";
306 return "left-front";
308 return "left-back";
310 return "right-front";
312 return "right-back";
314 return "top-front";
316 return "top-back";
318 return "bottom-front";
320 return "bottom-back";
322 return "left-top-front";
324 return "left-top-back";
326 return "left-bottom-front";
328 return "left-bottom-back";
330 return "right-top-front";
332 return "right-top-back";
334 return "right-bottom-front";
336 return "right-bottom-back";
337 }
338 return "";
339 }
340
341 string to_string(const direction& x)
342 {
343 return to_string(x.value);
344 }
345}
346
348{
349 if(x.value == y.value)
350 {
351 return true;
352 }
353 else
354 {
355 return false;
356 }
357}
358
360{
361 return !(x == y);
362}
363
365{
366 if(x.value == y)
367 {
368 return true;
369 }
370 else
371 {
372 return false;
373 }
374}
375
377{
378 return !(x == y);
379}
380
382{
383 return (x == y);
384}
385
387{
388 return !(x == y);
389}
390
391bool operator ==(const scifir::direction& x, const string& init_direction)
392{
393 scifir::direction y(init_direction);
394 return (x == y);
395}
396
397bool operator !=(const scifir::direction& x, const string& init_direction)
398{
399 return !(x == init_direction);
400}
401
402bool operator ==(const string& init_direction, const scifir::direction& x)
403{
404 scifir::direction y(init_direction);
405 return (x == y);
406}
407
408bool operator !=(const string& init_direction, const scifir::direction& x)
409{
410 return !(init_direction == x);
411}
412
413void operator +=(string& x, const scifir::direction& y)
414{
415 ostringstream output;
416 output << y;
417 x += output.str();
418}
419
420string operator +(const string& x, const scifir::direction& y)
421{
422 ostringstream output;
423 output << x;
424 output << y;
425 return output.str();
426}
427
428string operator +(const scifir::direction& y, const string& x)
429{
430 ostringstream output;
431 output << y;
432 output << x;
433 return output.str();
434}
435
436ostream& operator <<(ostream& os, const scifir::direction& x)
437{
438 return os << to_string(x);
439}
440
441istream& operator >>(istream& is, scifir::direction& x)
442{
443 char a[256];
444 is.getline(a, 256);
445 string b(a);
446 boost::trim(b);
447 x = scifir::direction(b);
448 return is;
449}
direction & operator=(const direction &x)
Definition direction.cpp:26
direction::name value
Definition direction.hpp:32
bool operator!=(const scifir::direction &x, const scifir::direction &y)
bool operator==(const scifir::direction &x, const scifir::direction &y)
istream & operator>>(istream &is, scifir::direction &x)
ostream & operator<<(ostream &os, const scifir::direction &x)
void operator+=(string &x, const scifir::direction &y)
string operator+(const string &x, const scifir::direction &y)
The namespace scifir contains all scifir-units, excepting the string literals, which are outside.
Definition address.cpp:6
direction::name invert(direction::name x)
@ NONE
No predefined astronomical body selected.
string to_string(const aid &x)
Creates a string representation of aid, it's for aid equivalent to the display() function of aid.
Definition aid.cpp:582
direction::name create_direction(const string &x)
Definition direction.cpp:55