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