LLDB  mainline
TypeCategoryMap.h
Go to the documentation of this file.
1 //===-- TypeCategoryMap.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_TypeCategoryMap_h_
10 #define lldb_TypeCategoryMap_h_
11 
12 #include <functional>
13 #include <list>
14 #include <map>
15 #include <mutex>
16 
17 #include "lldb/lldb-enumerations.h"
18 #include "lldb/lldb-public.h"
19 
22 
23 namespace lldb_private {
25 private:
26  typedef ConstString KeyType;
28  typedef ValueType::SharedPointer ValueSP;
29  typedef std::list<lldb::TypeCategoryImplSP> ActiveCategoriesList;
30  typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
31 
32 public:
33  typedef std::map<KeyType, ValueSP> MapType;
34  typedef MapType::iterator MapIterator;
35  typedef std::function<bool(const ValueSP &)> ForEachCallback;
36 
37  typedef uint32_t Position;
38 
39  static const Position First = 0;
40  static const Position Default = 1;
41  static const Position Last = UINT32_MAX;
42 
44 
45  void Add(KeyType name, const ValueSP &entry);
46 
47  bool Delete(KeyType name);
48 
49  bool Enable(KeyType category_name, Position pos = Default);
50 
51  bool Disable(KeyType category_name);
52 
53  bool Enable(ValueSP category, Position pos = Default);
54 
55  bool Disable(ValueSP category);
56 
57  void EnableAllCategories();
58 
59  void DisableAllCategories();
60 
61  void Clear();
62 
63  bool Get(KeyType name, ValueSP &entry);
64 
65  bool Get(uint32_t pos, ValueSP &entry);
66 
67  void ForEach(ForEachCallback callback);
68 
69  lldb::TypeCategoryImplSP GetAtIndex(uint32_t);
70 
71  bool
72  AnyMatches(ConstString type_name,
75  bool only_enabled = true, const char **matching_category = nullptr,
76  TypeCategoryImpl::FormatCategoryItems *matching_type = nullptr);
77 
78  uint32_t GetCount() { return m_map.size(); }
79 
80  lldb::TypeFormatImplSP GetFormat(FormattersMatchData &match_data);
81 
82  lldb::TypeSummaryImplSP GetSummaryFormat(FormattersMatchData &match_data);
83 
84  lldb::SyntheticChildrenSP
86 
87  lldb::TypeValidatorImplSP GetValidator(FormattersMatchData &match_data);
88 
89 private:
90  class delete_matching_categories {
91  lldb::TypeCategoryImplSP ptr;
92 
93  public:
94  delete_matching_categories(lldb::TypeCategoryImplSP p) : ptr(p) {}
95 
96  bool operator()(const lldb::TypeCategoryImplSP &other) {
97  return ptr.get() == other.get();
98  }
99  };
100 
101  std::recursive_mutex m_map_mutex;
102  IFormatChangeListener *listener;
103 
104  MapType m_map;
105  ActiveCategoriesList m_active_categories;
106 
107  MapType &map() { return m_map; }
108 
109  ActiveCategoriesList &active_list() { return m_active_categories; }
110 
111  std::recursive_mutex &mutex() { return m_map_mutex; }
112 
113  friend class FormattersContainer<KeyType, ValueType>;
114  friend class FormatManager;
115 };
116 } // namespace lldb_private
117 
118 #endif // lldb_TypeCategoryMap_h_
lldb::TypeFormatImplSP GetFormat(FormattersMatchData &match_data)
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
static const uint16_t ALL_ITEM_TYPES
Definition: TypeCategory.h:75
static const Position First
bool Disable(KeyType category_name)
std::shared_ptr< TypeCategoryImpl > SharedPointer
Definition: TypeCategory.h:372
lldb::TypeValidatorImplSP GetValidator(FormattersMatchData &match_data)
TypeCategoryMap(IFormatChangeListener *lst)
static const Position Default
bool AnyMatches(ConstString type_name, TypeCategoryImpl::FormatCategoryItems items=TypeCategoryImpl::ALL_ITEM_TYPES, bool only_enabled=true, const char **matching_category=nullptr, TypeCategoryImpl::FormatCategoryItems *matching_type=nullptr)
lldb::TypeSummaryImplSP GetSummaryFormat(FormattersMatchData &match_data)
#define UINT32_MAX
Definition: lldb-defines.h:31
std::function< bool(const ValueSP &)> ForEachCallback
lldb::TypeCategoryImplSP GetAtIndex(uint32_t)
void Add(KeyType name, const ValueSP &entry)
std::map< KeyType, ValueSP > MapType
A uniqued constant string class.
Definition: ConstString.h:38
void ForEach(ForEachCallback callback)
static const Position Last
lldb::SyntheticChildrenSP GetSyntheticChildren(FormattersMatchData &match_data)
bool Get(KeyType name, ValueSP &entry)
bool Enable(KeyType category_name, Position pos=Default)