6#include <llvm/Support/JSON.h>
7#include <llvm/Support/raw_ostream.h>
28 virtual bool onCall(llvm::StringRef
Method, llvm::json::Value Params,
29 llvm::json::Value ID) = 0;
30 virtual bool onReply(llvm::json::Value ID,
31 llvm::Expected<llvm::json::Value> Result) = 0;
36 std::atomic<bool> Close;
60 llvm::Expected<llvm::json::Value>
readMessage(std::string &Buffer);
72 llvm::raw_ostream &Outs;
74 llvm::SmallVector<char, 0> OutputBuffer;
82 : Outs(
llvm::outs()), Pretty(Pretty) {}
84 : Outs(Outs), OutputBuffer(), Pretty(Pretty) {}
85 void notify(llvm::StringRef
Method, llvm::json::Value Params);
86 void call(llvm::StringRef
Method, llvm::json::Value Params,
87 llvm::json::Value ID);
88 void reply(llvm::json::Value ID, llvm::Expected<llvm::json::Value> Result);
llvm::Expected< llvm::json::Value > readMessage(std::string &Buffer)
bool dispatch(llvm::json::Value Message, MessageHandler &Handler)
InboundPort(int In=STDIN_FILENO, JSONStreamStyle StreamStyle=JSONStreamStyle::Standard)
JSONStreamStyle StreamStyle
void close()
Notify the inbound port to close the connection.
llvm::Expected< llvm::json::Value > readStandardMessage(std::string &Buffer)
void loop(MessageHandler &Handler)
llvm::Expected< llvm::json::Value > readLitTestMessage(std::string &Buffer)
Read one message, expecting the input to be one of our Markdown lit-tests.
virtual bool onReply(llvm::json::Value ID, llvm::Expected< llvm::json::Value > Result)=0
virtual bool onNotify(llvm::StringRef Method, llvm::json::Value)=0
virtual bool onCall(llvm::StringRef Method, llvm::json::Value Params, llvm::json::Value ID)=0
virtual ~MessageHandler()=default
OutboundPort(llvm::raw_ostream &Outs, bool Pretty=false)
void sendMessage(llvm::json::Value Message)
void notify(llvm::StringRef Method, llvm::json::Value Params)
void reply(llvm::json::Value ID, llvm::Expected< llvm::json::Value > Result)
void call(llvm::StringRef Method, llvm::json::Value Params, llvm::json::Value ID)
OutboundPort(bool Pretty=false)
Whether current platform treats paths case insensitively.