1 //===-- DataVisualization.cpp ---------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/DataFormatters/DataVisualization.h"
14 // Other libraries and framework includes
18 using namespace lldb_private;
23 static FormatManager g_format_manager;
24 return g_format_manager;
28 DataVisualization::ForceUpdate ()
30 GetFormatManager().Changed();
34 DataVisualization::GetCurrentRevision ()
36 return GetFormatManager().GetCurrentRevision();
40 DataVisualization::ShouldPrintAsOneLiner (ValueObject& valobj)
42 return GetFormatManager().ShouldPrintAsOneLiner(valobj);
45 lldb::TypeFormatImplSP
46 DataVisualization::GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
48 return GetFormatManager().GetFormat(valobj, use_dynamic);
51 lldb::TypeFormatImplSP
52 DataVisualization::GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp)
54 return GetFormatManager().GetFormatForType(type_sp);
57 lldb::TypeSummaryImplSP
58 DataVisualization::GetSummaryFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
60 return GetFormatManager().GetSummaryFormat(valobj, use_dynamic);
63 lldb::TypeSummaryImplSP
64 DataVisualization::GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp)
66 return GetFormatManager().GetSummaryForType(type_sp);
69 #ifndef LLDB_DISABLE_PYTHON
70 lldb::SyntheticChildrenSP
71 DataVisualization::GetSyntheticChildren (ValueObject& valobj,
72 lldb::DynamicValueType use_dynamic)
74 return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic);
78 #ifndef LLDB_DISABLE_PYTHON
79 lldb::SyntheticChildrenSP
80 DataVisualization::GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp)
82 return GetFormatManager().GetSyntheticChildrenForType(type_sp);
86 lldb::TypeFilterImplSP
87 DataVisualization::GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp)
89 return GetFormatManager().GetFilterForType(type_sp);
92 #ifndef LLDB_DISABLE_PYTHON
93 lldb::ScriptedSyntheticChildrenSP
94 DataVisualization::GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp)
96 return GetFormatManager().GetSyntheticForType(type_sp);
100 lldb::TypeValidatorImplSP
101 DataVisualization::GetValidator (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
103 return GetFormatManager().GetValidator(valobj, use_dynamic);
106 lldb::TypeValidatorImplSP
107 DataVisualization::GetValidatorForType (lldb::TypeNameSpecifierImplSP type_sp)
109 return GetFormatManager().GetValidatorForType(type_sp);
113 DataVisualization::AnyMatches (ConstString type_name,
114 TypeCategoryImpl::FormatCategoryItems items,
116 const char** matching_category,
117 TypeCategoryImpl::FormatCategoryItems* matching_type)
119 return GetFormatManager().AnyMatches(type_name,
127 DataVisualization::Categories::GetCategory (const ConstString &category, lldb::TypeCategoryImplSP &entry,
130 entry = GetFormatManager().GetCategory(category, allow_create);
131 return (entry.get() != NULL);
135 DataVisualization::Categories::GetCategory (lldb::LanguageType language, lldb::TypeCategoryImplSP &entry)
137 if (LanguageCategory *lang_category = GetFormatManager().GetCategoryForLanguage(language))
138 entry = lang_category->GetCategory();
139 return (entry.get() != nullptr);
143 DataVisualization::Categories::Add (const ConstString &category)
145 GetFormatManager().GetCategory(category);
149 DataVisualization::Categories::Delete (const ConstString &category)
151 GetFormatManager().DisableCategory(category);
152 return GetFormatManager().DeleteCategory(category);
156 DataVisualization::Categories::Clear ()
158 GetFormatManager().ClearCategories();
162 DataVisualization::Categories::Clear (const ConstString &category)
164 GetFormatManager().GetCategory(category)->Clear(eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary);
168 DataVisualization::Categories::Enable (const ConstString& category,
169 TypeCategoryMap::Position pos)
171 if (GetFormatManager().GetCategory(category)->IsEnabled())
172 GetFormatManager().DisableCategory(category);
173 GetFormatManager().EnableCategory(category, pos, std::initializer_list<lldb::LanguageType>());
177 DataVisualization::Categories::Enable (lldb::LanguageType lang_type)
179 if (LanguageCategory* lang_category = GetFormatManager().GetCategoryForLanguage(lang_type))
180 lang_category->Enable();
184 DataVisualization::Categories::Disable (const ConstString& category)
186 if (GetFormatManager().GetCategory(category)->IsEnabled() == true)
187 GetFormatManager().DisableCategory(category);
191 DataVisualization::Categories::Disable (lldb::LanguageType lang_type)
193 if (LanguageCategory* lang_category = GetFormatManager().GetCategoryForLanguage(lang_type))
194 lang_category->Disable();
198 DataVisualization::Categories::Enable (const lldb::TypeCategoryImplSP& category,
199 TypeCategoryMap::Position pos)
203 if (category->IsEnabled())
204 GetFormatManager().DisableCategory(category);
205 GetFormatManager().EnableCategory(category, pos);
210 DataVisualization::Categories::Disable (const lldb::TypeCategoryImplSP& category)
212 if (category.get() && category->IsEnabled() == true)
213 GetFormatManager().DisableCategory(category);
217 DataVisualization::Categories::EnableStar ()
219 GetFormatManager().EnableAllCategories ();
223 DataVisualization::Categories::DisableStar ()
225 GetFormatManager().DisableAllCategories();
229 DataVisualization::Categories::ForEach (TypeCategoryMap::ForEachCallback callback)
231 GetFormatManager().ForEachCategory(callback);
235 DataVisualization::Categories::GetCount ()
237 return GetFormatManager().GetCategoriesCount();
240 lldb::TypeCategoryImplSP
241 DataVisualization::Categories::GetCategoryAtIndex (size_t index)
243 return GetFormatManager().GetCategoryAtIndex(index);
247 DataVisualization::NamedSummaryFormats::GetSummaryFormat (const ConstString &type, lldb::TypeSummaryImplSP &entry)
249 return GetFormatManager().GetNamedSummaryContainer().Get(type,entry);
253 DataVisualization::NamedSummaryFormats::Add (const ConstString &type, const lldb::TypeSummaryImplSP &entry)
255 GetFormatManager().GetNamedSummaryContainer().Add(FormatManager::GetValidTypeName(type),entry);
259 DataVisualization::NamedSummaryFormats::Delete (const ConstString &type)
261 return GetFormatManager().GetNamedSummaryContainer().Delete(type);
265 DataVisualization::NamedSummaryFormats::Clear ()
267 GetFormatManager().GetNamedSummaryContainer().Clear();
271 DataVisualization::NamedSummaryFormats::ForEach (std::function<bool(ConstString, const lldb::TypeSummaryImplSP&)> callback)
273 GetFormatManager().GetNamedSummaryContainer().ForEach(callback);
277 DataVisualization::NamedSummaryFormats::GetCount ()
279 return GetFormatManager().GetNamedSummaryContainer().GetCount();