blob: 3ebf3cc80a2ab99caa4e1aba4ce8880630a1518c [file] [log] [blame]
Jim Ingham03c8ee52011-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"
Greg Clayton96154be2011-11-13 06:57:31 +000017#include "lldb/Core/Stream.h"
Jim Ingham03c8ee52011-09-21 01:17:13 +000018#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{
Greg Clayton952e9dc2013-03-27 23:08:40 +000033 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Jim Ingham03c8ee52011-09-21 01:17:13 +000034
35 if (rhs.m_opaque_ap.get())
36 m_opaque_ap.reset (new FileSpecList (*(rhs.get())));
37
38 if (log)
39 {
Greg Claytona253c932011-09-21 06:45:51 +000040 log->Printf ("SBFileSpecList::SBFileSpecList (const SBFileSpecList rhs.ap=%p) => SBFileSpecList(%p)",
Jim Ingham03c8ee52011-09-21 01:17:13 +000041 rhs.m_opaque_ap.get(), m_opaque_ap.get());
42 }
43}
44
45SBFileSpecList::~SBFileSpecList ()
46{
47}
48
49const SBFileSpecList &
50SBFileSpecList::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
59uint32_t
60SBFileSpecList::GetSize () const
61{
62 return m_opaque_ap->GetSize();
63}
64
65void
66SBFileSpecList::Append (const SBFileSpec &sb_file)
67{
68 m_opaque_ap->Append (sb_file.ref());
69}
70
71bool
72SBFileSpecList::AppendIfUnique (const SBFileSpec &sb_file)
73{
74 return m_opaque_ap->AppendIfUnique (sb_file.ref());
75}
76
77void
78SBFileSpecList::Clear()
79{
80 m_opaque_ap->Clear();
81}
82
83uint32_t
Jim Inghamd6d47972011-09-23 00:54:11 +000084SBFileSpecList::FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full)
Jim Ingham03c8ee52011-09-21 01:17:13 +000085{
Jim Inghamd6d47972011-09-23 00:54:11 +000086 return m_opaque_ap->FindFileIndex (idx, sb_file.ref(), full);
Jim Ingham03c8ee52011-09-21 01:17:13 +000087}
88
89const SBFileSpec
90SBFileSpecList::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
97const lldb_private::FileSpecList *
98SBFileSpecList::operator->() const
99{
100 return m_opaque_ap.get();
101}
102
103const lldb_private::FileSpecList *
104SBFileSpecList::get() const
105{
106 return m_opaque_ap.get();
107}
108
109
110const lldb_private::FileSpecList &
111SBFileSpecList::operator*() const
112{
113 return *m_opaque_ap.get();
114}
115
116const lldb_private::FileSpecList &
117SBFileSpecList::ref() const
118{
119 return *m_opaque_ap.get();
120}
121
122bool
123SBFileSpecList::GetDescription (SBStream &description) const
124{
Greg Clayton96154be2011-11-13 06:57:31 +0000125 Stream &strm = description.ref();
126
Jim Ingham03c8ee52011-09-21 01:17:13 +0000127 if (m_opaque_ap.get())
128 {
129 uint32_t num_files = m_opaque_ap->GetSize();
Greg Clayton96154be2011-11-13 06:57:31 +0000130 strm.Printf ("%d files: ", num_files);
Jim Ingham03c8ee52011-09-21 01:17:13 +0000131 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)))
Greg Clayton96154be2011-11-13 06:57:31 +0000135 strm.Printf ("\n %s", path);
Jim Ingham03c8ee52011-09-21 01:17:13 +0000136 }
137 }
138 else
Greg Clayton96154be2011-11-13 06:57:31 +0000139 strm.PutCString ("No value");
Jim Ingham03c8ee52011-09-21 01:17:13 +0000140
141 return true;
142}