| 476 | |
| 477 | template <typename... Args> |
| 478 | void ReadData(std::string const & path, Args &&... args) |
| 479 | { |
| 480 | std::ifstream input; |
| 481 | input.exceptions(std::ifstream::badbit); |
| 482 | |
| 483 | try |
| 484 | { |
| 485 | input.open(path); |
| 486 | CHECK(input.is_open(), (path)); |
| 487 | std::string line; |
| 488 | |
| 489 | while (std::getline(input, line)) |
| 490 | { |
| 491 | if (line.empty()) |
| 492 | continue; |
| 493 | |
| 494 | base::Json jsonObject(line); |
| 495 | CHECK(jsonObject.get() != nullptr, ("Error parsing json from line:", line)); |
| 496 | Read(jsonObject, std::forward<Args>(args)...); |
| 497 | } |
| 498 | } |
| 499 | catch (std::ifstream::failure const & se) |
| 500 | { |
| 501 | LOG(LERROR, ("Exception reading line-by-line json from file", path, se.what())); |
| 502 | } |
| 503 | catch (base::Json::Exception const & je) |
| 504 | { |
| 505 | LOG(LERROR, ("Exception parsing json", path, je.what())); |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | void TransitData::DeserializeFromJson(std::string const & dirWithJsons, OsmIdToFeatureIdsMap const & mapping) |
| 510 | { |