brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · b09153a Raw
57 lines · c
1//===-- ResponseHandler.h -------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLDB_TOOLS_LLDB_DAP_HANDLER_RESPONSEHANDLER_H10#define LLDB_TOOLS_LLDB_DAP_HANDLER_RESPONSEHANDLER_H11 12#include "llvm/ADT/StringRef.h"13#include "llvm/Support/JSON.h"14#include <cstdint>15 16namespace lldb_dap {17struct DAP;18 19/// Handler for responses to reverse requests.20class ResponseHandler {21public:22  ResponseHandler(llvm::StringRef command, int64_t id)23      : m_command(command), m_id(id) {}24 25  /// ResponseHandlers are not copyable.26  /// @{27  ResponseHandler(const ResponseHandler &) = delete;28  ResponseHandler &operator=(const ResponseHandler &) = delete;29  /// @}30 31  virtual ~ResponseHandler() = default;32 33  virtual void operator()(llvm::Expected<llvm::json::Value> value) const = 0;34 35protected:36  llvm::StringRef m_command;37  int64_t m_id;38};39 40/// Response handler used for unknown responses.41class UnknownResponseHandler : public ResponseHandler {42public:43  using ResponseHandler::ResponseHandler;44  void operator()(llvm::Expected<llvm::json::Value> value) const override;45};46 47/// Response handler which logs to stderr in case of a failure.48class LogFailureResponseHandler : public ResponseHandler {49public:50  using ResponseHandler::ResponseHandler;51  void operator()(llvm::Expected<llvm::json::Value> value) const override;52};53 54} // namespace lldb_dap55 56#endif57