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