Debian Codegraph @

CodeLite/LSP/Message.h

raw
1 #ifndef MESSAGE_H
2 #define MESSAGE_H
3
4 #include "IPathConverter.hpp"
5 #include "JSON.h"
6 #include "JSONObject.h"
7 #include "codelite_exports.h"
8 #include <string>
9 #include <memory>
10
11 namespace LSP
12 {
13 class WXDLLIMPEXP_CL Message : public LSP::Serializable
14 {
15 wxString m_jsonrpc = "2.0";
16
17 public:
18 static int GetNextID();
19
20 public:
21 Message();
22 virtual ~Message();
23 virtual JSONItem ToJSON(const wxString& name) const;
24 virtual void FromJSON(const JSONItem& json);
25
26 /**
27 * @brief serialize this message into string
28 */
29 virtual std::string ToString() const = 0;
30
31 /**
32 * @brief return the **first** JSON payload from the network buffer
33 * @param network_buffer - network buffer (may contain multiple messages)
34 */
35 static std::unique_ptr<JSON> GetJSONPayload(wxString& network_buffer);
36
37 template <typename T> T* As() const { return dynamic_cast<T*>(const_cast<Message*>(this)); }
38 };
39
40 }; // namespace LSP
41
42 #endif // MESSAGE_H