• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
20 using namespace lldb;
21 using namespace lldb_private;
22 
23 
24 
SBFileSpecList()25 SBFileSpecList::SBFileSpecList () :
26     m_opaque_ap(new FileSpecList())
27 {
28 }
29 
SBFileSpecList(const SBFileSpecList & rhs)30 SBFileSpecList::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                      rhs.m_opaque_ap.get(), m_opaque_ap.get());
42     }
43 }
44 
~SBFileSpecList()45 SBFileSpecList::~SBFileSpecList ()
46 {
47 }
48 
49 const SBFileSpecList &
operator =(const SBFileSpecList & rhs)50 SBFileSpecList::operator = (const SBFileSpecList &rhs)
51 {
52     if (this != &rhs)
53     {
54         m_opaque_ap.reset (new lldb_private::FileSpecList(*(rhs.get())));
55     }
56     return *this;
57 }
58 
59 uint32_t
GetSize() const60 SBFileSpecList::GetSize () const
61 {
62     return m_opaque_ap->GetSize();
63 }
64 
65 void
Append(const SBFileSpec & sb_file)66 SBFileSpecList::Append (const SBFileSpec &sb_file)
67 {
68     m_opaque_ap->Append (sb_file.ref());
69 }
70 
71 bool
AppendIfUnique(const SBFileSpec & sb_file)72 SBFileSpecList::AppendIfUnique (const SBFileSpec &sb_file)
73 {
74     return m_opaque_ap->AppendIfUnique (sb_file.ref());
75 }
76 
77 void
Clear()78 SBFileSpecList::Clear()
79 {
80     m_opaque_ap->Clear();
81 }
82 
83 uint32_t
FindFileIndex(uint32_t idx,const SBFileSpec & sb_file,bool full)84 SBFileSpecList::FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full)
85 {
86     return m_opaque_ap->FindFileIndex (idx, sb_file.ref(), full);
87 }
88 
89 const SBFileSpec
GetFileSpecAtIndex(uint32_t idx) const90 SBFileSpecList::GetFileSpecAtIndex (uint32_t idx) const
91 {
92     SBFileSpec new_spec;
93     new_spec.SetFileSpec(m_opaque_ap->GetFileSpecAtIndex(idx));
94     return new_spec;
95 }
96 
97 const lldb_private::FileSpecList *
operator ->() const98 SBFileSpecList::operator->() const
99 {
100     return m_opaque_ap.get();
101 }
102 
103 const lldb_private::FileSpecList *
get() const104 SBFileSpecList::get() const
105 {
106     return m_opaque_ap.get();
107 }
108 
109 
110 const lldb_private::FileSpecList &
operator *() const111 SBFileSpecList::operator*() const
112 {
113     return *m_opaque_ap.get();
114 }
115 
116 const lldb_private::FileSpecList &
ref() const117 SBFileSpecList::ref() const
118 {
119     return *m_opaque_ap.get();
120 }
121 
122 bool
GetDescription(SBStream & description) const123 SBFileSpecList::GetDescription (SBStream &description) const
124 {
125     Stream &strm = description.ref();
126 
127     if (m_opaque_ap.get())
128     {
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++)
132         {
133             char path[PATH_MAX];
134             if (m_opaque_ap->GetFileSpecAtIndex(i).GetPath(path, sizeof(path)))
135                 strm.Printf ("\n    %s", path);
136         }
137     }
138     else
139         strm.PutCString ("No value");
140 
141     return true;
142 }
143