MCPcopy Create free account
hub / github.com/Kitware/CMake / processResponse

Method processResponse

Utilities/cmcppdap/src/session.cpp:433–474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

431 }
432
433 void processResponse(const dap::Deserializer* d) {
434 dap::integer requestSeq = 0;
435 if (!d->field("request_seq", &requestSeq)) {
436 handlers.error("Response missing int 'request_seq' field");
437 return;
438 }
439
440 const dap::TypeInfo* typeinfo;
441 GenericResponseHandler handler;
442 std::tie(typeinfo, handler) = handlers.response(requestSeq);
443 if (!typeinfo) {
444 handlers.error("Unknown response with sequence %d", requestSeq);
445 return;
446 }
447
448 dap::boolean success = false;
449 if (!d->field("success", &success)) {
450 handlers.error("Response missing int 'success' field");
451 return;
452 }
453
454 if (success) {
455 auto data = std::unique_ptr<uint8_t[]>(new uint8_t[typeinfo->size()]);
456 typeinfo->construct(data.get());
457
458 // "body" field in Response is an optional field.
459 d->field("body", [&](const dap::Deserializer* d) {
460 return typeinfo->deserialize(d, data.get());
461 });
462
463 handler(data.get(), nullptr);
464 typeinfo->destruct(data.get());
465 } else {
466 std::string message;
467 if (!d->field("message", &message)) {
468 handlers.error("Failed to deserialize message");
469 return;
470 }
471 auto error = dap::Error("%s", message.c_str());
472 handler(nullptr, &error);
473 }
474 }
475
476 bool send(const std::string& s) {
477 std::unique_lock<std::mutex> lock(sendMutex);

Callers

nothing calls this directly

Calls 10

responseMethod · 0.80
c_strMethod · 0.80
ErrorClass · 0.50
fieldMethod · 0.45
errorMethod · 0.45
sizeMethod · 0.45
constructMethod · 0.45
getMethod · 0.45
deserializeMethod · 0.45
destructMethod · 0.45

Tested by

no test coverage detected