1 //===-- SBFileSpecList.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;
23 SBFileSpecList::SBFileSpecList() : m_opaque_ap(new FileSpecList()) {}
25 SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) : m_opaque_ap() {
26 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
28 if (rhs.m_opaque_ap.get())
29 m_opaque_ap.reset(new FileSpecList(*(rhs.get())));
32 log->Printf("SBFileSpecList::SBFileSpecList (const SBFileSpecList "
33 "rhs.ap=%p) => SBFileSpecList(%p)",
34 static_cast<void *>(rhs.m_opaque_ap.get()),
35 static_cast<void *>(m_opaque_ap.get()));
39 SBFileSpecList::~SBFileSpecList() {}
41 const SBFileSpecList &SBFileSpecList::operator=(const SBFileSpecList &rhs) {
43 m_opaque_ap.reset(new lldb_private::FileSpecList(*(rhs.get())));
48 uint32_t SBFileSpecList::GetSize() const { return m_opaque_ap->GetSize(); }
50 void SBFileSpecList::Append(const SBFileSpec &sb_file) {
51 m_opaque_ap->Append(sb_file.ref());
54 bool SBFileSpecList::AppendIfUnique(const SBFileSpec &sb_file) {
55 return m_opaque_ap->AppendIfUnique(sb_file.ref());
58 void SBFileSpecList::Clear() { m_opaque_ap->Clear(); }
60 uint32_t SBFileSpecList::FindFileIndex(uint32_t idx, const SBFileSpec &sb_file,
62 return m_opaque_ap->FindFileIndex(idx, sb_file.ref(), full);
65 const SBFileSpec SBFileSpecList::GetFileSpecAtIndex(uint32_t idx) const {
67 new_spec.SetFileSpec(m_opaque_ap->GetFileSpecAtIndex(idx));
71 const lldb_private::FileSpecList *SBFileSpecList::operator->() const {
72 return m_opaque_ap.get();
75 const lldb_private::FileSpecList *SBFileSpecList::get() const {
76 return m_opaque_ap.get();
79 const lldb_private::FileSpecList &SBFileSpecList::operator*() const {
80 return *m_opaque_ap.get();
83 const lldb_private::FileSpecList &SBFileSpecList::ref() const {
84 return *m_opaque_ap.get();
87 bool SBFileSpecList::GetDescription(SBStream &description) const {
88 Stream &strm = description.ref();
90 if (m_opaque_ap.get()) {
91 uint32_t num_files = m_opaque_ap->GetSize();
92 strm.Printf("%d files: ", num_files);
93 for (uint32_t i = 0; i < num_files; i++) {
95 if (m_opaque_ap->GetFileSpecAtIndex(i).GetPath(path, sizeof(path)))
96 strm.Printf("\n %s", path);
99 strm.PutCString("No value");