1 //===-- SBFileSpecListList.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 //===----------------------------------------------------------------------===//
12 #include "lldb/API/SBFileSpec.h"
13 #include "lldb/API/SBFileSpecList.h"
14 #include "lldb/API/SBStream.h"
15 #include "lldb/Core/FileSpecList.h"
16 #include "lldb/Core/Log.h"
17 #include "lldb/Core/Stream.h"
18 #include "lldb/Host/FileSpec.h"
21 using namespace lldb_private;
25 SBFileSpecList::SBFileSpecList () :
26 m_opaque_ap(new FileSpecList())
30 SBFileSpecList::SBFileSpecList (const SBFileSpecList &rhs) :
33 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
35 if (rhs.m_opaque_ap.get())
36 m_opaque_ap.reset (new FileSpecList (*(rhs.get())));
40 log->Printf ("SBFileSpecList::SBFileSpecList (const SBFileSpecList rhs.ap=%p) => SBFileSpecList(%p)",
41 rhs.m_opaque_ap.get(), m_opaque_ap.get());
45 SBFileSpecList::~SBFileSpecList ()
49 const SBFileSpecList &
50 SBFileSpecList::operator = (const SBFileSpecList &rhs)
54 m_opaque_ap.reset (new lldb_private::FileSpecList(*(rhs.get())));
60 SBFileSpecList::GetSize () const
62 return m_opaque_ap->GetSize();
66 SBFileSpecList::Append (const SBFileSpec &sb_file)
68 m_opaque_ap->Append (sb_file.ref());
72 SBFileSpecList::AppendIfUnique (const SBFileSpec &sb_file)
74 return m_opaque_ap->AppendIfUnique (sb_file.ref());
78 SBFileSpecList::Clear()
84 SBFileSpecList::FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full)
86 return m_opaque_ap->FindFileIndex (idx, sb_file.ref(), full);
90 SBFileSpecList::GetFileSpecAtIndex (uint32_t idx) const
93 new_spec.SetFileSpec(m_opaque_ap->GetFileSpecAtIndex(idx));
97 const lldb_private::FileSpecList *
98 SBFileSpecList::operator->() const
100 return m_opaque_ap.get();
103 const lldb_private::FileSpecList *
104 SBFileSpecList::get() const
106 return m_opaque_ap.get();
110 const lldb_private::FileSpecList &
111 SBFileSpecList::operator*() const
113 return *m_opaque_ap.get();
116 const lldb_private::FileSpecList &
117 SBFileSpecList::ref() const
119 return *m_opaque_ap.get();
123 SBFileSpecList::GetDescription (SBStream &description) const
125 Stream &strm = description.ref();
127 if (m_opaque_ap.get())
129 uint32_t num_files = m_opaque_ap->GetSize();
130 strm.Printf ("%d files: ", num_files);
131 for (uint32_t i = 0; i < num_files; i++)
134 if (m_opaque_ap->GetFileSpecAtIndex(i).GetPath(path, sizeof(path)))
135 strm.Printf ("\n %s", path);
139 strm.PutCString ("No value");