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 
12 #include "lldb/API/SBDefines.h"
13 #include "lldb/API/SBModule.h"
14 
15 namespace lldb {
16 
18 public:
20 
22 
23  SBStructuredData(const lldb::EventSP &event_sp);
24 
26 
28 
30 
31  explicit operator bool() const;
32 
33  bool IsValid() const;
34 
36 
37  lldb::SBError SetFromJSON(const char *json);
38 
39  void Clear();
40 
41  lldb::SBError GetAsJSON(lldb::SBStream &stream) const;
42 
44 
45  /// Return the type of data in this data structure
47 
48  /// Return the size (i.e. number of elements) in this data structure
49  /// if it is an array or dictionary type. For other types, 0 will be
50  // returned.
51  size_t GetSize() const;
52 
53  /// Fill keys with the keys in this object and return true if this data
54  /// structure is a dictionary. Returns false otherwise.
55  bool GetKeys(lldb::SBStringList &keys) const;
56 
57  /// Return the value corresponding to a key if this data structure
58  /// is a dictionary type.
59  lldb::SBStructuredData GetValueForKey(const char *key) const;
60 
61  /// Return the value corresponding to an index if this data structure
62  /// is array.
63  lldb::SBStructuredData GetItemAtIndex(size_t idx) const;
64 
65  /// Return the integer value if this data structure is an integer type.
66  uint64_t GetIntegerValue(uint64_t fail_value = 0) const;
67 
68  /// Return the floating point value if this data structure is a floating
69  /// type.
70  double GetFloatValue(double fail_value = 0.0) const;
71 
72  /// Return the boolean value if this data structure is a boolean type.
73  bool GetBooleanValue(bool fail_value = false) const;
74 
75  /// Provides the string value if this data structure is a string type.
76  ///
77  /// \param[out] dst
78  /// pointer where the string value will be written. In case it is null,
79  /// nothing will be written at \a dst.
80  ///
81  /// \param[in] dst_len
82  /// max number of characters that can be written at \a dst. In case it is
83  /// zero, nothing will be written at \a dst. If this length is not enough
84  /// to write the complete string value, (\a dst_len - 1) bytes of the
85  /// string value will be written at \a dst followed by a null character.
86  ///
87  /// \return
88  /// Returns the byte size needed to completely write the string value at
89  /// \a dst in all cases.
90  size_t GetStringValue(char *dst, size_t dst_len) const;
91 
92 protected:
93  friend class SBLaunchInfo;
94  friend class SBDebugger;
95  friend class SBTarget;
96  friend class SBProcess;
97  friend class SBThread;
98  friend class SBThreadPlan;
99  friend class SBBreakpoint;
100  friend class SBBreakpointLocation;
101  friend class SBBreakpointName;
102  friend class SBTrace;
103 
104  StructuredDataImplUP m_impl_up;
105 };
106 } // namespace lldb
107 
108 #endif // LLDB_API_SBSTRUCTUREDDATA_H
lldb::SBBreakpointLocation
Definition: SBBreakpointLocation.h:17
lldb::SBStringList
Definition: SBStringList.h:16
lldb::StructuredDataType
StructuredDataType
Definition: lldb-enumerations.h:785
lldb::SBLaunchInfo
Definition: SBLaunchInfo.h:23
lldb::SBStructuredData::GetFloatValue
double GetFloatValue(double fail_value=0.0) const
Return the floating point value if this data structure is a floating type.
Definition: SBStructuredData.cpp:184
lldb::SBThread
Definition: SBThread.h:20
SBDefines.h
SBModule.h
lldb::SBStructuredData::GetDescription
lldb::SBError GetDescription(lldb::SBStream &stream) const
Definition: SBStructuredData.cpp:109
lldb::SBError
Definition: SBError.h:20
lldb::SBStructuredData::SBStructuredData
SBStructuredData()
Definition: SBStructuredData.cpp:27
lldb::SBProcess
Definition: SBProcess.h:23
lldb::SBStructuredData::GetItemAtIndex
lldb::SBStructuredData GetItemAtIndex(size_t idx) const
Return the value corresponding to an index if this data structure is array.
Definition: SBStructuredData.cpp:168
lldb::SBStructuredData::m_impl_up
StructuredDataImplUP m_impl_up
Definition: SBStructuredData.h:104
lldb::SBTrace
Definition: SBTrace.h:19
lldb::SBTarget
Definition: SBTarget.h:29
lldb::SBStructuredData::GetSize
size_t GetSize() const
Return the size (i.e.
Definition: SBStructuredData.cpp:126
lldb::SBDebugger
Definition: SBDebugger.h:34
lldb::SBStructuredData::GetAsJSON
lldb::SBError GetAsJSON(lldb::SBStream &stream) const
Definition: SBStructuredData.cpp:100
lldb::SBThreadPlan
Definition: SBThreadPlan.h:18
lldb::SBStructuredData::GetIntegerValue
uint64_t GetIntegerValue(uint64_t fail_value=0) const
Return the integer value if this data structure is an integer type.
Definition: SBStructuredData.cpp:177
lldb_private::StructuredDataImpl
Definition: StructuredDataImpl.h:26
lldb::SBStructuredData::operator=
lldb::SBStructuredData & operator=(const lldb::SBStructuredData &rhs)
Definition: SBStructuredData.cpp:51
lldb::SBStructuredData::GetKeys
bool GetKeys(lldb::SBStringList &keys) const
Fill keys with the keys in this object and return true if this data structure is a dictionary.
Definition: SBStructuredData.cpp:132
lldb::SBStructuredData::GetValueForKey
lldb::SBStructuredData GetValueForKey(const char *key) const
Return the value corresponding to a key if this data structure is a dictionary type.
Definition: SBStructuredData.cpp:159
lldb::SBStructuredData
Definition: SBStructuredData.h:17
lldb::SBBreakpoint
Definition: SBBreakpoint.h:18
lldb::SBStructuredData::GetBooleanValue
bool GetBooleanValue(bool fail_value=false) const
Return the boolean value if this data structure is a boolean type.
Definition: SBStructuredData.cpp:191
lldb::SBStructuredData::~SBStructuredData
~SBStructuredData()
lldb::SBStructuredData::GetType
lldb::StructuredDataType GetType() const
Return the type of data in this data structure.
Definition: SBStructuredData.cpp:119
lldb::SBStructuredData::SetFromJSON
lldb::SBError SetFromJSON(lldb::SBStream &stream)
Definition: SBStructuredData.cpp:60
lldb::SBStream
Definition: SBStream.h:18
lldb::SBBreakpointName
Definition: SBBreakpointName.h:18
lldb::SBStructuredData::GetStringValue
size_t GetStringValue(char *dst, size_t dst_len) const
Provides the string value if this data structure is a string type.
Definition: SBStructuredData.cpp:198
lldb
Definition: SBAddress.h:15
lldb::SBStructuredData::Clear
void Clear()
Definition: SBStructuredData.cpp:94
lldb::SBStructuredData::IsValid
bool IsValid() const
Definition: SBStructuredData.cpp:83