1 //===-- TypeList.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_SYMBOL_TYPELIST_H
10 #define LLDB_SYMBOL_TYPELIST_H
11 
12 #include "lldb/Symbol/Type.h"
13 #include "lldb/Utility/Iterable.h"
14 #include "lldb/lldb-private.h"
15 #include <functional>
16 #include <vector>
17 
18 namespace lldb_private {
19 
20 class TypeList {
21 public:
22   // Constructors and Destructors
23   TypeList();
24 
25   virtual ~TypeList();
26 
27   void Clear();
28 
29   void Dump(Stream *s, bool show_context);
30 
31   TypeList FindTypes(ConstString name);
32 
33   void Insert(const lldb::TypeSP &type);
34 
35   uint32_t GetSize() const;
36 
37   bool Empty() const { return !GetSize(); }
38 
39   lldb::TypeSP GetTypeAtIndex(uint32_t idx);
40 
41   typedef std::vector<lldb::TypeSP> collection;
42   typedef AdaptedIterable<collection, lldb::TypeSP, vector_adapter>
43       TypeIterable;
44 
45   TypeIterable Types() { return TypeIterable(m_types); }
46 
47   void ForEach(
48       std::function<bool(const lldb::TypeSP &type_sp)> const &callback) const;
49 
50   void ForEach(std::function<bool(lldb::TypeSP &type_sp)> const &callback);
51 
52   void RemoveMismatchedTypes(llvm::StringRef qualified_typename,
53                              bool exact_match);
54 
55   void RemoveMismatchedTypes(llvm::StringRef type_scope,
56                              llvm::StringRef type_basename,
57                              lldb::TypeClass type_class, bool exact_match);
58 
59   void RemoveMismatchedTypes(lldb::TypeClass type_class);
60 
61 private:
62   typedef collection::iterator iterator;
63   typedef collection::const_iterator const_iterator;
64 
65   collection m_types;
66 
67   TypeList(const TypeList &) = delete;
68   const TypeList &operator=(const TypeList &) = delete;
69 };
70 
71 } // namespace lldb_private
72 
73 #endif // LLDB_SYMBOL_TYPELIST_H
74