MCPcopy Create free account
hub / github.com/clice-io/clice / load_json

Function load_json

tests/unit/command/command_tests.cpp:451–465  ·  view source on GitHub ↗

Write JSON to a temp file, load into a CDB, remove the file. Returns the number of entries loaded.

Source from the content-addressed store, hash-verified

449/// Write JSON to a temp file, load into a CDB, remove the file.
450/// Returns the number of entries loaded.
451std::size_t load_json(CompilationDatabase& database, llvm::StringRef json) {
452 auto path = fs::createTemporaryFile("cdb", "json");
453 if(!path)
454 return 0;
455 {
456 std::error_code ec;
457 llvm::raw_fd_ostream out(*path, ec);
458 if(ec)
459 return 0;
460 out << json;
461 }
462 auto count = database.load(*path).value_or(0);
463 llvm::sys::fs::remove(*path);
464 return count;
465}
466
467TEST_CASE(LoadMixedFormats) {
468 /// "arguments" array and "command" string can coexist in the same CDB.

Callers 1

TEST_CASEFunction · 0.85

Calls 2

createTemporaryFileFunction · 0.85
loadMethod · 0.45

Tested by

no test coverage detected