LLDB  mainline
ValueObjectList.cpp
Go to the documentation of this file.
1 //===-- ValueObjectList.cpp -------------------------------------*- 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 
10 
11 #include "lldb/Core/ValueObject.h"
14 
15 #include <utility>
16 
17 using namespace lldb;
18 using namespace lldb_private;
19 
20 ValueObjectList::ValueObjectList() : m_value_objects() {}
21 
24 
26 
28  if (this != &rhs)
30  return *this;
31 }
32 
33 void ValueObjectList::Append(const ValueObjectSP &val_obj_sp) {
34  m_value_objects.push_back(val_obj_sp);
35 }
36 
37 void ValueObjectList::Append(const ValueObjectList &valobj_list) {
38  std::copy(valobj_list.m_value_objects.begin(), // source begin
39  valobj_list.m_value_objects.end(), // source end
40  back_inserter(m_value_objects)); // destination
41 }
42 
43 size_t ValueObjectList::GetSize() const { return m_value_objects.size(); }
44 
45 void ValueObjectList::Resize(size_t size) { m_value_objects.resize(size); }
46 
47 lldb::ValueObjectSP ValueObjectList::GetValueObjectAtIndex(size_t idx) {
48  lldb::ValueObjectSP valobj_sp;
49  if (idx < m_value_objects.size())
50  valobj_sp = m_value_objects[idx];
51  return valobj_sp;
52 }
53 
54 lldb::ValueObjectSP ValueObjectList::RemoveValueObjectAtIndex(size_t idx) {
55  lldb::ValueObjectSP valobj_sp;
56  if (idx < m_value_objects.size()) {
57  valobj_sp = m_value_objects[idx];
58  m_value_objects.erase(m_value_objects.begin() + idx);
59  }
60  return valobj_sp;
61 }
62 
64  const ValueObjectSP &valobj_sp) {
65  if (idx >= m_value_objects.size())
66  m_value_objects.resize(idx + 1);
67  m_value_objects[idx] = valobj_sp;
68 }
69 
70 ValueObjectSP ValueObjectList::FindValueObjectByValueName(const char *name) {
71  ConstString name_const_str(name);
72  ValueObjectSP val_obj_sp;
73  collection::iterator pos, end = m_value_objects.end();
74  for (pos = m_value_objects.begin(); pos != end; ++pos) {
75  ValueObject *valobj = (*pos).get();
76  if (valobj && valobj->GetName() == name_const_str) {
77  val_obj_sp = *pos;
78  break;
79  }
80  }
81  return val_obj_sp;
82 }
83 
85  ValueObjectSP valobj_sp;
86  collection::iterator pos, end = m_value_objects.end();
87 
88  for (pos = m_value_objects.begin(); pos != end; ++pos) {
89  // Watch out for NULL objects in our list as the list might get resized to
90  // a specific size and lazily filled in
91  ValueObject *valobj = (*pos).get();
92  if (valobj && valobj->GetID() == uid) {
93  valobj_sp = *pos;
94  break;
95  }
96  }
97  return valobj_sp;
98 }
99 
100 ValueObjectSP
102  ValueObjectSP valobj_sp;
103  collection::iterator pos, end = m_value_objects.end();
104 
105  for (pos = m_value_objects.begin(); pos != end; ++pos) {
106  ValueObject *valobj = (*pos).get();
107  if (valobj && valobj == find_valobj) {
108  valobj_sp = *pos;
109  break;
110  }
111  }
112  return valobj_sp;
113 }
114 
115 void ValueObjectList::Swap(ValueObjectList &value_object_list) {
116  m_value_objects.swap(value_object_list.m_value_objects);
117 }
lldb::ValueObjectSP GetValueObjectAtIndex(size_t idx)
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
ConstString GetName() const
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:49
const ValueObjectList & operator=(const ValueObjectList &rhs)
lldb::ValueObjectSP FindValueObjectByPointer(ValueObject *valobj)
void SetValueObjectAtIndex(size_t idx, const lldb::ValueObjectSP &valobj_sp)
lldb::ValueObjectSP FindValueObjectByValueName(const char *name)
uint64_t user_id_t
Definition: lldb-types.h:84
void Append(const lldb::ValueObjectSP &val_obj_sp)
lldb::ValueObjectSP FindValueObjectByUID(lldb::user_id_t uid)
lldb::ValueObjectSP RemoveValueObjectAtIndex(size_t idx)
A uniqued constant string class.
Definition: ConstString.h:38
Definition: SBAddress.h:15
void Swap(ValueObjectList &value_object_list)