Debian Codegraph @

CodeLite/UIBreakpoint.cpp

raw
1 #include "UIBreakpoint.hpp"
2
3 UIBreakpoint::UIBreakpoint() {}
4
5 UIBreakpoint::~UIBreakpoint() {}
6
7 bool UIBreakpoint::SameAs(const UIBreakpoint& other) const
8 {
9 // check the type first
10 if(GetType() != other.GetType()) {
11 return false;
12 }
13
14 switch(GetType()) {
15 case UIBreakpointType::INVALID:
16 return true;
17 case UIBreakpointType::SOURCE:
18 return m_file == other.m_file && m_line == other.m_line;
19 case UIBreakpointType::FUNCTION:
20 return m_function == other.m_function;
21 }
22 return false; // should not get here
23 }
24
25 JSONItem UIBreakpoint::To() const
26 {
27 JSON root(cJSON_Object);
28 auto json = root.toElement();
29
30 json.addProperty("type", (int)m_type);
31 json.addProperty("file", m_file);
32 json.addProperty("line", m_line);
33 json.addProperty("function", m_function);
34 json.addProperty("condition", m_condition);
35 return json;
36 }
37
38 void UIBreakpoint::From(const JSONItem& json)
39 {
40 m_type = (UIBreakpointType)json["type"].toInt(wxNOT_FOUND);
41 m_file = json["file"].toString();
42 m_line = json["line"].toInt(wxNOT_FOUND);
43 m_function = json["function"].toString();
44 m_condition = json["condition"].toString();
45 }
46
47 bool UIBreakpoint::From(const clDebuggerBreakpoint& bp)
48 {
49 if(bp.bp_type != BreakpointType::BP_type_break)
50 return false;
51
52 if(!bp.function_name.empty()) {
53 SetType(UIBreakpointType::FUNCTION);
54 SetFunction(bp.function_name);
55 SetCondition(bp.conditions);
56 } else if(bp.lineno < 0 || bp.file.empty()) {
57 return false;
58 } else {
59 SetType(UIBreakpointType::SOURCE);
60 SetFile(bp.file);
61 SetLine(bp.lineno);
62 SetCondition(bp.conditions);
63 }
64 return true;
65 }