forked from eranif/codelite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoteObject.cpp
More file actions
64 lines (56 loc) · 1.79 KB
/
Copy pathRemoteObject.cpp
File metadata and controls
64 lines (56 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "PropertyPreview.h"
#include "RemoteObject.h"
RemoteObject::RemoteObject() {}
RemoteObject::~RemoteObject() {}
void RemoteObject::FromJSON(const JSONItem& json)
{
m_type = json.namedObject("type").toString();
m_subtype = json.namedObject("subtype").toString();
m_className = json.namedObject("className").toString();
m_objectId = json.namedObject("objectId").toString();
JSONItem value = json.namedObject("value");
if(value.isNull()) {
m_value = "null";
} else if(value.isBool()) {
m_value << (value.toBool() ? "true" : "false");
} else if(value.isNumber()) {
m_value << value.toInt();
} else {
m_value << value.toString();
}
if(json.hasNamedObject("preview")) { m_preview.FromJSON(json.namedObject("preview")); }
}
JSONItem RemoteObject::ToJSON(const wxString& name) const
{
JSONItem json = JSONItem::createObject(name);
json.addProperty("type", m_type);
json.addProperty("subtype", m_subtype);
json.addProperty("className", m_className);
json.addProperty("value", m_value);
json.addProperty("objectId", m_objectId);
if(!m_preview.IsEmpty()) { json.append(m_preview.ToJSON("preview")); }
return json;
}
wxString RemoteObject::ToString() const
{
wxString str;
if(IsFunction()) {
return "Function";
} else if(IsObject()) {
str << this->GetClassName() << " : " << GetPreview().ToString();
} else if(IsString()) {
// Simple type
str << "\"" << GetValue() << "\"";
} else if(IsUndefined()) {
str << "undefined";
} else {
str << GetValue();
}
return str;
}
wxString RemoteObject::GetTextPreview() const
{
if(IsObject()) { return "{...}"; }
return ToString();
}
bool RemoteObject::HasChildren() const { return IsObject(); }