blob: a457a754f0d06beddea42002f333820361381264 [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"
Greg Claytonda7bc7d2011-11-13 06:57:31 +000017#include "lldb/Core/Stream.h"
Jim Ingham969795f2011-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 Clayton5160ce52013-03-27 23:08:40 +000033 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Jim Ingham969795f2011-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 Claytonc1ef10f2011-09-21 06:45:51 +000040 log->Printf ("SBFileSpecList::SBFileSpecList (const SBFileSpecList rhs.ap=%p) => SBFileSpecList(%p)",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +000041 static_cast<void*>(rhs.m_opaque_ap.get()),
42 static_cast<void*>(m_opaque_ap.get()));
Jim Ingham969795f2011-09-21 01:17:13 +000043 }
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
Jim Ingham87df91b2011-09-23 00:54:11 +000085SBFileSpecList::FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full)
Jim Ingham969795f2011-09-21 01:17:13 +000086{
Jim Ingham87df91b2011-09-23 00:54:11 +000087 return m_opaque_ap->FindFileIndex (idx, sb_file.ref(), full);
Jim Ingham969795f2011-09-21 01:17:13 +000088}
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{
Greg Claytonda7bc7d2011-11-13 06:57:31 +0000126 Stream &strm = description.ref();
127
Jim Ingham969795f2011-09-21 01:17:13 +0000128 if (m_opaque_ap.get())
129 {
130 uint32_t num_files = m_opaque_ap->GetSize();
Greg Claytonda7bc7d2011-11-13 06:57:31 +0000131 strm.Printf ("%d files: ", num_files);
Jim Ingham969795f2011-09-21 01:17:13 +0000132 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)))
Greg Claytonda7bc7d2011-11-13 06:57:31 +0000136 strm.Printf ("\n %s", path);
Jim Ingham969795f2011-09-21 01:17:13 +0000137 }
138 }
139 else
Greg Claytonda7bc7d2011-11-13 06:57:31 +0000140 strm.PutCString ("No value");
Jim Ingham969795f2011-09-21 01:17:13 +0000141
142 return true;
143}