1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
15 #include <cm3p/cppdap/types.h> // IWYU pragma: keep
17 namespace cmDebugger
{
18 class cmDebuggerVariablesManager
;
25 namespace cmDebugger
{
27 struct cmDebuggerVariableEntry
29 cmDebuggerVariableEntry()
30 : cmDebuggerVariableEntry("", "", "")
33 cmDebuggerVariableEntry(std::string name
, std::string value
,
35 : Name(std::move(name
))
36 , Value(std::move(value
))
37 , Type(std::move(type
))
40 cmDebuggerVariableEntry(std::string name
, std::string value
)
41 : Name(std::move(name
))
42 , Value(std::move(value
))
46 cmDebuggerVariableEntry(std::string name
, const char* value
)
47 : Name(std::move(name
))
48 , Value(value
== nullptr ? "" : value
)
52 cmDebuggerVariableEntry(std::string name
, bool value
)
53 : Name(std::move(name
))
54 , Value(value
? "TRUE" : "FALSE")
58 cmDebuggerVariableEntry(std::string name
, int64_t value
)
59 : Name(std::move(name
))
60 , Value(std::to_string(value
))
64 cmDebuggerVariableEntry(std::string name
, int value
)
65 : Name(std::move(name
))
66 , Value(std::to_string(value
))
70 std::string
const Name
;
71 std::string
const Value
;
72 std::string
const Type
;
75 class cmDebuggerVariables
77 static std::atomic
<int64_t> NextId
;
82 std::function
<std::vector
<cmDebuggerVariableEntry
>()> GetKeyValuesFunction
;
83 std::vector
<std::shared_ptr
<cmDebuggerVariables
>> SubVariables
;
84 bool IgnoreEmptyStringEntries
= false;
85 bool EnableSorting
= true;
87 virtual dap::array
<dap::Variable
> HandleVariablesRequest();
88 friend class cmDebuggerVariablesManager
;
91 const bool SupportsVariableType
;
92 std::shared_ptr
<cmDebuggerVariablesManager
> VariablesManager
;
93 void EnumerateSubVariablesIfAny(
94 dap::array
<dap::Variable
>& toBeReturned
) const;
95 void ClearSubVariables();
99 std::shared_ptr
<cmDebuggerVariablesManager
> variablesManager
,
100 std::string name
, bool supportsVariableType
);
102 std::shared_ptr
<cmDebuggerVariablesManager
> variablesManager
,
103 std::string name
, bool supportsVariableType
,
104 std::function
<std::vector
<cmDebuggerVariableEntry
>()> getKeyValuesFunc
);
105 inline int64_t GetId() const noexcept
{ return this->Id
; }
106 inline std::string
GetName() const noexcept
{ return this->Name
; }
107 inline std::string
GetValue() const noexcept
{ return this->Value
; }
108 inline void SetValue(std::string
const& value
) noexcept
112 void AddSubVariables(std::shared_ptr
<cmDebuggerVariables
> const& variables
);
113 inline void SetIgnoreEmptyStringEntries(bool value
) noexcept
115 this->IgnoreEmptyStringEntries
= value
;
117 inline void SetEnableSorting(bool value
) noexcept
119 this->EnableSorting
= value
;
121 virtual ~cmDebuggerVariables();
124 } // namespace cmDebugger