LLDB mainline
lldb_private::transport::JSONTransport< Proto > Class Template Referenceabstract

A transport is responsible for maintaining the connection to a client application, and reading/writing structured messages to it. More...

#include <JSONTransport.h>

Inheritance diagram for lldb_private::transport::JSONTransport< Proto >:
[legend]

Classes

class  MessageHandler
 Implemented to handle incoming messages. More...

Public Types

using Req = typename Proto::Req
using Resp = typename Proto::Resp
using Evt = typename Proto::Evt
using Message = std::variant<Req, Resp, Evt>

Public Member Functions

virtual ~JSONTransport ()=default
virtual llvm::Error Send (const Evt &)=0
 Sends an event, a message that does not require a response.
virtual llvm::Error Send (const Req &)=0
 Sends a request, a message that expects a response.
virtual llvm::Error Send (const Resp &)=0
 Sends a response to a specific request.
virtual llvm::Error ReplyWithParseError (llvm::StringRef raw_message, llvm::StringRef reason)
 Sends an error response for a message that failed to parse, described by reason.
virtual llvm::Error RegisterMessageHandler (MessageHandler &handler)=0
 RegisterMessageHandler registers the Transport with the given MainLoop and handles any incoming messages using the given MessageHandler.

Protected Member Functions

template<typename... Ts>
auto Logv (const char *Fmt, Ts &&...Vals)
virtual void Log (llvm::StringRef message)=0

Detailed Description

template<typename Proto>
class lldb_private::transport::JSONTransport< Proto >

A transport is responsible for maintaining the connection to a client application, and reading/writing structured messages to it.

JSONTransport have limited thread safety requirements:

  • Messages will not be sent concurrently.
  • Messages MAY be sent while Run() is reading, or its callback is active.

Definition at line 147 of file JSONTransport.h.

Member Typedef Documentation

◆ Evt

template<typename Proto>
using lldb_private::transport::JSONTransport< Proto >::Evt = typename Proto::Evt

Definition at line 151 of file JSONTransport.h.

◆ Message

template<typename Proto>
using lldb_private::transport::JSONTransport< Proto >::Message = std::variant<Req, Resp, Evt>

Definition at line 152 of file JSONTransport.h.

◆ Req

template<typename Proto>
using lldb_private::transport::JSONTransport< Proto >::Req = typename Proto::Req

Definition at line 149 of file JSONTransport.h.

◆ Resp

template<typename Proto>
using lldb_private::transport::JSONTransport< Proto >::Resp = typename Proto::Resp

Definition at line 150 of file JSONTransport.h.

Constructor & Destructor Documentation

◆ ~JSONTransport()

template<typename Proto>
virtual lldb_private::transport::JSONTransport< Proto >::~JSONTransport ( )
virtualdefault

Member Function Documentation

◆ Log()

template<typename Proto>
virtual void lldb_private::transport::JSONTransport< Proto >::Log ( llvm::StringRef message)
protectedpure virtual

◆ Logv()

template<typename Proto>
template<typename... Ts>
auto lldb_private::transport::JSONTransport< Proto >::Logv ( const char * Fmt,
Ts &&... Vals )
inlineprotected

◆ RegisterMessageHandler()

template<typename Proto>
virtual llvm::Error lldb_private::transport::JSONTransport< Proto >::RegisterMessageHandler ( MessageHandler & handler)
pure virtual

RegisterMessageHandler registers the Transport with the given MainLoop and handles any incoming messages using the given MessageHandler.

If an unexpected error occurs, the MainLoop will be terminated and a log message will include additional information about the termination reason.

Implemented in lldb_private::transport::IOTransport< Proto >.

◆ ReplyWithParseError()

template<typename Proto>
virtual llvm::Error lldb_private::transport::JSONTransport< Proto >::ReplyWithParseError ( llvm::StringRef raw_message,
llvm::StringRef reason )
inlinevirtual

Sends an error response for a message that failed to parse, described by reason.

Sends nothing if no request id can be recovered from it, since there is then no request to respond to.

Reimplemented in lldb_protocol::mcp::Transport.

Definition at line 166 of file JSONTransport.h.

Referenced by lldb_private::transport::IOTransport< Proto >::OnRead().

◆ Send() [1/3]

template<typename Proto>
virtual llvm::Error lldb_private::transport::JSONTransport< Proto >::Send ( const Evt & )
pure virtual

Sends an event, a message that does not require a response.

◆ Send() [2/3]

template<typename Proto>
virtual llvm::Error lldb_private::transport::JSONTransport< Proto >::Send ( const Req & )
pure virtual

Sends a request, a message that expects a response.

◆ Send() [3/3]

template<typename Proto>
virtual llvm::Error lldb_private::transport::JSONTransport< Proto >::Send ( const Resp & )
pure virtual

Sends a response to a specific request.


The documentation for this class was generated from the following file: