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