1 //===-- SBTypeSummary.h -------------------------------------------*- C++
2 //-*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLDB_SBTypeSummary_h_
11 #define LLDB_SBTypeSummary_h_
12 
13 #include "lldb/API/SBDefines.h"
14 
15 namespace lldb {
16 class LLDB_API SBTypeSummaryOptions {
17 public:
18   SBTypeSummaryOptions();
19 
20   SBTypeSummaryOptions(const lldb::SBTypeSummaryOptions &rhs);
21 
22   SBTypeSummaryOptions(const lldb_private::TypeSummaryOptions *lldb_object_ptr);
23 
24   ~SBTypeSummaryOptions();
25 
26   explicit operator bool() const;
27 
28   bool IsValid();
29 
30   lldb::LanguageType GetLanguage();
31 
32   lldb::TypeSummaryCapping GetCapping();
33 
34   void SetLanguage(lldb::LanguageType);
35 
36   void SetCapping(lldb::TypeSummaryCapping);
37 
38 protected:
39   friend class SBValue;
40 
41   lldb_private::TypeSummaryOptions *operator->();
42 
43   const lldb_private::TypeSummaryOptions *operator->() const;
44 
45   lldb_private::TypeSummaryOptions *get();
46 
47   lldb_private::TypeSummaryOptions &ref();
48 
49   const lldb_private::TypeSummaryOptions &ref() const;
50 
51   void SetOptions(const lldb_private::TypeSummaryOptions *lldb_object_ptr);
52 
53 private:
54   std::unique_ptr<lldb_private::TypeSummaryOptions> m_opaque_up;
55 };
56 
57 class SBTypeSummary {
58 public:
59   SBTypeSummary();
60 
61   // Native function summary formatter callback
62   typedef bool (*FormatCallback)(SBValue, SBTypeSummaryOptions, SBStream &);
63 
64   static SBTypeSummary
65   CreateWithSummaryString(const char *data,
66                           uint32_t options = 0); // see lldb::eTypeOption values
67 
68   static SBTypeSummary
69   CreateWithFunctionName(const char *data,
70                          uint32_t options = 0); // see lldb::eTypeOption values
71 
72   static SBTypeSummary
73   CreateWithScriptCode(const char *data,
74                        uint32_t options = 0); // see lldb::eTypeOption values
75 
76   static SBTypeSummary CreateWithCallback(FormatCallback cb,
77                                           uint32_t options = 0,
78                                           const char *description = nullptr);
79 
80   SBTypeSummary(const lldb::SBTypeSummary &rhs);
81 
82   ~SBTypeSummary();
83 
84   explicit operator bool() const;
85 
86   bool IsValid() const;
87 
88   bool IsFunctionCode();
89 
90   bool IsFunctionName();
91 
92   bool IsSummaryString();
93 
94   const char *GetData();
95 
96   void SetSummaryString(const char *data);
97 
98   void SetFunctionName(const char *data);
99 
100   void SetFunctionCode(const char *data);
101 
102   uint32_t GetOptions();
103 
104   void SetOptions(uint32_t);
105 
106   bool GetDescription(lldb::SBStream &description,
107                       lldb::DescriptionLevel description_level);
108 
109   lldb::SBTypeSummary &operator=(const lldb::SBTypeSummary &rhs);
110 
111   bool DoesPrintValue(lldb::SBValue value);
112 
113   bool IsEqualTo(lldb::SBTypeSummary &rhs);
114 
115   bool operator==(lldb::SBTypeSummary &rhs);
116 
117   bool operator!=(lldb::SBTypeSummary &rhs);
118 
119 protected:
120   friend class SBDebugger;
121   friend class SBTypeCategory;
122   friend class SBValue;
123 
124   lldb::TypeSummaryImplSP GetSP();
125 
126   void SetSP(const lldb::TypeSummaryImplSP &typefilter_impl_sp);
127 
128   lldb::TypeSummaryImplSP m_opaque_sp;
129 
130   SBTypeSummary(const lldb::TypeSummaryImplSP &);
131 
132   bool CopyOnWrite_Impl();
133 
134   bool ChangeSummaryType(bool want_script);
135 };
136 
137 } // namespace lldb
138 
139 #endif // LLDB_SBTypeSummary_h_
140