| 1 |
#ifndef UIBREAKPOINT_HPP |
| 2 |
#define UIBREAKPOINT_HPP |
| 3 |
|
| 4 |
#include "JSON.h" |
| 5 |
#include "clDebuggerBreakpoint.hpp" |
| 6 |
#include "codelite_exports.h" |
| 7 |
|
| 8 |
#include <functional> |
| 9 |
#include <unordered_set> |
| 10 |
#include <wx/string.h> |
| 11 |
|
| 12 |
enum class UIBreakpointType { |
| 13 |
INVALID = -1, |
| 14 |
FUNCTION, |
| 15 |
SOURCE, |
| 16 |
}; |
| 17 |
|
| 18 |
class WXDLLIMPEXP_CL UIBreakpoint |
| 19 |
{ |
| 20 |
public: |
| 21 |
typedef std::unordered_set<UIBreakpoint> set_t; |
| 22 |
|
| 23 |
protected: |
| 24 |
UIBreakpointType m_type = UIBreakpointType::INVALID; |
| 25 |
wxString m_file; |
| 26 |
int m_line = wxNOT_FOUND; |
| 27 |
wxString m_function; |
| 28 |
wxString m_condition; |
| 29 |
|
| 30 |
public: |
| 31 |
UIBreakpoint(); |
| 32 |
UIBreakpoint(const wxString& file, int line) |
| 33 |
: m_type(UIBreakpointType::SOURCE) |
| 34 |
, m_file(file) |
| 35 |
, m_line(line) |
| 36 |
{ |
| 37 |
} |
| 38 |
~UIBreakpoint(); |
| 39 |
|
| 40 |
void SetFile(const wxString& file) { this->m_file = file; } |
| 41 |
void SetFunction(const wxString& function) { this->m_function = function; } |
| 42 |
void SetLine(int line) { this->m_line = line; } |
| 43 |
void SetType(UIBreakpointType type) { this->m_type = type; } |
| 44 |
const wxString& GetFile() const { return m_file; } |
| 45 |
const wxString& GetFunction() const { return m_function; } |
| 46 |
int GetLine() const { return m_line; } |
| 47 |
UIBreakpointType GetType() const { return m_type; } |
| 48 |
|
| 49 |
void SetCondition(const wxString& condition) { this->m_condition = condition; } |
| 50 |
const wxString& GetCondition() const { return m_condition; } |
| 51 |
|
| 52 |
bool SameAs(const UIBreakpoint& other) const; |
| 53 |
bool operator==(const UIBreakpoint& other) const { return SameAs(other); } |
| 54 |
|
| 55 |
wxString GetKey() const { return (wxString() << GetFile() << GetLine() << GetFunction()); } |
| 56 |
|
| 57 |
// aliases |
| 58 |
bool IsFunctionBreakpoint() const { return GetType() == UIBreakpointType::FUNCTION; } |
| 59 |
bool IsSourceBreakpoint() const { return GetType() == UIBreakpointType::SOURCE; } |
| 60 |
bool IsOk() const { return GetType() != UIBreakpointType::INVALID; } |
| 61 |
|
| 62 |
JSONItem To() const; |
| 63 |
void From(const JSONItem& json); |
| 64 |
bool From(const clDebuggerBreakpoint& bp); |
| 65 |
}; |
| 66 |
|
| 67 |
// provide custom hash so we will be able to use UIBreakpoint with unordered_map/unordered_set et al |
| 68 |
namespace std |
| 69 |
{ |
| 70 |
template <> struct hash<UIBreakpoint> { |
| 71 |
std::size_t operator()(const UIBreakpoint& b) const { return hash<std::wstring>{}(b.GetKey().ToStdWstring()); } |
| 72 |
}; |
| 73 |
} // namespace std |
| 74 |
#endif // UIBREAKPOINT_HPP |