TypeCategory.h revision 258884
1//===-- TypeCategory.h -------------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef lldb_TypeCategory_h_ 11#define lldb_TypeCategory_h_ 12 13// C Includes 14// C++ Includes 15 16// Other libraries and framework includes 17// Project includes 18#include "lldb/lldb-public.h" 19#include "lldb/lldb-enumerations.h" 20 21#include "lldb/DataFormatters/FormatClasses.h" 22#include "lldb/DataFormatters/FormatNavigator.h" 23 24namespace lldb_private { 25 class TypeCategoryImpl 26 { 27 private: 28 typedef FormatNavigator<ConstString, TypeFormatImpl> ValueNavigator; 29 typedef FormatNavigator<lldb::RegularExpressionSP, TypeFormatImpl> RegexValueNavigator; 30 31 typedef FormatNavigator<ConstString, TypeSummaryImpl> SummaryNavigator; 32 typedef FormatNavigator<lldb::RegularExpressionSP, TypeSummaryImpl> RegexSummaryNavigator; 33 34 typedef FormatNavigator<ConstString, TypeFilterImpl> FilterNavigator; 35 typedef FormatNavigator<lldb::RegularExpressionSP, TypeFilterImpl> RegexFilterNavigator; 36 37#ifndef LLDB_DISABLE_PYTHON 38 typedef FormatNavigator<ConstString, ScriptedSyntheticChildren> SynthNavigator; 39 typedef FormatNavigator<lldb::RegularExpressionSP, ScriptedSyntheticChildren> RegexSynthNavigator; 40#endif // #ifndef LLDB_DISABLE_PYTHON 41 42 typedef ValueNavigator::MapType ValueMap; 43 typedef RegexValueNavigator::MapType RegexValueMap; 44 45 typedef SummaryNavigator::MapType SummaryMap; 46 typedef RegexSummaryNavigator::MapType RegexSummaryMap; 47 48 typedef FilterNavigator::MapType FilterMap; 49 typedef RegexFilterNavigator::MapType RegexFilterMap; 50 51#ifndef LLDB_DISABLE_PYTHON 52 typedef SynthNavigator::MapType SynthMap; 53 typedef RegexSynthNavigator::MapType RegexSynthMap; 54#endif // #ifndef LLDB_DISABLE_PYTHON 55 56 public: 57 58 typedef uint16_t FormatCategoryItems; 59 static const uint16_t ALL_ITEM_TYPES = UINT16_MAX; 60 61 typedef ValueNavigator::SharedPointer ValueNavigatorSP; 62 typedef RegexValueNavigator::SharedPointer RegexValueNavigatorSP; 63 64 typedef SummaryNavigator::SharedPointer SummaryNavigatorSP; 65 typedef RegexSummaryNavigator::SharedPointer RegexSummaryNavigatorSP; 66 67 typedef FilterNavigator::SharedPointer FilterNavigatorSP; 68 typedef RegexFilterNavigator::SharedPointer RegexFilterNavigatorSP; 69#ifndef LLDB_DISABLE_PYTHON 70 typedef SynthNavigator::SharedPointer SynthNavigatorSP; 71 typedef RegexSynthNavigator::SharedPointer RegexSynthNavigatorSP; 72#endif // #ifndef LLDB_DISABLE_PYTHON 73 74 TypeCategoryImpl (IFormatChangeListener* clist, 75 ConstString name); 76 77 ValueNavigatorSP 78 GetValueNavigator () 79 { 80 return ValueNavigatorSP(m_value_nav); 81 } 82 83 RegexValueNavigatorSP 84 GetRegexValueNavigator () 85 { 86 return RegexValueNavigatorSP(m_regex_value_nav); 87 } 88 89 SummaryNavigatorSP 90 GetSummaryNavigator () 91 { 92 return SummaryNavigatorSP(m_summary_nav); 93 } 94 95 RegexSummaryNavigatorSP 96 GetRegexSummaryNavigator () 97 { 98 return RegexSummaryNavigatorSP(m_regex_summary_nav); 99 } 100 101 FilterNavigatorSP 102 GetFilterNavigator () 103 { 104 return FilterNavigatorSP(m_filter_nav); 105 } 106 107 RegexFilterNavigatorSP 108 GetRegexFilterNavigator () 109 { 110 return RegexFilterNavigatorSP(m_regex_filter_nav); 111 } 112 113 ValueNavigator::MapValueType 114 GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp); 115 116 SummaryNavigator::MapValueType 117 GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp); 118 119 FilterNavigator::MapValueType 120 GetFilterForType (lldb::TypeNameSpecifierImplSP type_sp); 121 122#ifndef LLDB_DISABLE_PYTHON 123 SynthNavigator::MapValueType 124 GetSyntheticForType (lldb::TypeNameSpecifierImplSP type_sp); 125#endif 126 127 lldb::TypeNameSpecifierImplSP 128 GetTypeNameSpecifierForFormatAtIndex (size_t index); 129 130 lldb::TypeNameSpecifierImplSP 131 GetTypeNameSpecifierForSummaryAtIndex (size_t index); 132 133 ValueNavigator::MapValueType 134 GetFormatAtIndex (size_t index); 135 136 SummaryNavigator::MapValueType 137 GetSummaryAtIndex (size_t index); 138 139 FilterNavigator::MapValueType 140 GetFilterAtIndex (size_t index); 141 142 lldb::TypeNameSpecifierImplSP 143 GetTypeNameSpecifierForFilterAtIndex (size_t index); 144 145#ifndef LLDB_DISABLE_PYTHON 146 SynthNavigatorSP 147 GetSyntheticNavigator () 148 { 149 return SynthNavigatorSP(m_synth_nav); 150 } 151 152 RegexSynthNavigatorSP 153 GetRegexSyntheticNavigator () 154 { 155 return RegexSynthNavigatorSP(m_regex_synth_nav); 156 } 157 158 SynthNavigator::MapValueType 159 GetSyntheticAtIndex (size_t index); 160 161 lldb::TypeNameSpecifierImplSP 162 GetTypeNameSpecifierForSyntheticAtIndex (size_t index); 163 164#endif // #ifndef LLDB_DISABLE_PYTHON 165 166 bool 167 IsEnabled () const 168 { 169 return m_enabled; 170 } 171 172 uint32_t 173 GetEnabledPosition() 174 { 175 if (m_enabled == false) 176 return UINT32_MAX; 177 else 178 return m_enabled_position; 179 } 180 181 bool 182 Get (ValueObject& valobj, 183 const FormattersMatchVector& candidates, 184 lldb::TypeFormatImplSP& entry, 185 uint32_t* reason = NULL); 186 187 bool 188 Get (ValueObject& valobj, 189 const FormattersMatchVector& candidates, 190 lldb::TypeSummaryImplSP& entry, 191 uint32_t* reason = NULL); 192 193 bool 194 Get (ValueObject& valobj, 195 const FormattersMatchVector& candidates, 196 lldb::SyntheticChildrenSP& entry, 197 uint32_t* reason = NULL); 198 199 void 200 Clear (FormatCategoryItems items = ALL_ITEM_TYPES); 201 202 bool 203 Delete (ConstString name, 204 FormatCategoryItems items = ALL_ITEM_TYPES); 205 206 uint32_t 207 GetCount (FormatCategoryItems items = ALL_ITEM_TYPES); 208 209 const char* 210 GetName () 211 { 212 return m_name.GetCString(); 213 } 214 215 bool 216 AnyMatches (ConstString type_name, 217 FormatCategoryItems items = ALL_ITEM_TYPES, 218 bool only_enabled = true, 219 const char** matching_category = NULL, 220 FormatCategoryItems* matching_type = NULL); 221 222 typedef std::shared_ptr<TypeCategoryImpl> SharedPointer; 223 224 private: 225 ValueNavigator::SharedPointer m_value_nav; 226 RegexValueNavigator::SharedPointer m_regex_value_nav; 227 228 SummaryNavigator::SharedPointer m_summary_nav; 229 RegexSummaryNavigator::SharedPointer m_regex_summary_nav; 230 231 FilterNavigator::SharedPointer m_filter_nav; 232 RegexFilterNavigator::SharedPointer m_regex_filter_nav; 233 234#ifndef LLDB_DISABLE_PYTHON 235 SynthNavigator::SharedPointer m_synth_nav; 236 RegexSynthNavigator::SharedPointer m_regex_synth_nav; 237#endif // #ifndef LLDB_DISABLE_PYTHON 238 239 bool m_enabled; 240 241 IFormatChangeListener* m_change_listener; 242 243 Mutex m_mutex; 244 245 ConstString m_name; 246 247 uint32_t m_enabled_position; 248 249 void 250 Enable (bool value, uint32_t position); 251 252 void 253 Disable () 254 { 255 Enable(false, UINT32_MAX); 256 } 257 258 friend class TypeCategoryMap; 259 260 friend class FormatNavigator<ConstString, TypeFormatImpl>; 261 friend class FormatNavigator<lldb::RegularExpressionSP, TypeFormatImpl>; 262 263 friend class FormatNavigator<ConstString, TypeSummaryImpl>; 264 friend class FormatNavigator<lldb::RegularExpressionSP, TypeSummaryImpl>; 265 266 friend class FormatNavigator<ConstString, TypeFilterImpl>; 267 friend class FormatNavigator<lldb::RegularExpressionSP, TypeFilterImpl>; 268 269#ifndef LLDB_DISABLE_PYTHON 270 friend class FormatNavigator<ConstString, ScriptedSyntheticChildren>; 271 friend class FormatNavigator<lldb::RegularExpressionSP, ScriptedSyntheticChildren>; 272#endif // #ifndef LLDB_DISABLE_PYTHON 273 }; 274 275} // namespace lldb_private 276 277#endif // lldb_TypeCategory_h_ 278