1 //===-- SBStructuredData.h --------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef SBStructuredData_h
10 #define SBStructuredData_h
12 #include "lldb/API/SBDefines.h"
13 #include "lldb/API/SBModule.h"
17 class SBStructuredData {
21 SBStructuredData(const lldb::SBStructuredData &rhs);
23 SBStructuredData(const lldb::EventSP &event_sp);
25 SBStructuredData(lldb_private::StructuredDataImpl *impl);
29 lldb::SBStructuredData &operator=(const lldb::SBStructuredData &rhs);
31 explicit operator bool() const;
35 lldb::SBError SetFromJSON(lldb::SBStream &stream);
39 lldb::SBError GetAsJSON(lldb::SBStream &stream) const;
41 lldb::SBError GetDescription(lldb::SBStream &stream) const;
43 /// Return the type of data in this data structure
44 lldb::StructuredDataType GetType() const;
46 /// Return the size (i.e. number of elements) in this data structure
47 /// if it is an array or dictionary type. For other types, 0 will be
49 size_t GetSize() const;
51 /// Fill keys with the keys in this object and return true if this data
52 /// structure is a dictionary. Returns false otherwise.
53 bool GetKeys(lldb::SBStringList &keys) const;
55 /// Return the value corresponding to a key if this data structure
56 /// is a dictionary type.
57 lldb::SBStructuredData GetValueForKey(const char *key) const;
59 /// Return the value corresponding to an index if this data structure
61 lldb::SBStructuredData GetItemAtIndex(size_t idx) const;
63 /// Return the integer value if this data structure is an integer type.
64 uint64_t GetIntegerValue(uint64_t fail_value = 0) const;
66 /// Return the floating point value if this data structure is a floating
68 double GetFloatValue(double fail_value = 0.0) const;
70 /// Return the boolean value if this data structure is a boolean type.
71 bool GetBooleanValue(bool fail_value = false) const;
73 /// Provides the string value if this data structure is a string type.
76 /// pointer where the string value will be written. In case it is null,
77 /// nothing will be written at \a dst.
79 /// \param[in] dst_len
80 /// max number of characters that can be written at \a dst. In case it is
81 /// zero, nothing will be written at \a dst. If this length is not enough
82 /// to write the complete string value, (\a dst_len - 1) bytes of the
83 /// string value will be written at \a dst followed by a null character.
86 /// Returns the byte size needed to completely write the string value at
87 /// \a dst in all cases.
88 size_t GetStringValue(char *dst, size_t dst_len) const;
91 friend class SBTraceOptions;
92 friend class SBDebugger;
93 friend class SBTarget;
94 friend class SBThread;
95 friend class SBThreadPlan;
96 friend class SBBreakpoint;
97 friend class SBBreakpointLocation;
98 friend class SBBreakpointName;
100 StructuredDataImplUP m_impl_up;
104 #endif /* SBStructuredData_h */