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 () :
30 ValueObjectList::ValueObjectList (const ValueObjectList &rhs) :
31 m_value_objects(rhs.m_value_objects)
36 ValueObjectList::~ValueObjectList ()
40 const ValueObjectList &
41 ValueObjectList::operator = (const ValueObjectList &rhs)
44 m_value_objects = rhs.m_value_objects;
49 ValueObjectList::Append (const ValueObjectSP &val_obj_sp)
51 m_value_objects.push_back(val_obj_sp);
55 ValueObjectList::Append (const ValueObjectList &valobj_list)
57 std::copy(valobj_list.m_value_objects.begin(), // source begin
58 valobj_list.m_value_objects.end(), // source end
59 back_inserter(m_value_objects)); // destination
65 ValueObjectList::GetSize() const
67 return m_value_objects.size();
71 ValueObjectList::Resize (size_t size)
73 m_value_objects.resize (size);
77 ValueObjectList::GetValueObjectAtIndex (size_t idx)
79 lldb::ValueObjectSP valobj_sp;
80 if (idx < m_value_objects.size())
81 valobj_sp = m_value_objects[idx];
86 ValueObjectList::RemoveValueObjectAtIndex (size_t idx)
88 lldb::ValueObjectSP valobj_sp;
89 if (idx < m_value_objects.size())
91 valobj_sp = m_value_objects[idx];
92 m_value_objects.erase (m_value_objects.begin() + idx);
98 ValueObjectList::SetValueObjectAtIndex (size_t idx, const ValueObjectSP &valobj_sp)
100 if (idx >= m_value_objects.size())
101 m_value_objects.resize (idx + 1);
102 m_value_objects[idx] = valobj_sp;
106 ValueObjectList::FindValueObjectByValueName (const char *name)
108 ConstString name_const_str(name);
109 ValueObjectSP val_obj_sp;
110 collection::iterator pos, end = m_value_objects.end();
111 for (pos = m_value_objects.begin(); pos != end; ++pos)
113 ValueObject *valobj = (*pos).get();
114 if (valobj && valobj->GetName() == name_const_str)
124 ValueObjectList::FindValueObjectByUID (lldb::user_id_t uid)
126 ValueObjectSP valobj_sp;
127 collection::iterator pos, end = m_value_objects.end();
129 for (pos = m_value_objects.begin(); pos != end; ++pos)
131 // Watch out for NULL objects in our list as the list
132 // might get resized to a specific size and lazily filled in
133 ValueObject *valobj = (*pos).get();
134 if (valobj && valobj->GetID() == uid)
145 ValueObjectList::FindValueObjectByPointer (ValueObject *find_valobj)
147 ValueObjectSP valobj_sp;
148 collection::iterator pos, end = m_value_objects.end();
150 for (pos = m_value_objects.begin(); pos != end; ++pos)
152 ValueObject *valobj = (*pos).get();
153 if (valobj && valobj == find_valobj)
163 ValueObjectList::Swap (ValueObjectList &value_object_list)
165 m_value_objects.swap (value_object_list.m_value_objects);