1 //===-- DataVisualization.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 lldb_DataVisualization_h_
10 #define lldb_DataVisualization_h_
11 
12 
13 #include "lldb/DataFormatters/FormatClasses.h"
14 #include "lldb/DataFormatters/FormatManager.h"
15 #include "lldb/Utility/ConstString.h"
16 
17 namespace lldb_private {
18 
19 // this class is the high-level front-end of LLDB Data Visualization code in
20 // FormatManager.h/cpp is the low-level implementation of this feature clients
21 // should refer to this class as the entry-point into the data formatters
22 // unless they have a good reason to bypass this and go to the backend
23 class DataVisualization {
24 public:
25   // use this call to force the FM to consider itself updated even when there
26   // is no apparent reason for that
27   static void ForceUpdate();
28 
29   static uint32_t GetCurrentRevision();
30 
31   static bool ShouldPrintAsOneLiner(ValueObject &valobj);
32 
33   static lldb::TypeFormatImplSP GetFormat(ValueObject &valobj,
34                                           lldb::DynamicValueType use_dynamic);
35 
36   static lldb::TypeFormatImplSP
37   GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp);
38 
39   static lldb::TypeSummaryImplSP
40   GetSummaryFormat(ValueObject &valobj, lldb::DynamicValueType use_dynamic);
41 
42   static lldb::TypeSummaryImplSP
43   GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp);
44 
45   static lldb::TypeFilterImplSP
46   GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp);
47 
48   static lldb::ScriptedSyntheticChildrenSP
49   GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp);
50 
51   static lldb::SyntheticChildrenSP
52   GetSyntheticChildren(ValueObject &valobj, lldb::DynamicValueType use_dynamic);
53 
54   static bool
55   AnyMatches(ConstString type_name,
56              TypeCategoryImpl::FormatCategoryItems items =
57                  TypeCategoryImpl::ALL_ITEM_TYPES,
58              bool only_enabled = true, const char **matching_category = nullptr,
59              TypeCategoryImpl::FormatCategoryItems *matching_type = nullptr);
60 
61   class NamedSummaryFormats {
62   public:
63     static bool GetSummaryFormat(ConstString type,
64                                  lldb::TypeSummaryImplSP &entry);
65 
66     static void Add(ConstString type,
67                     const lldb::TypeSummaryImplSP &entry);
68 
69     static bool Delete(ConstString type);
70 
71     static void Clear();
72 
73     static void
74     ForEach(std::function<bool(ConstString, const lldb::TypeSummaryImplSP &)>
75                 callback);
76 
77     static uint32_t GetCount();
78   };
79 
80   class Categories {
81   public:
82     static bool GetCategory(ConstString category,
83                             lldb::TypeCategoryImplSP &entry,
84                             bool allow_create = true);
85 
86     static bool GetCategory(lldb::LanguageType language,
87                             lldb::TypeCategoryImplSP &entry);
88 
89     static void Add(ConstString category);
90 
91     static bool Delete(ConstString category);
92 
93     static void Clear();
94 
95     static void Clear(ConstString category);
96 
97     static void Enable(ConstString category,
98                        TypeCategoryMap::Position = TypeCategoryMap::Default);
99 
100     static void Enable(lldb::LanguageType lang_type);
101 
102     static void Disable(ConstString category);
103 
104     static void Disable(lldb::LanguageType lang_type);
105 
106     static void Enable(const lldb::TypeCategoryImplSP &category,
107                        TypeCategoryMap::Position = TypeCategoryMap::Default);
108 
109     static void Disable(const lldb::TypeCategoryImplSP &category);
110 
111     static void EnableStar();
112 
113     static void DisableStar();
114 
115     static void ForEach(TypeCategoryMap::ForEachCallback callback);
116 
117     static uint32_t GetCount();
118 
119     static lldb::TypeCategoryImplSP GetCategoryAtIndex(size_t);
120   };
121 };
122 
123 } // namespace lldb_private
124 
125 #endif // lldb_DataVisualization_h_
126