static inline string wbLogEntry_toJSON(wbLogEntry_t elem) { if (elem != NULL) { stringstream ss; ss << "{\n"; ss << wbString_quote("level") << ":" << wbString_quote(getLevelName(wbLogEntry_getLevel(elem))) << ",\n"; ss << wbString_quote("message") << ":" << wbString_quote(wbLogEntry_getMessage(elem)) << ",\n"; ss << wbString_quote("file") << ":" << wbString_quote(wbLogEntry_getFile(elem)) << ",\n"; ss << wbString_quote("function") << ":" << wbString_quote(wbLogEntry_getFunction(elem)) << ",\n"; ss << wbString_quote("line") << ":" << wbLogEntry_getLine(elem) << ",\n"; ss << wbString_quote("time") << ":" << wbLogEntry_getTime(elem) << "\n"; ss << "}"; return ss.str(); } return ""; }
wbBool wbSolution(wbArg_t arg, void *data, int rows, int columns, int depth) { char *type; wbBool res; char *expectedOutputFile; char *outputFile; stringstream ss; expectedOutputFile = wbArg_getExpectedOutputFile(arg); outputFile = wbArg_getOutputFile(arg); type = wbArg_getType(arg); wbAssert(type != NULL); wbAssert(expectedOutputFile != NULL); wbAssert(outputFile != NULL); res = wbSolution(expectedOutputFile, outputFile, type, data, rows, columns, depth); if (WB_USE_JSON11) { json11::Json json; if (res) { json = json11::Json::object{{"correctq", true}, {"message", "The solution is correct"}}; } else { json = json11::Json::object{{"correctq", false}, {"message", _solution_correctQ}}; } #ifdef wbLogger_printOnLog if (wbLogger_printOnLog) { json11::Json e = json11::Json::object{{"type", "solution"}, {"data", json}}; std::cout << e.dump() << std::endl; } #endif /* wbLogger_printOnLog */ solutionJSON = wbString_duplicate(json.string_value()); } else { if (res) { ss << "{\n"; ss << wbString_quote("correctq") << ": true,\n"; ss << wbString_quote("message") << ": " << wbString_quote("Solution is correct.") << "\n"; ss << "}"; } else { ss << "{\n"; ss << wbString_quote("correctq") << ": false,\n"; ss << wbString_quote("message") << ": " << wbString_quote(_solution_correctQ) << "\n"; ss << "}"; } solutionJSON = wbString_duplicate(ss.str()); } return res; }
string wbLogger_toJSON(wbLogger_t logger) { if (logger != NULL) { wbLogEntry_t iter; stringstream ss; ss << "{\n"; ss << wbString_quote("elements") << ":[\n"; for (iter = wbLogger_getHead(logger); iter != NULL; iter = wbLogEntry_getNext(iter)) { ss << wbLogEntry_toJSON(iter); if (wbLogEntry_getNext(iter) != NULL) { ss << ",\n"; } } ss << "]\n"; ss << "}\n"; return ss.str(); } return ""; }
static inline string wbLogEntry_toJSON(wbLogEntry_t elem) { if (elem == NULL) { return ""; } else if (WB_USE_JSON11) { json11::Json json = wbLogEntry_toJSONObject(elem); return json.string_value(); } else { stringstream ss; ss << "{\n"; ss << wbString_quote("id") << ":" << wbString_quote(wbLogEntry_getId(elem)) << ",\n"; ss << wbString_quote("session_id") << ":" << wbString_quote(wbLogEntry_getSessionId(elem)) << ",\n"; ss << wbString_quote("mpi_rank") << ":" << wbString(wbLogEntry_getMPIRank(elem)) << ",\n"; ss << wbString_quote("level") << ":" << wbString_quote(getLevelName(wbLogEntry_getLevel(elem))) << ",\n"; ss << wbString_quote("message") << ":" << wbString_quote(wbLogEntry_getMessage(elem)) << ",\n"; ss << wbString_quote("file") << ":" << wbString_quote(wbLogEntry_getFile(elem)) << ",\n"; ss << wbString_quote("function") << ":" << wbString_quote(wbLogEntry_getFunction(elem)) << ",\n"; ss << wbString_quote("line") << ":" << wbLogEntry_getLine(elem) << ",\n"; ss << wbString_quote("time") << ":" << wbLogEntry_getTime(elem) << "\n"; ss << "}"; return ss.str(); } return ""; }