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 using namespace lldb_private;
17 static FormatManager &GetFormatManager() {
18 static FormatManager g_format_manager;
19 return g_format_manager;
22 void DataVisualization::ForceUpdate() { GetFormatManager().Changed(); }
24 uint32_t DataVisualization::GetCurrentRevision() {
25 return GetFormatManager().GetCurrentRevision();
28 bool DataVisualization::ShouldPrintAsOneLiner(ValueObject &valobj) {
29 return GetFormatManager().ShouldPrintAsOneLiner(valobj);
32 lldb::TypeFormatImplSP
33 DataVisualization::GetFormat(ValueObject &valobj,
34 lldb::DynamicValueType use_dynamic) {
35 return GetFormatManager().GetFormat(valobj, use_dynamic);
38 lldb::TypeFormatImplSP
39 DataVisualization::GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp) {
40 return GetFormatManager().GetFormatForType(type_sp);
43 lldb::TypeSummaryImplSP
44 DataVisualization::GetSummaryFormat(ValueObject &valobj,
45 lldb::DynamicValueType use_dynamic) {
46 return GetFormatManager().GetSummaryFormat(valobj, use_dynamic);
49 lldb::TypeSummaryImplSP
50 DataVisualization::GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp) {
51 return GetFormatManager().GetSummaryForType(type_sp);
54 #ifndef LLDB_DISABLE_PYTHON
55 lldb::SyntheticChildrenSP
56 DataVisualization::GetSyntheticChildren(ValueObject &valobj,
57 lldb::DynamicValueType use_dynamic) {
58 return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic);
62 #ifndef LLDB_DISABLE_PYTHON
63 lldb::SyntheticChildrenSP DataVisualization::GetSyntheticChildrenForType(
64 lldb::TypeNameSpecifierImplSP type_sp) {
65 return GetFormatManager().GetSyntheticChildrenForType(type_sp);
69 lldb::TypeFilterImplSP
70 DataVisualization::GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp) {
71 return GetFormatManager().GetFilterForType(type_sp);
74 #ifndef LLDB_DISABLE_PYTHON
75 lldb::ScriptedSyntheticChildrenSP
76 DataVisualization::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) {
77 return GetFormatManager().GetSyntheticForType(type_sp);
81 lldb::TypeValidatorImplSP
82 DataVisualization::GetValidator(ValueObject &valobj,
83 lldb::DynamicValueType use_dynamic) {
84 return GetFormatManager().GetValidator(valobj, use_dynamic);
87 lldb::TypeValidatorImplSP
88 DataVisualization::GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp) {
89 return GetFormatManager().GetValidatorForType(type_sp);
92 bool DataVisualization::AnyMatches(
93 ConstString type_name, TypeCategoryImpl::FormatCategoryItems items,
94 bool only_enabled, const char **matching_category,
95 TypeCategoryImpl::FormatCategoryItems *matching_type) {
96 return GetFormatManager().AnyMatches(type_name, items, only_enabled,
97 matching_category, matching_type);
100 bool DataVisualization::Categories::GetCategory(const ConstString &category,
101 lldb::TypeCategoryImplSP &entry,
103 entry = GetFormatManager().GetCategory(category, allow_create);
104 return (entry.get() != NULL);
107 bool DataVisualization::Categories::GetCategory(
108 lldb::LanguageType language, lldb::TypeCategoryImplSP &entry) {
109 if (LanguageCategory *lang_category =
110 GetFormatManager().GetCategoryForLanguage(language))
111 entry = lang_category->GetCategory();
112 return (entry.get() != nullptr);
115 void DataVisualization::Categories::Add(const ConstString &category) {
116 GetFormatManager().GetCategory(category);
119 bool DataVisualization::Categories::Delete(const ConstString &category) {
120 GetFormatManager().DisableCategory(category);
121 return GetFormatManager().DeleteCategory(category);
124 void DataVisualization::Categories::Clear() {
125 GetFormatManager().ClearCategories();
128 void DataVisualization::Categories::Clear(const ConstString &category) {
129 GetFormatManager().GetCategory(category)->Clear(
130 eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary);
133 void DataVisualization::Categories::Enable(const ConstString &category,
134 TypeCategoryMap::Position pos) {
135 if (GetFormatManager().GetCategory(category)->IsEnabled())
136 GetFormatManager().DisableCategory(category);
137 GetFormatManager().EnableCategory(
138 category, pos, std::initializer_list<lldb::LanguageType>());
141 void DataVisualization::Categories::Enable(lldb::LanguageType lang_type) {
142 if (LanguageCategory *lang_category =
143 GetFormatManager().GetCategoryForLanguage(lang_type))
144 lang_category->Enable();
147 void DataVisualization::Categories::Disable(const ConstString &category) {
148 if (GetFormatManager().GetCategory(category)->IsEnabled())
149 GetFormatManager().DisableCategory(category);
152 void DataVisualization::Categories::Disable(lldb::LanguageType lang_type) {
153 if (LanguageCategory *lang_category =
154 GetFormatManager().GetCategoryForLanguage(lang_type))
155 lang_category->Disable();
158 void DataVisualization::Categories::Enable(
159 const lldb::TypeCategoryImplSP &category, TypeCategoryMap::Position pos) {
160 if (category.get()) {
161 if (category->IsEnabled())
162 GetFormatManager().DisableCategory(category);
163 GetFormatManager().EnableCategory(category, pos);
167 void DataVisualization::Categories::Disable(
168 const lldb::TypeCategoryImplSP &category) {
169 if (category.get() && category->IsEnabled())
170 GetFormatManager().DisableCategory(category);
173 void DataVisualization::Categories::EnableStar() {
174 GetFormatManager().EnableAllCategories();
177 void DataVisualization::Categories::DisableStar() {
178 GetFormatManager().DisableAllCategories();
181 void DataVisualization::Categories::ForEach(
182 TypeCategoryMap::ForEachCallback callback) {
183 GetFormatManager().ForEachCategory(callback);
186 uint32_t DataVisualization::Categories::GetCount() {
187 return GetFormatManager().GetCategoriesCount();
190 lldb::TypeCategoryImplSP
191 DataVisualization::Categories::GetCategoryAtIndex(size_t index) {
192 return GetFormatManager().GetCategoryAtIndex(index);
195 bool DataVisualization::NamedSummaryFormats::GetSummaryFormat(
196 const ConstString &type, lldb::TypeSummaryImplSP &entry) {
197 return GetFormatManager().GetNamedSummaryContainer().Get(type, entry);
200 void DataVisualization::NamedSummaryFormats::Add(
201 const ConstString &type, const lldb::TypeSummaryImplSP &entry) {
202 GetFormatManager().GetNamedSummaryContainer().Add(
203 FormatManager::GetValidTypeName(type), entry);
206 bool DataVisualization::NamedSummaryFormats::Delete(const ConstString &type) {
207 return GetFormatManager().GetNamedSummaryContainer().Delete(type);
210 void DataVisualization::NamedSummaryFormats::Clear() {
211 GetFormatManager().GetNamedSummaryContainer().Clear();
214 void DataVisualization::NamedSummaryFormats::ForEach(
215 std::function<bool(ConstString, const lldb::TypeSummaryImplSP &)>
217 GetFormatManager().GetNamedSummaryContainer().ForEach(callback);
220 uint32_t DataVisualization::NamedSummaryFormats::GetCount() {
221 return GetFormatManager().GetNamedSummaryContainer().GetCount();