]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lldb/include/lldb/API/SBStructuredData.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lldb / include / lldb / API / SBStructuredData.h
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
17 class SBStructuredData {
18 public:
19   SBStructuredData();
20
21   SBStructuredData(const lldb::SBStructuredData &rhs);
22
23   SBStructuredData(const lldb::EventSP &event_sp);
24   
25   SBStructuredData(lldb_private::StructuredDataImpl *impl);
26
27   ~SBStructuredData();
28
29   lldb::SBStructuredData &operator=(const lldb::SBStructuredData &rhs);
30
31   explicit operator bool() const;
32
33   bool IsValid() const;
34
35   lldb::SBError SetFromJSON(lldb::SBStream &stream);
36
37   void Clear();
38
39   lldb::SBError GetAsJSON(lldb::SBStream &stream) const;
40
41   lldb::SBError GetDescription(lldb::SBStream &stream) const;
42
43   /// Return the type of data in this data structure
44   lldb::StructuredDataType GetType() const;
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   friend class SBThread;
95   friend class SBThreadPlan;
96   friend class SBBreakpoint;
97   friend class SBBreakpointLocation;
98   friend class SBBreakpointName;
99
100   StructuredDataImplUP m_impl_up;
101 };
102 } // namespace lldb
103
104 #endif /* SBStructuredData_h */