1 //===-- ValueObjectList.cpp -------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Core/ValueObjectList.h"
14 // Other libraries and framework includes
16 #include "lldb/Core/ValueObjectChild.h"
17 #include "lldb/Core/ValueObjectRegister.h"
18 #include "lldb/Core/ValueObjectVariable.h"
19 #include "lldb/Target/ExecutionContext.h"
20 #include "lldb/Target/Process.h"
23 using namespace lldb_private;
25 ValueObjectList::ValueObjectList() : m_value_objects() {}
27 ValueObjectList::ValueObjectList(const ValueObjectList &rhs)
28 : m_value_objects(rhs.m_value_objects) {}
30 ValueObjectList::~ValueObjectList() {}
32 const ValueObjectList &ValueObjectList::operator=(const ValueObjectList &rhs) {
34 m_value_objects = rhs.m_value_objects;
38 void ValueObjectList::Append(const ValueObjectSP &val_obj_sp) {
39 m_value_objects.push_back(val_obj_sp);
42 void ValueObjectList::Append(const ValueObjectList &valobj_list) {
43 std::copy(valobj_list.m_value_objects.begin(), // source begin
44 valobj_list.m_value_objects.end(), // source end
45 back_inserter(m_value_objects)); // destination
48 size_t ValueObjectList::GetSize() const { return m_value_objects.size(); }
50 void ValueObjectList::Resize(size_t size) { m_value_objects.resize(size); }
52 lldb::ValueObjectSP ValueObjectList::GetValueObjectAtIndex(size_t idx) {
53 lldb::ValueObjectSP valobj_sp;
54 if (idx < m_value_objects.size())
55 valobj_sp = m_value_objects[idx];
59 lldb::ValueObjectSP ValueObjectList::RemoveValueObjectAtIndex(size_t idx) {
60 lldb::ValueObjectSP valobj_sp;
61 if (idx < m_value_objects.size()) {
62 valobj_sp = m_value_objects[idx];
63 m_value_objects.erase(m_value_objects.begin() + idx);
68 void ValueObjectList::SetValueObjectAtIndex(size_t idx,
69 const ValueObjectSP &valobj_sp) {
70 if (idx >= m_value_objects.size())
71 m_value_objects.resize(idx + 1);
72 m_value_objects[idx] = valobj_sp;
75 ValueObjectSP ValueObjectList::FindValueObjectByValueName(const char *name) {
76 ConstString name_const_str(name);
77 ValueObjectSP val_obj_sp;
78 collection::iterator pos, end = m_value_objects.end();
79 for (pos = m_value_objects.begin(); pos != end; ++pos) {
80 ValueObject *valobj = (*pos).get();
81 if (valobj && valobj->GetName() == name_const_str) {
89 ValueObjectSP ValueObjectList::FindValueObjectByUID(lldb::user_id_t uid) {
90 ValueObjectSP valobj_sp;
91 collection::iterator pos, end = m_value_objects.end();
93 for (pos = m_value_objects.begin(); pos != end; ++pos) {
94 // Watch out for NULL objects in our list as the list
95 // might get resized to a specific size and lazily filled in
96 ValueObject *valobj = (*pos).get();
97 if (valobj && valobj->GetID() == uid) {
106 ValueObjectList::FindValueObjectByPointer(ValueObject *find_valobj) {
107 ValueObjectSP valobj_sp;
108 collection::iterator pos, end = m_value_objects.end();
110 for (pos = m_value_objects.begin(); pos != end; ++pos) {
111 ValueObject *valobj = (*pos).get();
112 if (valobj && valobj == find_valobj) {
120 void ValueObjectList::Swap(ValueObjectList &value_object_list) {
121 m_value_objects.swap(value_object_list.m_value_objects);