1 //===-- SBValueList.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 //===----------------------------------------------------------------------===//
11 #include "lldb/API/SBValueList.h"
12 #include "lldb/API/SBValue.h"
13 #include "lldb/API/SBStream.h"
14 #include "lldb/Core/Log.h"
15 #include "lldb/Core/ValueObjectList.h"
20 using namespace lldb_private;
30 ValueListImpl (const ValueListImpl& rhs) :
31 m_values(rhs.m_values)
36 operator = (const ValueListImpl& rhs)
40 m_values = rhs.m_values;
47 return m_values.size();
51 Append (const lldb::SBValue& sb_value)
53 m_values.push_back(sb_value);
57 Append (const ValueListImpl& list)
59 for (auto val : list.m_values)
64 GetValueAtIndex (uint32_t index)
66 if (index >= GetSize())
67 return lldb::SBValue();
68 return m_values[index];
72 FindValueByUID (lldb::user_id_t uid)
74 for (auto val : m_values)
76 if (val.IsValid() && val.GetID() == uid)
79 return lldb::SBValue();
83 std::vector<lldb::SBValue> m_values;
86 SBValueList::SBValueList () :
91 SBValueList::SBValueList (const SBValueList &rhs) :
94 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
97 m_opaque_ap.reset (new ValueListImpl (*rhs));
101 log->Printf ("SBValueList::SBValueList (rhs.ap=%p) => this.ap = %p",
102 (rhs.IsValid() ? rhs.m_opaque_ap.get() : NULL),
107 SBValueList::SBValueList (const ValueListImpl *lldb_object_ptr) :
110 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
113 m_opaque_ap.reset (new ValueListImpl (*lldb_object_ptr));
117 log->Printf ("SBValueList::SBValueList (lldb_object_ptr=%p) => this.ap = %p",
123 SBValueList::~SBValueList ()
128 SBValueList::IsValid () const
130 return (m_opaque_ap.get() != NULL);
140 SBValueList::operator = (const SBValueList &rhs)
145 m_opaque_ap.reset (new ValueListImpl (*rhs));
147 m_opaque_ap.reset ();
153 SBValueList::operator->()
155 return m_opaque_ap.get();
159 SBValueList::operator*()
164 const ValueListImpl *
165 SBValueList::operator->() const
167 return m_opaque_ap.get();
170 const ValueListImpl &
171 SBValueList::operator*() const
177 SBValueList::Append (const SBValue &val_obj)
180 m_opaque_ap->Append (val_obj);
184 SBValueList::Append (lldb::ValueObjectSP& val_obj_sp)
189 m_opaque_ap->Append (SBValue(val_obj_sp));
194 SBValueList::Append (const lldb::SBValueList& value_list)
196 if (value_list.IsValid())
199 m_opaque_ap->Append (*value_list);
205 SBValueList::GetValueAtIndex (uint32_t idx) const
207 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
210 // log->Printf ("SBValueList::GetValueAtIndex (uint32_t idx) idx = %d", idx);
213 if (m_opaque_ap.get())
214 sb_value = m_opaque_ap->GetValueAtIndex (idx);
219 sb_value.GetDescription (sstr);
220 log->Printf ("SBValueList::GetValueAtIndex (this.ap=%p, idx=%d) => SBValue (this.sp = %p, '%s')",
221 m_opaque_ap.get(), idx, sb_value.GetSP().get(), sstr.GetData());
228 SBValueList::GetSize () const
230 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
233 // log->Printf ("SBValueList::GetSize ()");
236 if (m_opaque_ap.get())
237 size = m_opaque_ap->GetSize();
240 log->Printf ("SBValueList::GetSize (this.ap=%p) => %d", m_opaque_ap.get(), size);
246 SBValueList::CreateIfNeeded ()
248 if (m_opaque_ap.get() == NULL)
249 m_opaque_ap.reset (new ValueListImpl());
254 SBValueList::FindValueObjectByUID (lldb::user_id_t uid)
257 if (m_opaque_ap.get())
258 sb_value = m_opaque_ap->FindValueByUID(uid);
263 SBValueList::opaque_ptr ()
265 return m_opaque_ap.get();
272 return *m_opaque_ap.get();