File: UIBreakpoint.cpp

package info (click to toggle)
codelite 17.0.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 136,204 kB
  • sloc: cpp: 491,547; ansic: 280,393; php: 10,259; sh: 8,930; lisp: 7,664; vhdl: 6,518; python: 6,020; lex: 4,920; yacc: 3,123; perl: 2,385; javascript: 1,715; cs: 1,193; xml: 1,110; makefile: 804; cobol: 741; sql: 709; ruby: 620; f90: 566; ada: 534; asm: 464; fortran: 350; objc: 289; tcl: 258; java: 157; erlang: 61; pascal: 51; ml: 49; awk: 44; haskell: 36
file content (65 lines) | stat: -rw-r--r-- 1,728 bytes parent folder | download | duplicates (2)
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
65
#include "UIBreakpoint.hpp"

UIBreakpoint::UIBreakpoint() {}

UIBreakpoint::~UIBreakpoint() {}

bool UIBreakpoint::SameAs(const UIBreakpoint& other) const
{
    // check the type first
    if(GetType() != other.GetType()) {
        return false;
    }

    switch(GetType()) {
    case UIBreakpointType::INVALID:
        return true;
    case UIBreakpointType::SOURCE:
        return m_file == other.m_file && m_line == other.m_line;
    case UIBreakpointType::FUNCTION:
        return m_function == other.m_function;
    }
    return false; // should not get here
}

JSONItem UIBreakpoint::To() const
{
    JSON root(cJSON_Object);
    auto json = root.toElement();

    json.addProperty("type", (int)m_type);
    json.addProperty("file", m_file);
    json.addProperty("line", m_line);
    json.addProperty("function", m_function);
    json.addProperty("condition", m_condition);
    return json;
}

void UIBreakpoint::From(const JSONItem& json)
{
    m_type = (UIBreakpointType)json["type"].toInt(wxNOT_FOUND);
    m_file = json["file"].toString();
    m_line = json["line"].toInt(wxNOT_FOUND);
    m_function = json["function"].toString();
    m_condition = json["condition"].toString();
}

bool UIBreakpoint::From(const clDebuggerBreakpoint& bp)
{
    if(bp.bp_type != BreakpointType::BP_type_break)
        return false;

    if(!bp.function_name.empty()) {
        SetType(UIBreakpointType::FUNCTION);
        SetFunction(bp.function_name);
        SetCondition(bp.conditions);
    } else if(bp.lineno < 0 || bp.file.empty()) {
        return false;
    } else {
        SetType(UIBreakpointType::SOURCE);
        SetFile(bp.file);
        SetLine(bp.lineno);
        SetCondition(bp.conditions);
    }
    return true;
}