Write a csv line for a FileMap according to the keys
| 276 | |
| 277 | /// Write a csv line for a FileMap according to the keys |
| 278 | static void write_csv_row(FILE* file_out, const FileMap& file, const std::vector<std::string>& keys) { |
| 279 | for (size_t i = 0; i < keys.size(); ++i) { |
| 280 | const std::string& key = keys[i]; |
| 281 | |
| 282 | // find the appropriate entry |
| 283 | auto it = std::find_if(file.begin(), file.end(), [&](const auto& kv) { return kv.first == key; }); |
| 284 | |
| 285 | if (it != file.end()) { |
| 286 | std::visit(CsvValueWriter{file_out}, it->second); |
| 287 | } else { |
| 288 | // empty field if key does not exist |
| 289 | } |
| 290 | |
| 291 | if (i + 1 < keys.size()) fprintf(file_out, ";"); |
| 292 | } |
| 293 | |
| 294 | fprintf(file_out, "\n"); |
| 295 | } |
| 296 | |
| 297 | |
| 298 | // A group of keys that belong together |
no test coverage detected