1 //===-- DataVisualization.cpp ---------------------------------------*- C++
4 // The LLVM Compiler Infrastructure
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #include "lldb/DataFormatters/DataVisualization.h"
15 // Other libraries and framework includes
19 using namespace lldb_private;
21 static FormatManager &GetFormatManager() {
22 static FormatManager g_format_manager;
23 return g_format_manager;
26 void DataVisualization::ForceUpdate() { GetFormatManager().Changed(); }
28 uint32_t DataVisualization::GetCurrentRevision() {
29 return GetFormatManager().GetCurrentRevision();
32 bool DataVisualization::ShouldPrintAsOneLiner(ValueObject &valobj) {
33 return GetFormatManager().ShouldPrintAsOneLiner(valobj);
36 lldb::TypeFormatImplSP
37 DataVisualization::GetFormat(ValueObject &valobj,
38 lldb::DynamicValueType use_dynamic) {
39 return GetFormatManager().GetFormat(valobj, use_dynamic);
42 lldb::TypeFormatImplSP
43 DataVisualization::GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp) {
44 return GetFormatManager().GetFormatForType(type_sp);
47 lldb::TypeSummaryImplSP
48 DataVisualization::GetSummaryFormat(ValueObject &valobj,
49 lldb::DynamicValueType use_dynamic) {
50 return GetFormatManager().GetSummaryFormat(valobj, use_dynamic);
53 lldb::TypeSummaryImplSP
54 DataVisualization::GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp) {
55 return GetFormatManager().GetSummaryForType(type_sp);
58 #ifndef LLDB_DISABLE_PYTHON
59 lldb::SyntheticChildrenSP
60 DataVisualization::GetSyntheticChildren(ValueObject &valobj,
61 lldb::DynamicValueType use_dynamic) {
62 return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic);
66 #ifndef LLDB_DISABLE_PYTHON
67 lldb::SyntheticChildrenSP DataVisualization::GetSyntheticChildrenForType(
68 lldb::TypeNameSpecifierImplSP type_sp) {
69 return GetFormatManager().GetSyntheticChildrenForType(type_sp);
73 lldb::TypeFilterImplSP
74 DataVisualization::GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp) {
75 return GetFormatManager().GetFilterForType(type_sp);
78 #ifndef LLDB_DISABLE_PYTHON
79 lldb::ScriptedSyntheticChildrenSP
80 DataVisualization::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) {
81 return GetFormatManager().GetSyntheticForType(type_sp);
85 lldb::TypeValidatorImplSP
86 DataVisualization::GetValidator(ValueObject &valobj,
87 lldb::DynamicValueType use_dynamic) {
88 return GetFormatManager().GetValidator(valobj, use_dynamic);
91 lldb::TypeValidatorImplSP
92 DataVisualization::GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp) {
93 return GetFormatManager().GetValidatorForType(type_sp);
96 bool DataVisualization::AnyMatches(
97 ConstString type_name, TypeCategoryImpl::FormatCategoryItems items,
98 bool only_enabled, const char **matching_category,
99 TypeCategoryImpl::FormatCategoryItems *matching_type) {
100 return GetFormatManager().AnyMatches(type_name, items, only_enabled,
101 matching_category, matching_type);
104 bool DataVisualization::Categories::GetCategory(const ConstString &category,
105 lldb::TypeCategoryImplSP &entry,
107 entry = GetFormatManager().GetCategory(category, allow_create);
108 return (entry.get() != NULL);
111 bool DataVisualization::Categories::GetCategory(
112 lldb::LanguageType language, lldb::TypeCategoryImplSP &entry) {
113 if (LanguageCategory *lang_category =
114 GetFormatManager().GetCategoryForLanguage(language))
115 entry = lang_category->GetCategory();
116 return (entry.get() != nullptr);
119 void DataVisualization::Categories::Add(const ConstString &category) {
120 GetFormatManager().GetCategory(category);
123 bool DataVisualization::Categories::Delete(const ConstString &category) {
124 GetFormatManager().DisableCategory(category);
125 return GetFormatManager().DeleteCategory(category);
128 void DataVisualization::Categories::Clear() {
129 GetFormatManager().ClearCategories();
132 void DataVisualization::Categories::Clear(const ConstString &category) {
133 GetFormatManager().GetCategory(category)->Clear(
134 eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary);
137 void DataVisualization::Categories::Enable(const ConstString &category,
138 TypeCategoryMap::Position pos) {
139 if (GetFormatManager().GetCategory(category)->IsEnabled())
140 GetFormatManager().DisableCategory(category);
141 GetFormatManager().EnableCategory(
142 category, pos, std::initializer_list<lldb::LanguageType>());
145 void DataVisualization::Categories::Enable(lldb::LanguageType lang_type) {
146 if (LanguageCategory *lang_category =
147 GetFormatManager().GetCategoryForLanguage(lang_type))
148 lang_category->Enable();
151 void DataVisualization::Categories::Disable(const ConstString &category) {
152 if (GetFormatManager().GetCategory(category)->IsEnabled() == true)
153 GetFormatManager().DisableCategory(category);
156 void DataVisualization::Categories::Disable(lldb::LanguageType lang_type) {
157 if (LanguageCategory *lang_category =
158 GetFormatManager().GetCategoryForLanguage(lang_type))
159 lang_category->Disable();
162 void DataVisualization::Categories::Enable(
163 const lldb::TypeCategoryImplSP &category, TypeCategoryMap::Position pos) {
164 if (category.get()) {
165 if (category->IsEnabled())
166 GetFormatManager().DisableCategory(category);
167 GetFormatManager().EnableCategory(category, pos);
171 void DataVisualization::Categories::Disable(
172 const lldb::TypeCategoryImplSP &category) {
173 if (category.get() && category->IsEnabled() == true)
174 GetFormatManager().DisableCategory(category);
177 void DataVisualization::Categories::EnableStar() {
178 GetFormatManager().EnableAllCategories();
181 void DataVisualization::Categories::DisableStar() {
182 GetFormatManager().DisableAllCategories();
185 void DataVisualization::Categories::ForEach(
186 TypeCategoryMap::ForEachCallback callback) {
187 GetFormatManager().ForEachCategory(callback);
190 uint32_t DataVisualization::Categories::GetCount() {
191 return GetFormatManager().GetCategoriesCount();
194 lldb::TypeCategoryImplSP
195 DataVisualization::Categories::GetCategoryAtIndex(size_t index) {
196 return GetFormatManager().GetCategoryAtIndex(index);
199 bool DataVisualization::NamedSummaryFormats::GetSummaryFormat(
200 const ConstString &type, lldb::TypeSummaryImplSP &entry) {
201 return GetFormatManager().GetNamedSummaryContainer().Get(type, entry);
204 void DataVisualization::NamedSummaryFormats::Add(
205 const ConstString &type, const lldb::TypeSummaryImplSP &entry) {
206 GetFormatManager().GetNamedSummaryContainer().Add(
207 FormatManager::GetValidTypeName(type), entry);
210 bool DataVisualization::NamedSummaryFormats::Delete(const ConstString &type) {
211 return GetFormatManager().GetNamedSummaryContainer().Delete(type);
214 void DataVisualization::NamedSummaryFormats::Clear() {
215 GetFormatManager().GetNamedSummaryContainer().Clear();
218 void DataVisualization::NamedSummaryFormats::ForEach(
219 std::function<bool(ConstString, const lldb::TypeSummaryImplSP &)>
221 GetFormatManager().GetNamedSummaryContainer().ForEach(callback);
224 uint32_t DataVisualization::NamedSummaryFormats::GetCount() {
225 return GetFormatManager().GetNamedSummaryContainer().GetCount();