| 1 |
#ifndef JSONRPC_RESULTS_H |
| 2 |
#define JSONRPC_RESULTS_H |
| 3 |
|
| 4 |
#include "codelite_exports.h" |
| 5 |
#include "JSON.h" |
| 6 |
#include "LSP/JSONObject.h" |
| 7 |
#include <wx/sharedptr.h> |
| 8 |
#include "basic_types.h" |
| 9 |
|
| 10 |
namespace LSP |
| 11 |
{ |
| 12 |
//===---------------------------------------------------------------------------------- |
| 13 |
// Result |
| 14 |
//===---------------------------------------------------------------------------------- |
| 15 |
class WXDLLIMPEXP_CL Result : public Serializable |
| 16 |
{ |
| 17 |
public: |
| 18 |
typedef wxSharedPtr<Result> Ptr_t; |
| 19 |
|
| 20 |
public: |
| 21 |
Result() {} |
| 22 |
virtual ~Result() {} |
| 23 |
template <typename T> T* As() const { return dynamic_cast<T*>(const_cast<Result*>(this)); } |
| 24 |
virtual JSONItem ToJSON(const wxString& name) const { return JSONItem(nullptr); } |
| 25 |
}; |
| 26 |
|
| 27 |
//===---------------------------------------------------------------------------------- |
| 28 |
// ResultString |
| 29 |
//===---------------------------------------------------------------------------------- |
| 30 |
class WXDLLIMPEXP_CL ResultString : public Result |
| 31 |
{ |
| 32 |
wxString m_text; |
| 33 |
|
| 34 |
public: |
| 35 |
ResultString(const wxString& text) {} |
| 36 |
virtual ~ResultString() {} |
| 37 |
void FromJSON(const JSONItem& json); |
| 38 |
ResultString& SetText(const wxString& text) |
| 39 |
{ |
| 40 |
this->m_text = text; |
| 41 |
return *this; |
| 42 |
} |
| 43 |
const wxString& GetText() const { return m_text; } |
| 44 |
}; |
| 45 |
|
| 46 |
//===---------------------------------------------------------------------------------- |
| 47 |
// ResultNumber |
| 48 |
//===---------------------------------------------------------------------------------- |
| 49 |
class WXDLLIMPEXP_CL ResultNumber : public Result |
| 50 |
{ |
| 51 |
int m_number = 0; |
| 52 |
|
| 53 |
public: |
| 54 |
ResultNumber(const wxString& text) {} |
| 55 |
virtual ~ResultNumber() {} |
| 56 |
void FromJSON(const JSONItem& json); |
| 57 |
ResultNumber& SetNumber(int number) |
| 58 |
{ |
| 59 |
this->m_number = number; |
| 60 |
return *this; |
| 61 |
} |
| 62 |
int GetNumber() const { return m_number; } |
| 63 |
}; |
| 64 |
|
| 65 |
//===---------------------------------------------------------------------------------- |
| 66 |
// ResultNumber |
| 67 |
//===---------------------------------------------------------------------------------- |
| 68 |
class WXDLLIMPEXP_CL ResultBoolean : public Result |
| 69 |
{ |
| 70 |
bool m_value = false; |
| 71 |
|
| 72 |
public: |
| 73 |
ResultBoolean(const wxString& text) {} |
| 74 |
virtual ~ResultBoolean() {} |
| 75 |
void FromJSON(const JSONItem& json); |
| 76 |
|
| 77 |
ResultBoolean& SetValue(bool value) |
| 78 |
{ |
| 79 |
this->m_value = value; |
| 80 |
return *this; |
| 81 |
} |
| 82 |
bool GetValue() const { return m_value; } |
| 83 |
}; |
| 84 |
}; // namespace LSP |
| 85 |
|
| 86 |
#endif // JSONRPC_RESULTS_H |