fixed some compiler warnings
added equality checks to sensor-data classes more robust sensor reader [fixed some issues] added support for gps added support for compass added sensor-data-writer added test-cases minor changes
This commit is contained in:
53
sensors/offline/Splitter.h
Normal file
53
sensors/offline/Splitter.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef DATA_SPLITTER_H
|
||||
#define DATA_SPLITTER_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* split an input-file into various tokens
|
||||
*/
|
||||
class Splitter {
|
||||
|
||||
std::string str;
|
||||
char sep = ';';
|
||||
std::vector<std::string> split;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor */
|
||||
Splitter(const std::string& str, const char sep = ';') : str(str), sep(sep) {
|
||||
build();
|
||||
}
|
||||
|
||||
bool has(const int idx) const {return split.size() > idx;}
|
||||
|
||||
const std::string& get(const int idx) const {return split.at(idx);}
|
||||
|
||||
const float getFloat(const int idx) const {return std::stof(get(idx));}
|
||||
|
||||
size_t size() const {return split.size();}
|
||||
|
||||
private:
|
||||
|
||||
void build() {
|
||||
|
||||
std::string cur;
|
||||
|
||||
for (char c : str) {
|
||||
if (c == sep) {
|
||||
split.push_back(cur);
|
||||
cur = "";
|
||||
} else {
|
||||
cur += c;
|
||||
}
|
||||
}
|
||||
|
||||
split.push_back(cur);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // DATA_SPLITTER_H
|
||||
Reference in New Issue
Block a user