1//===-- SBFileSpecListList.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#include <limits.h> 11 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" 19 20using namespace lldb; 21using namespace lldb_private; 22 23 24 25SBFileSpecList::SBFileSpecList () : 26 m_opaque_ap(new FileSpecList()) 27{ 28} 29 30SBFileSpecList::SBFileSpecList (const SBFileSpecList &rhs) : 31 m_opaque_ap() 32{ 33 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 34 35 if (rhs.m_opaque_ap.get()) 36 m_opaque_ap.reset (new FileSpecList (*(rhs.get()))); 37 38 if (log) 39 { 40 log->Printf ("SBFileSpecList::SBFileSpecList (const SBFileSpecList rhs.ap=%p) => SBFileSpecList(%p)", 41 static_cast<void*>(rhs.m_opaque_ap.get()), 42 static_cast<void*>(m_opaque_ap.get())); 43 } 44} 45 46SBFileSpecList::~SBFileSpecList () 47{ 48} 49 50const SBFileSpecList & 51SBFileSpecList::operator = (const SBFileSpecList &rhs) 52{ 53 if (this != &rhs) 54 { 55 m_opaque_ap.reset (new lldb_private::FileSpecList(*(rhs.get()))); 56 } 57 return *this; 58} 59 60uint32_t 61SBFileSpecList::GetSize () const 62{ 63 return m_opaque_ap->GetSize(); 64} 65 66void 67SBFileSpecList::Append (const SBFileSpec &sb_file) 68{ 69 m_opaque_ap->Append (sb_file.ref()); 70} 71 72bool 73SBFileSpecList::AppendIfUnique (const SBFileSpec &sb_file) 74{ 75 return m_opaque_ap->AppendIfUnique (sb_file.ref()); 76} 77 78void 79SBFileSpecList::Clear() 80{ 81 m_opaque_ap->Clear(); 82} 83 84uint32_t 85SBFileSpecList::FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full) 86{ 87 return m_opaque_ap->FindFileIndex (idx, sb_file.ref(), full); 88} 89 90const SBFileSpec 91SBFileSpecList::GetFileSpecAtIndex (uint32_t idx) const 92{ 93 SBFileSpec new_spec; 94 new_spec.SetFileSpec(m_opaque_ap->GetFileSpecAtIndex(idx)); 95 return new_spec; 96} 97 98const lldb_private::FileSpecList * 99SBFileSpecList::operator->() const 100{ 101 return m_opaque_ap.get(); 102} 103 104const lldb_private::FileSpecList * 105SBFileSpecList::get() const 106{ 107 return m_opaque_ap.get(); 108} 109 110 111const lldb_private::FileSpecList & 112SBFileSpecList::operator*() const 113{ 114 return *m_opaque_ap.get(); 115} 116 117const lldb_private::FileSpecList & 118SBFileSpecList::ref() const 119{ 120 return *m_opaque_ap.get(); 121} 122 123bool 124SBFileSpecList::GetDescription (SBStream &description) const 125{ 126 Stream &strm = description.ref(); 127 128 if (m_opaque_ap.get()) 129 { 130 uint32_t num_files = m_opaque_ap->GetSize(); 131 strm.Printf ("%d files: ", num_files); 132 for (uint32_t i = 0; i < num_files; i++) 133 { 134 char path[PATH_MAX]; 135 if (m_opaque_ap->GetFileSpecAtIndex(i).GetPath(path, sizeof(path))) 136 strm.Printf ("\n %s", path); 137 } 138 } 139 else 140 strm.PutCString ("No value"); 141 142 return true; 143} 144