| 25 | namespace sensorDB { |
| 26 | |
| 27 | bool parseDatabase(const std::string& databaseFilePath, std::vector<Datasheet>& databaseStructure) |
| 28 | { |
| 29 | std::ifstream fileIn(databaseFilePath); |
| 30 | if (!fileIn || !utils::exists(databaseFilePath) || !fs::is_regular_file(databaseFilePath)) |
| 31 | return false; |
| 32 | |
| 33 | std::string line; |
| 34 | while (fileIn.good()) |
| 35 | { |
| 36 | getline(fileIn, line); |
| 37 | if (!line.empty()) |
| 38 | { |
| 39 | if (line[0] != '#') |
| 40 | { |
| 41 | std::vector<std::string> values; |
| 42 | boost::split(values, line, boost::is_any_of(";")); |
| 43 | |
| 44 | if (values.size() >= 4) |
| 45 | { |
| 46 | const std::string brand = values[0]; |
| 47 | const std::string model = values[1]; |
| 48 | const double sensorWidth = std::stod(values[2]); |
| 49 | databaseStructure.emplace_back(brand, model, sensorWidth); |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | return true; |
| 55 | } |
| 56 | |
| 57 | bool getInfo(const std::string& brand, const std::string& model, const std::vector<Datasheet>& databaseStructure, Datasheet& datasheetContent) |
| 58 | { |