1061da546Spatrick //===-- SBStructuredData.h --------------------------------------*- C++ -*-===//
2061da546Spatrick //
3061da546Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4061da546Spatrick // See https://llvm.org/LICENSE.txt for license information.
5061da546Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6061da546Spatrick //
7061da546Spatrick //===----------------------------------------------------------------------===//
8061da546Spatrick 
9dda28197Spatrick #ifndef LLDB_API_SBSTRUCTUREDDATA_H
10dda28197Spatrick #define LLDB_API_SBSTRUCTUREDDATA_H
11061da546Spatrick 
12061da546Spatrick #include "lldb/API/SBDefines.h"
13061da546Spatrick #include "lldb/API/SBModule.h"
14061da546Spatrick 
15061da546Spatrick namespace lldb {
16061da546Spatrick 
17061da546Spatrick class SBStructuredData {
18061da546Spatrick public:
19061da546Spatrick   SBStructuredData();
20061da546Spatrick 
21061da546Spatrick   SBStructuredData(const lldb::SBStructuredData &rhs);
22061da546Spatrick 
23061da546Spatrick   SBStructuredData(const lldb::EventSP &event_sp);
24061da546Spatrick 
25*f6aab3d8Srobert   SBStructuredData(const lldb_private::StructuredDataImpl &impl);
26061da546Spatrick 
27061da546Spatrick   ~SBStructuredData();
28061da546Spatrick 
29061da546Spatrick   lldb::SBStructuredData &operator=(const lldb::SBStructuredData &rhs);
30061da546Spatrick 
31061da546Spatrick   explicit operator bool() const;
32061da546Spatrick 
33061da546Spatrick   bool IsValid() const;
34061da546Spatrick 
35061da546Spatrick   lldb::SBError SetFromJSON(lldb::SBStream &stream);
36061da546Spatrick 
37be691f3bSpatrick   lldb::SBError SetFromJSON(const char *json);
38be691f3bSpatrick 
39061da546Spatrick   void Clear();
40061da546Spatrick 
41061da546Spatrick   lldb::SBError GetAsJSON(lldb::SBStream &stream) const;
42061da546Spatrick 
43061da546Spatrick   lldb::SBError GetDescription(lldb::SBStream &stream) const;
44061da546Spatrick 
45061da546Spatrick   /// Return the type of data in this data structure
46061da546Spatrick   lldb::StructuredDataType GetType() const;
47061da546Spatrick 
48061da546Spatrick   /// Return the size (i.e. number of elements) in this data structure
49061da546Spatrick   /// if it is an array or dictionary type. For other types, 0 will be
50061da546Spatrick   //  returned.
51061da546Spatrick   size_t GetSize() const;
52061da546Spatrick 
53061da546Spatrick   /// Fill keys with the keys in this object and return true if this data
54061da546Spatrick   /// structure is a dictionary.  Returns false otherwise.
55061da546Spatrick    bool GetKeys(lldb::SBStringList &keys) const;
56061da546Spatrick 
57061da546Spatrick   /// Return the value corresponding to a key if this data structure
58061da546Spatrick   /// is a dictionary type.
59061da546Spatrick   lldb::SBStructuredData GetValueForKey(const char *key) const;
60061da546Spatrick 
61061da546Spatrick   /// Return the value corresponding to an index if this data structure
62061da546Spatrick   /// is array.
63061da546Spatrick   lldb::SBStructuredData GetItemAtIndex(size_t idx) const;
64061da546Spatrick 
65061da546Spatrick   /// Return the integer value if this data structure is an integer type.
66061da546Spatrick   uint64_t GetIntegerValue(uint64_t fail_value = 0) const;
67061da546Spatrick 
68061da546Spatrick   /// Return the floating point value if this data structure is a floating
69061da546Spatrick   /// type.
70061da546Spatrick   double GetFloatValue(double fail_value = 0.0) const;
71061da546Spatrick 
72061da546Spatrick   /// Return the boolean value if this data structure is a boolean type.
73061da546Spatrick   bool GetBooleanValue(bool fail_value = false) const;
74061da546Spatrick 
75061da546Spatrick   /// Provides the string value if this data structure is a string type.
76061da546Spatrick   ///
77061da546Spatrick   /// \param[out] dst
78061da546Spatrick   ///     pointer where the string value will be written. In case it is null,
79061da546Spatrick   ///     nothing will be written at \a dst.
80061da546Spatrick   ///
81061da546Spatrick   /// \param[in] dst_len
82061da546Spatrick   ///     max number of characters that can be written at \a dst. In case it is
83061da546Spatrick   ///     zero, nothing will be written at \a dst. If this length is not enough
84061da546Spatrick   ///     to write the complete string value, (\a dst_len - 1) bytes of the
85061da546Spatrick   ///     string value will be written at \a dst followed by a null character.
86061da546Spatrick   ///
87061da546Spatrick   /// \return
88061da546Spatrick   ///     Returns the byte size needed to completely write the string value at
89061da546Spatrick   ///     \a dst in all cases.
90061da546Spatrick   size_t GetStringValue(char *dst, size_t dst_len) const;
91061da546Spatrick 
92061da546Spatrick protected:
93be691f3bSpatrick   friend class SBLaunchInfo;
94061da546Spatrick   friend class SBDebugger;
95061da546Spatrick   friend class SBTarget;
96dda28197Spatrick   friend class SBProcess;
97061da546Spatrick   friend class SBThread;
98061da546Spatrick   friend class SBThreadPlan;
99061da546Spatrick   friend class SBBreakpoint;
100061da546Spatrick   friend class SBBreakpointLocation;
101061da546Spatrick   friend class SBBreakpointName;
102be691f3bSpatrick   friend class SBTrace;
103061da546Spatrick 
104061da546Spatrick   StructuredDataImplUP m_impl_up;
105061da546Spatrick };
106061da546Spatrick } // namespace lldb
107061da546Spatrick 
108dda28197Spatrick #endif // LLDB_API_SBSTRUCTUREDDATA_H
109