]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/API/SBStructuredData.h
MFV r348548: 9617 too-frequent TXG sync causes excessive write inflation
[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(lldb_private::StructuredDataImpl *impl);
27
28   ~SBStructuredData();
29
30   lldb::SBStructuredData &operator=(const lldb::SBStructuredData &rhs);
31
32   bool IsValid() const;
33
34   lldb::SBError SetFromJSON(lldb::SBStream &stream);
35
36   void Clear();
37
38   lldb::SBError GetAsJSON(lldb::SBStream &stream) const;
39
40   lldb::SBError GetDescription(lldb::SBStream &stream) const;
41
42   //------------------------------------------------------------------
43   /// Return the type of data in this data structure
44   //------------------------------------------------------------------
45   lldb::StructuredDataType GetType() const;
46   
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
50   //  returned.
51   //------------------------------------------------------------------
52   size_t GetSize() const;
53
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;
59   
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;
65
66   //------------------------------------------------------------------
67   /// Return the value corresponding to an index if this data structure
68   /// is array.
69   //------------------------------------------------------------------
70   lldb::SBStructuredData GetItemAtIndex(size_t idx) const;
71
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;
76
77   //------------------------------------------------------------------
78   /// Return the floating point value if this data structure is a floating
79   /// type.
80   //------------------------------------------------------------------
81   double GetFloatValue(double fail_value = 0.0) const;
82
83   //------------------------------------------------------------------
84   /// Return the boolean value if this data structure is a boolean type.
85   //------------------------------------------------------------------
86   bool GetBooleanValue(bool fail_value = false) const;
87
88   //------------------------------------------------------------------
89   /// Provides the string value if this data structure is a string type.
90   ///
91   /// @param[out] dst
92   ///     pointer where the string value will be written. In case it is null,
93   ///     nothing will be written at @dst.
94   ///
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.
100   ///
101   /// @return
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;
106
107 protected:
108   friend class SBTraceOptions;
109   friend class SBDebugger;
110   friend class SBTarget;
111
112   StructuredDataImplUP m_impl_up;
113 };
114 } // namespace lldb
115
116 #endif /* SBStructuredData_h */