LLDB  mainline
VariableList.h
Go to the documentation of this file.
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 
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 
61  bool if_unique = true);
62 
64 
65  size_t MemorySize() const;
66 
67  size_t GetSize() const;
68  bool Empty() const { return m_variables.empty(); }
69 
70  typedef collection::iterator iterator;
71  typedef collection::const_iterator const_iterator;
72 
73  iterator begin() { return m_variables.begin(); }
74  iterator end() { return m_variables.end(); }
75  const_iterator begin() const { return m_variables.begin(); }
76  const_iterator end() const { return m_variables.end(); }
77 
78 protected:
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
lldb_private::RegularExpression
Definition: RegularExpression.h:18
lldb_private::VariableList::Dump
void Dump(Stream *s, bool show_context) const
Definition: VariableList.cpp:167
lldb_private::VariableList::Clear
void Clear()
Definition: VariableList.cpp:45
lldb_private::VariableList::AppendVariablesWithScope
size_t AppendVariablesWithScope(lldb::ValueType type, VariableList &var_list, bool if_unique=true)
Definition: VariableList.cpp:128
lldb_private::VariableList::iterator
collection::iterator iterator
Definition: VariableList.h:70
lldb_private::VariableList::AddVariable
void AddVariable(const lldb::VariableSP &var_sp)
Definition: VariableList.cpp:25
lldb_private::VariableList::~VariableList
virtual ~VariableList()
lldb_private::VariableList::GetSize
size_t GetSize() const
Definition: VariableList.cpp:165
lldb_private::VariableList::FindVariable
lldb::VariableSP FindVariable(ConstString name, bool include_static_members=true)
Definition: VariableList.cpp:72
lldb_private::Stream
Definition: Stream.h:28
lldb_private::VariableList
Definition: VariableList.h:18
lldb_private::VariableList::operator=
const VariableList & operator=(const VariableList &)=delete
lldb_private::VariableList::GetVariableAtIndex
lldb::VariableSP GetVariableAtIndex(size_t idx) const
Definition: VariableList.cpp:47
lldb_private::VariableList::const_iterator
collection::const_iterator const_iterator
Definition: VariableList.h:71
lldb_private::VariableList::begin
iterator begin()
Definition: VariableList.h:73
lldb_private::VariableList::MemorySize
size_t MemorySize() const
Definition: VariableList.cpp:157
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::VariableList::collection
std::vector< lldb::VariableSP > collection
Definition: VariableList.h:19
lldb_private::VariableList::end
iterator end()
Definition: VariableList.h:74
lldb_private::VariableList::AddVariables
void AddVariables(VariableList *variable_list)
Definition: VariableList.cpp:37
lldb_private::VariableList::begin
const_iterator begin() const
Definition: VariableList.h:75
lldb-private.h
lldb_private::VariableList::VariableList
VariableList()
Definition: VariableList.cpp:20
lldb_private::VariableList::RemoveVariableAtIndex
lldb::VariableSP RemoveVariableAtIndex(size_t idx)
Definition: VariableList.cpp:54
lldb::ValueType
ValueType
Definition: lldb-enumerations.h:315
uint32_t
lldb_private::VariableList::end
const_iterator end() const
Definition: VariableList.h:76
lldb_private::VariableList::m_variables
collection m_variables
Definition: VariableList.h:79
lldb_private::VariableList::AppendVariablesIfUnique
size_t AppendVariablesIfUnique(VariableList &var_list)
Definition: VariableList.cpp:103
SymbolContext.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::VariableList::Empty
bool Empty() const
Definition: VariableList.h:68
lldb_private::VariableList::AddVariableIfUnique
bool AddVariableIfUnique(const lldb::VariableSP &var_sp)
Definition: VariableList.cpp:29
lldb_private::VariableList::FindIndexForVariable
uint32_t FindIndexForVariable(Variable *variable)
Definition: VariableList.cpp:145
lldb_private::Variable
Definition: Variable.h:25
Variable.h
lldb_private::VariableList::FindVariableIndex
uint32_t FindVariableIndex(const lldb::VariableSP &var_sp)
Definition: VariableList.cpp:63