LLDB mainline
SBStructuredData.h
Go to the documentation of this file.
1//===-- SBStructuredData.h --------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_API_SBSTRUCTUREDDATA_H
10#define LLDB_API_SBSTRUCTUREDDATA_H
11
13#include "lldb/API/SBDefines.h"
14#include "lldb/API/SBModule.h"
16
17namespace lldb_private {
18namespace python {
19class SWIGBridge;
20}
21namespace lua {
22class SWIGBridge;
23}
24} // namespace lldb_private
25
26namespace lldb {
27
29public:
31
33
35 const lldb::SBDebugger &debugger);
36
38
40
41 explicit operator bool() const;
42
43 bool IsValid() const;
44
46
47 lldb::SBError SetFromJSON(const char *json);
48
49 void Clear();
50
52
54
55 /// Return the type of data in this data structure
57
58 /// Return the size (i.e. number of elements) in this data structure
59 /// if it is an array or dictionary type. For other types, 0 will be
60 // returned.
61 size_t GetSize() const;
62
63 /// Fill keys with the keys in this object and return true if this data
64 /// structure is a dictionary. Returns false otherwise.
65 bool GetKeys(lldb::SBStringList &keys) const;
66
67 /// Return the value corresponding to a key if this data structure
68 /// is a dictionary type.
69 lldb::SBStructuredData GetValueForKey(const char *key) const;
70
71 /// Return the value corresponding to an index if this data structure
72 /// is array.
73 lldb::SBStructuredData GetItemAtIndex(size_t idx) const;
74
75 /// Return the integer value if this data structure is an integer type.
76 uint64_t GetUnsignedIntegerValue(uint64_t fail_value = 0) const;
77 /// Return the integer value if this data structure is an integer type.
78 int64_t GetSignedIntegerValue(int64_t fail_value = 0) const;
79
81 "Specify if the value is signed or unsigned",
82 "uint64_t GetUnsignedIntegerValue(uint64_t fail_value = 0)")
83 uint64_t GetIntegerValue(uint64_t fail_value = 0) const;
84
85 /// Return the floating point value if this data structure is a floating
86 /// type.
87 double GetFloatValue(double fail_value = 0.0) const;
88
89 /// Return the boolean value if this data structure is a boolean type.
90 bool GetBooleanValue(bool fail_value = false) const;
91
92 /// Provides the string value if this data structure is a string type.
93 ///
94 /// \param[out] dst
95 /// pointer where the string value will be written. In case it is null,
96 /// nothing will be written at \a dst.
97 ///
98 /// \param[in] dst_len
99 /// max number of characters that can be written at \a dst. In case it is
100 /// zero, nothing will be written at \a dst. If this length is not enough
101 /// to write the complete string value, (\a dst_len - 1) bytes of the
102 /// string value will be written at \a dst followed by a null character.
103 ///
104 /// \return
105 /// Returns the byte size needed to completely write the string value at
106 /// \a dst in all cases.
107 size_t GetStringValue(char *dst, size_t dst_len) const;
108
109 /// Return the generic pointer if this data structure is a generic type.
111
112 /// Set the value corresponding to a key. If this data structure
113 /// is not a dictionary type, reset the type to be dictionary and overwrite
114 /// the previous data.
115 void SetValueForKey(const char *key, SBStructuredData &value);
116
117 /// Change the type to unsigned interger and overwrite the previous data with
118 /// the new value.
119 void SetUnsignedIntegerValue(uint64_t value);
120
121 /// Change the type to signed interger and overwrite the previous data with
122 /// the new value.
123 void SetSignedIntegerValue(int64_t value);
124
125 /// Change the type to float and overwrite the previous data with the new
126 /// value.
127 void SetFloatValue(double value);
128
129 /// Change the type to boolean and overwrite the previous data with the new
130 /// value.
131 void SetBooleanValue(bool value);
132
133 /// Change the type to string and overwrite the previous data with the new
134 /// value.
135 void SetStringValue(const char *value);
136
137 /// Change the type to generic and overwrite the previous data with the new
138 /// value.
140
141protected:
142 friend class SBAttachInfo;
144 friend class SBLaunchInfo;
145 friend class SBDebugger;
146 friend class SBFrame;
147 friend class SBError;
148 friend class SBTarget;
149 friend class SBProcess;
150 friend class SBThread;
151 friend class SBThreadPlan;
152 friend class SBBreakpoint;
154 friend class SBBreakpointName;
155 friend class SBTrace;
156 friend class lldb_private::python::SWIGBridge;
157 friend class lldb_private::lua::SWIGBridge;
159
160 SBStructuredData(const lldb_private::StructuredDataImpl &impl);
161
162 SBStructuredData(const lldb::EventSP &event_sp);
163
165};
166} // namespace lldb
167
168#endif // LLDB_API_SBSTRUCTUREDDATA_H
void SetStringValue(const char *value)
Change the type to string and overwrite the previous data with the new value.
lldb::SBStructuredData GetItemAtIndex(size_t idx) const
Return the value corresponding to an index if this data structure is array.
lldb::SBStructuredData & operator=(const lldb::SBStructuredData &rhs)
int64_t GetSignedIntegerValue(int64_t fail_value=0) const
Return the integer value if this data structure is an integer type.
void SetGenericValue(SBScriptObject value)
Change the type to generic and overwrite the previous data with the new value.
lldb::SBError GetDescription(lldb::SBStream &stream) const
friend class lldb_private::python::SWIGBridge
friend class SBCommandReturnObject
void SetBooleanValue(bool value)
Change the type to boolean and overwrite the previous data with the new value.
size_t GetStringValue(char *dst, size_t dst_len) const
Provides the string value if this data structure is a string type.
lldb::SBScriptObject GetGenericValue() const
Return the generic pointer if this data structure is a generic type.
bool GetBooleanValue(bool fail_value=false) const
Return the boolean value if this data structure is a boolean type.
StructuredDataImplUP m_impl_up
void SetUnsignedIntegerValue(uint64_t value)
Change the type to unsigned interger and overwrite the previous data with the new value.
LLDB_DEPRECATED_FIXME("Specify if the value is signed or unsigned", "uint64_t GetUnsignedIntegerValue(uint64_t fail_value = 0)") uint64_t GetIntegerValue(uint64_t fail_value=0) const
lldb::StructuredDataType GetType() const
Return the type of data in this data structure.
uint64_t GetUnsignedIntegerValue(uint64_t fail_value=0) const
Return the integer value if this data structure is an integer type.
void SetSignedIntegerValue(int64_t value)
Change the type to signed interger and overwrite the previous data with the new value.
size_t GetSize() const
Return the size (i.e.
bool GetKeys(lldb::SBStringList &keys) const
Fill keys with the keys in this object and return true if this data structure is a dictionary.
lldb::SBError GetAsJSON(lldb::SBStream &stream) const
void SetFloatValue(double value)
Change the type to float and overwrite the previous data with the new value.
lldb::SBStructuredData GetValueForKey(const char *key) const
Return the value corresponding to a key if this data structure is a dictionary type.
lldb::SBError SetFromJSON(lldb::SBStream &stream)
double GetFloatValue(double fail_value=0.0) const
Return the floating point value if this data structure is a floating type.
friend class SBBreakpointLocation
friend class SBCommandInterpreter
void SetValueForKey(const char *key, SBStructuredData &value)
Set the value corresponding to a key.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Event > EventSP
std::unique_ptr< lldb_private::StructuredDataImpl > StructuredDataImplUP