VariableList.h revision 355940
1//===-- VariableList.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 liblldb_VariableList_h_
10#define liblldb_VariableList_h_
11
12#include "lldb/Symbol/SymbolContext.h"
13#include "lldb/Symbol/Variable.h"
14#include "lldb/lldb-private.h"
15
16namespace lldb_private {
17
18class VariableList {
19public:
20  // Constructors and Destructors
21  //  VariableList(const SymbolContext &symbol_context);
22  VariableList();
23  virtual ~VariableList();
24
25  void AddVariable(const lldb::VariableSP &var_sp);
26
27  bool AddVariableIfUnique(const lldb::VariableSP &var_sp);
28
29  void AddVariables(VariableList *variable_list);
30
31  void Clear();
32
33  void Dump(Stream *s, bool show_context) const;
34
35  lldb::VariableSP GetVariableAtIndex(size_t idx) const;
36
37  lldb::VariableSP RemoveVariableAtIndex(size_t idx);
38
39  lldb::VariableSP FindVariable(ConstString name,
40                                bool include_static_members = true);
41
42  lldb::VariableSP FindVariable(ConstString name,
43                                lldb::ValueType value_type,
44                                bool include_static_members = true);
45
46  uint32_t FindVariableIndex(const lldb::VariableSP &var_sp);
47
48  size_t AppendVariablesIfUnique(VariableList &var_list);
49
50  // Returns the actual number of unique variables that were added to the list.
51  // "total_matches" will get updated with the actually number of matches that
52  // were found regardless of whether they were unique or not to allow for
53  // error conditions when nothing is found, versus conditions where any
54  // variables that match "regex" were already in "var_list".
55  size_t AppendVariablesIfUnique(const RegularExpression &regex,
56                                 VariableList &var_list, size_t &total_matches);
57
58  size_t AppendVariablesWithScope(lldb::ValueType type, VariableList &var_list,
59                                  bool if_unique = true);
60
61  uint32_t FindIndexForVariable(Variable *variable);
62
63  size_t MemorySize() const;
64
65  size_t GetSize() const;
66  bool Empty() const { return m_variables.empty(); }
67
68protected:
69  typedef std::vector<lldb::VariableSP> collection;
70  typedef collection::iterator iterator;
71  typedef collection::const_iterator const_iterator;
72
73  collection m_variables;
74
75private:
76  // For VariableList only
77  DISALLOW_COPY_AND_ASSIGN(VariableList);
78};
79
80} // namespace lldb_private
81
82#endif // liblldb_VariableList_h_
83