1 //===-- SBStructuredData.h --------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef SBStructuredData_h
11 #define SBStructuredData_h
13 #include "lldb/API/SBDefines.h"
14 #include "lldb/API/SBModule.h"
18 class SBStructuredData {
22 SBStructuredData(const lldb::SBStructuredData &rhs);
24 SBStructuredData(const lldb::EventSP &event_sp);
26 SBStructuredData(lldb_private::StructuredDataImpl *impl);
30 lldb::SBStructuredData &operator=(const lldb::SBStructuredData &rhs);
34 lldb::SBError SetFromJSON(lldb::SBStream &stream);
38 lldb::SBError GetAsJSON(lldb::SBStream &stream) const;
40 lldb::SBError GetDescription(lldb::SBStream &stream) const;
42 //------------------------------------------------------------------
43 /// Return the type of data in this data structure
44 //------------------------------------------------------------------
45 lldb::StructuredDataType GetType() const;
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
51 //------------------------------------------------------------------
52 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 //------------------------------------------------------------------
58 bool GetKeys(lldb::SBStringList &keys) const;
60 //------------------------------------------------------------------
61 /// Return the value corresponding to a key if this data structure
62 /// is a dictionary type.
63 //------------------------------------------------------------------
64 lldb::SBStructuredData GetValueForKey(const char *key) const;
66 //------------------------------------------------------------------
67 /// Return the value corresponding to an index if this data structure
69 //------------------------------------------------------------------
70 lldb::SBStructuredData GetItemAtIndex(size_t idx) const;
72 //------------------------------------------------------------------
73 /// Return the integer value if this data structure is an integer type.
74 //------------------------------------------------------------------
75 uint64_t GetIntegerValue(uint64_t fail_value = 0) const;
77 //------------------------------------------------------------------
78 /// Return the floating point value if this data structure is a floating
80 //------------------------------------------------------------------
81 double GetFloatValue(double fail_value = 0.0) const;
83 //------------------------------------------------------------------
84 /// Return the boolean value if this data structure is a boolean type.
85 //------------------------------------------------------------------
86 bool GetBooleanValue(bool fail_value = false) const;
88 //------------------------------------------------------------------
89 /// Provides the string value if this data structure is a string type.
92 /// pointer where the string value will be written. In case it is null,
93 /// nothing will be written at @dst.
95 /// @param[in] dst_len
96 /// max number of characters that can be written at @dst. In case it is
97 /// zero, nothing will be written at @dst. If this length is not enough
98 /// to write the complete string value, (dst_len-1) bytes of the string
99 /// value will be written at @dst followed by a null character.
102 /// Returns the byte size needed to completely write the string value at
103 /// @dst in all cases.
104 //------------------------------------------------------------------
105 size_t GetStringValue(char *dst, size_t dst_len) const;
108 friend class SBTraceOptions;
109 friend class SBDebugger;
110 friend class SBTarget;
112 StructuredDataImplUP m_impl_up;
116 #endif /* SBStructuredData_h */