]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/API/SBStructuredData.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / API / SBStructuredData.h
1 //===-- SBStructuredData.h --------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef SBStructuredData_h
11 #define SBStructuredData_h
12
13 #include "lldb/API/SBDefines.h"
14 #include "lldb/API/SBModule.h"
15
16 namespace lldb {
17
18 class SBStructuredData {
19 public:
20   SBStructuredData();
21
22   SBStructuredData(const lldb::SBStructuredData &rhs);
23
24   SBStructuredData(const lldb::EventSP &event_sp);
25
26   ~SBStructuredData();
27
28   lldb::SBStructuredData &operator=(const lldb::SBStructuredData &rhs);
29
30   bool IsValid() const;
31
32   lldb::SBError SetFromJSON(lldb::SBStream &stream);
33
34   void Clear();
35
36   lldb::SBError GetAsJSON(lldb::SBStream &stream) const;
37
38   lldb::SBError GetDescription(lldb::SBStream &stream) const;
39
40   //------------------------------------------------------------------
41   /// Return the type of data in this data structure
42   //------------------------------------------------------------------
43   lldb::StructuredDataType GetType() const;
44
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   //------------------------------------------------------------------
50   size_t GetSize() const;
51
52   //------------------------------------------------------------------
53   /// Return the value corresponding to a key if this data structure
54   /// is a dictionary type.
55   //------------------------------------------------------------------
56   lldb::SBStructuredData GetValueForKey(const char *key) const;
57
58   //------------------------------------------------------------------
59   /// Return the value corresponding to an index if this data structure
60   /// is array.
61   //------------------------------------------------------------------
62   lldb::SBStructuredData GetItemAtIndex(size_t idx) const;
63
64   //------------------------------------------------------------------
65   /// Return the integer value if this data structure is an integer type.
66   //------------------------------------------------------------------
67   uint64_t GetIntegerValue(uint64_t fail_value = 0) const;
68
69   //------------------------------------------------------------------
70   /// Return the floating point value if this data structure is a floating
71   /// type.
72   //------------------------------------------------------------------
73   double GetFloatValue(double fail_value = 0.0) const;
74
75   //------------------------------------------------------------------
76   /// Return the boolean value if this data structure is a boolean type.
77   //------------------------------------------------------------------
78   bool GetBooleanValue(bool fail_value = false) const;
79
80   //------------------------------------------------------------------
81   /// Provides the string value if this data structure is a string type.
82   ///
83   /// @param[out] dst
84   ///     pointer where the string value will be written. In case it is null,
85   ///     nothing will be written at @dst.
86   ///
87   /// @param[in] dst_len
88   ///     max number of characters that can be written at @dst. In case it is
89   ///     zero, nothing will be written at @dst. If this length is not enough
90   ///     to write the complete string value, (dst_len-1) bytes of the string
91   ///     value will be written at @dst followed by a null character.
92   ///
93   /// @return
94   ///     Returns the byte size needed to completely write the string value at
95   ///     @dst in all cases.
96   //------------------------------------------------------------------
97   size_t GetStringValue(char *dst, size_t dst_len) const;
98
99 protected:
100   friend class SBTraceOptions;
101   friend class SBDebugger;
102   friend class SBTarget;
103
104   StructuredDataImplUP m_impl_up;
105 };
106 } // namespace lldb
107
108 #endif /* SBStructuredData_h */