1 //===-- SBValueList.cpp -----------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 
11 #include "lldb/API/SBValueList.h"
12 #include "lldb/API/SBValue.h"
13 
14 #include "lldb/Core/ValueObjectList.h"
15 
16 using namespace lldb;
17 using namespace lldb_private;
18 
19 SBValueList::SBValueList () :
20     m_lldb_object_ap ()
21 {
22 }
23 
24 SBValueList::SBValueList (const SBValueList &rhs) :
25     m_lldb_object_ap ()
26 {
27     if (rhs.IsValid())
28         m_lldb_object_ap.reset (new lldb_private::ValueObjectList (*rhs));
29 }
30 
31 SBValueList::SBValueList (const lldb_private::ValueObjectList *lldb_object_ptr) :
32     m_lldb_object_ap ()
33 {
34     if (lldb_object_ptr)
35         m_lldb_object_ap.reset (new lldb_private::ValueObjectList (*lldb_object_ptr));
36 }
37 
38 SBValueList::~SBValueList ()
39 {
40 }
41 
42 bool
43 SBValueList::IsValid () const
44 {
45     return (m_lldb_object_ap.get() != NULL);
46 }
47 
48 const SBValueList &
49 SBValueList::operator = (const SBValueList &rhs)
50 {
51     if (this != &rhs)
52     {
53         if (rhs.IsValid())
54             m_lldb_object_ap.reset (new lldb_private::ValueObjectList (*rhs));
55         else
56             m_lldb_object_ap.reset ();
57     }
58     return *this;
59 }
60 
61 lldb_private::ValueObjectList *
62 SBValueList::operator->()
63 {
64     return m_lldb_object_ap.get();
65 }
66 
67 lldb_private::ValueObjectList &
68 SBValueList::operator*()
69 {
70     return *m_lldb_object_ap;
71 }
72 
73 const lldb_private::ValueObjectList *
74 SBValueList::operator->() const
75 {
76     return m_lldb_object_ap.get();
77 }
78 
79 const lldb_private::ValueObjectList &
80 SBValueList::operator*() const
81 {
82     return *m_lldb_object_ap;
83 }
84 
85 void
86 SBValueList::Append (const SBValue &val_obj)
87 {
88     if (val_obj.get())
89     {
90         CreateIfNeeded ();
91         m_lldb_object_ap->Append (*val_obj);
92     }
93 }
94 
95 void
96 SBValueList::Append (lldb::ValueObjectSP& val_obj_sp)
97 {
98     if (val_obj_sp)
99     {
100         CreateIfNeeded ();
101         m_lldb_object_ap->Append (val_obj_sp);
102     }
103 }
104 
105 
106 SBValue
107 SBValueList::GetValueAtIndex (uint32_t idx) const
108 {
109     SBValue sb_value;
110     if (m_lldb_object_ap.get())
111         *sb_value = m_lldb_object_ap->GetValueObjectAtIndex (idx);
112     return sb_value;
113 }
114 
115 uint32_t
116 SBValueList::GetSize () const
117 {
118     uint32_t size = 0;
119     if (m_lldb_object_ap.get())
120         size = m_lldb_object_ap->GetSize();
121     return size;
122 }
123 
124 void
125 SBValueList::CreateIfNeeded ()
126 {
127     if (m_lldb_object_ap.get() == NULL)
128         m_lldb_object_ap.reset (new ValueObjectList());
129 }
130 
131 
132 SBValue
133 SBValueList::FindValueObjectByUID (lldb::user_id_t uid)
134 {
135     SBValue sb_value;
136     if ( m_lldb_object_ap.get())
137         *sb_value = m_lldb_object_ap->FindValueObjectByUID (uid);
138     return sb_value;
139 }
140 
141