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 SBStructuredData_h
10 #define 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  void Clear();
38 
39  lldb::SBError GetAsJSON(lldb::SBStream &stream) const;
40 
42 
43  /// Return the type of data in this data structure
45 
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
48  // returned.
49  size_t GetSize() const;
50 
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;
54 
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;
58 
59  /// Return the value corresponding to an index if this data structure
60  /// is array.
61  lldb::SBStructuredData GetItemAtIndex(size_t idx) const;
62 
63  /// Return the integer value if this data structure is an integer type.
64  uint64_t GetIntegerValue(uint64_t fail_value = 0) const;
65 
66  /// Return the floating point value if this data structure is a floating
67  /// type.
68  double GetFloatValue(double fail_value = 0.0) const;
69 
70  /// Return the boolean value if this data structure is a boolean type.
71  bool GetBooleanValue(bool fail_value = false) const;
72 
73  /// Provides the string value if this data structure is a string type.
74  ///
75  /// \param[out] dst
76  /// pointer where the string value will be written. In case it is null,
77  /// nothing will be written at \a dst.
78  ///
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.
84  ///
85  /// \return
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;
89 
90 protected:
91  friend class SBTraceOptions;
92  friend class SBDebugger;
93  friend class SBTarget;
94 
95  StructuredDataImplUP m_impl_up;
96 };
97 } // namespace lldb
98 
99 #endif /* SBStructuredData_h */
lldb::SBError GetAsJSON(lldb::SBStream &stream) const
size_t GetSize() const
Return the size (i.e.
lldb::SBError GetDescription(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.
bool GetBooleanValue(bool fail_value=false) const
Return the boolean value if this data structure is a boolean type.
uint64_t GetIntegerValue(uint64_t fail_value=0) const
Return the integer value if this data structure is an integer type.
size_t GetStringValue(char *dst, size_t dst_len) const
Provides the string value if this data structure is a string type.
double GetFloatValue(double fail_value=0.0) const
Return the floating point value if this data structure is a floating type.
StructuredDataImplUP m_impl_up
lldb::StructuredDataType GetType() const
Return the type of data in this data structure.
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::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)
Definition: SBAddress.h:15
lldb::SBError SetFromJSON(lldb::SBStream &stream)