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;
70 llvm::raw_ostream &Outs;
72 llvm::SmallVector<char, 0> OutputBuffer;
80 : Outs(
llvm::outs()), Pretty(Pretty) {}
82 : Outs(Outs), OutputBuffer(), Pretty(Pretty) {}
83 void notify(llvm::StringRef
Method, llvm::json::Value Params);
84 void call(llvm::StringRef
Method, llvm::json::Value Params,
85 llvm::json::Value ID);
86 void reply(llvm::json::Value ID, llvm::Expected<llvm::json::Value> Result);
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.
bool readStandardMessage(std::string &JSONString)
bool readMessage(std::string &JSONString)
bool readDelimitedMessage(std::string &JSONString)
void loop(MessageHandler &Handler)
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.