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_DATAFORMATTERS_TYPECATEGORYMAP_H
10#define LLDB_DATAFORMATTERS_TYPECATEGORYMAP_H
11
12#include <functional>
13#include <list>
14#include <map>
15#include <mutex>
16
18#include "lldb/lldb-public.h"
19
23
24namespace lldb_private {
26private:
27 typedef std::list<lldb::TypeCategoryImplSP> ActiveCategoriesList;
28 typedef ActiveCategoriesList::iterator ActiveCategoriesIterator;
29
30public:
34 typedef std::map<KeyType, ValueSP> MapType;
35 typedef MapType::iterator MapIterator;
36 typedef std::function<bool(const ValueSP &)> ForEachCallback;
37
39
40 static const Position First = 0;
41 static const Position Default = 1;
42 static const Position Last = UINT32_MAX;
43
45
46 void Add(KeyType name, const ValueSP &entry);
47
48 bool Delete(KeyType name);
49
50 bool Enable(KeyType category_name, Position pos = Default);
51
52 bool Disable(KeyType category_name);
53
54 bool Enable(ValueSP category, Position pos = Default);
55
56 bool Disable(ValueSP category);
57
59
61
62 void Clear();
63
64 bool Get(KeyType name, ValueSP &entry);
65
66 bool Get(uint32_t pos, ValueSP &entry);
67
68 void ForEach(ForEachCallback callback);
69
70 lldb::TypeCategoryImplSP GetAtIndex(uint32_t);
71
72 bool
73 AnyMatches(const FormattersMatchCandidate &candidate_type,
76 bool only_enabled = true, const char **matching_category = nullptr,
77 TypeCategoryImpl::FormatCategoryItems *matching_type = nullptr);
78
79 uint32_t GetCount() { return m_map.size(); }
80
81 template <typename ImplSP> void Get(FormattersMatchData &, ImplSP &);
82
83private:
85 lldb::TypeCategoryImplSP ptr;
86
87 public:
88 delete_matching_categories(lldb::TypeCategoryImplSP p)
89 : ptr(std::move(p)) {}
90
91 bool operator()(const lldb::TypeCategoryImplSP &other) {
92 return ptr.get() == other.get();
93 }
94 };
95
96 std::recursive_mutex m_map_mutex;
98
101
102 MapType &map() { return m_map; }
103
105
106 std::recursive_mutex &mutex() { return m_map_mutex; }
107};
108} // namespace lldb_private
109
110#endif // LLDB_DATAFORMATTERS_TYPECATEGORYMAP_H
A uniqued constant string class.
Definition: ConstString.h:39
static const uint16_t ALL_ITEM_TYPES
Definition: TypeCategory.h:176
std::shared_ptr< TypeCategoryImpl > SharedPointer
Definition: TypeCategory.h:357
bool operator()(const lldb::TypeCategoryImplSP &other)
bool Get(KeyType name, ValueSP &entry)
ValueType::SharedPointer ValueSP
void Add(KeyType name, const ValueSP &entry)
static const Position Last
std::function< bool(const ValueSP &)> ForEachCallback
std::recursive_mutex & mutex()
bool AnyMatches(const FormattersMatchCandidate &candidate_type, TypeCategoryImpl::FormatCategoryItems items=TypeCategoryImpl::ALL_ITEM_TYPES, bool only_enabled=true, const char **matching_category=nullptr, TypeCategoryImpl::FormatCategoryItems *matching_type=nullptr)
bool Enable(KeyType category_name, Position pos=Default)
std::map< KeyType, ValueSP > MapType
lldb::TypeCategoryImplSP GetAtIndex(uint32_t)
std::recursive_mutex m_map_mutex
ActiveCategoriesList m_active_categories
ActiveCategoriesList::iterator ActiveCategoriesIterator
bool Disable(KeyType category_name)
IFormatChangeListener * listener
static const Position Default
std::list< lldb::TypeCategoryImplSP > ActiveCategoriesList
ActiveCategoriesList & active_list()
static const Position First
void ForEach(ForEachCallback callback)
#define UINT32_MAX
Definition: lldb-defines.h:19
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14