My Project
Loading...
Searching...
No Matches
converters.hpp
1#ifndef CONVERTERS_H
2#define CONVERTERS_H
3
4#include <iostream>
5#include <string>
6
7#include "spatial/attitude-utils.hpp"
8#include "style/decimal.hpp"
9
10namespace found {
11
22inline decimal strtodecimal(const std::string &str) {
23 return STR_TO_DECIMAL(str);
24}
25
37inline EulerAngles strtoea(const std::string &str) {
38 char delimiter = str.find(" ") != std::string::npos ? ' ' : ',';
39 decimal result[3];
40
41 size_t start = 0;
42 size_t end = str.find(delimiter);
43 size_t index = 0;
44
45 while (end != std::string::npos) {
46 result[index++] = strtodecimal(str.substr(start, end - start));
47 start = end + 1;
48 end = str.find(delimiter, start);
49 }
50
51 result[index] = strtodecimal(str.substr(start));
52
53 return EulerAngles(result[0], result[1], result[2]);
54}
55
64inline bool strtobool(const std::string &str) {
65 return str.size() != 0 && str != "0" && str != "false";
66}
67
68} // namespace found
69
70#endif // CONVERTERS_H
Definition attitude-utils.hpp:173
Definition converters.hpp:10
decimal strtodecimal(const std::string &str)
Definition converters.hpp:22
bool strtobool(const std::string &str)
Definition converters.hpp:64
EulerAngles strtoea(const std::string &str)
Definition converters.hpp:37