#include #include #include #include #include namespace RAT { std::vector DBJsonLoader::parse(const std::string &filename) { std::string contents; if(ReadFile(filename, contents) < 0) throw FileNotFoundError(filename); return parseString(contents); } std::vector DBJsonLoader::parseString(const std::string &data) { std::vector tables; json::Reader reader(data); json::Value jsonDoc; while (reader.getValue(jsonDoc)) { // Copy the fields into a RATDB table Log::Assert(jsonDoc.getType() == json::TOBJECT, "DBJsonLoader::parseString: Non-object JSON document found."); DBTable *newTable = convertTable(jsonDoc); tables.push_back(newTable); } return tables; } RAT::DBTable *DBJsonLoader::convertTable(const json::Value &jsonDoc) { return new DBTable(const_cast(jsonDoc)); } } // namespace RAT