MCPcopy Create free account
hub / github.com/comaps/comaps / ReadData

Function ReadData

libs/transit/experimental/transit_data.cpp:478–507  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

476
477template <typename... Args>
478void 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
509void TransitData::DeserializeFromJson(std::string const & dirWithJsons, OsmIdToFeatureIdsMap const & mapping)
510{

Callers 1

DeserializeFromJsonMethod · 0.85

Calls 5

openMethod · 0.80
ReadFunction · 0.70
getMethod · 0.65
emptyMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected