LLDB mainline
SBFileSpecList.cpp
Go to the documentation of this file.
1//===-- SBFileSpecList.cpp ------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "Utils.h"
11#include "lldb/API/SBFileSpec.h"
12#include "lldb/API/SBStream.h"
13#include "lldb/Host/PosixApi.h"
17#include "lldb/Utility/Stream.h"
18
19#include <climits>
20
21using namespace lldb;
22using namespace lldb_private;
23
26}
27
29 LLDB_INSTRUMENT_VA(this, rhs);
30
32}
33
35
37 LLDB_INSTRUMENT_VA(this, rhs);
38
39 if (this != &rhs)
41 return *this;
42}
43
44uint32_t SBFileSpecList::GetSize() const {
46
47 return m_opaque_up->GetSize();
48}
49
50void SBFileSpecList::Append(const SBFileSpec &sb_file) {
51 LLDB_INSTRUMENT_VA(this, sb_file);
52
53 m_opaque_up->Append(sb_file.ref());
54}
55
57 LLDB_INSTRUMENT_VA(this, sb_file);
58
59 return m_opaque_up->AppendIfUnique(sb_file.ref());
60}
61
64
65 m_opaque_up->Clear();
66}
67
68uint32_t SBFileSpecList::FindFileIndex(uint32_t idx, const SBFileSpec &sb_file,
69 bool full) {
70 LLDB_INSTRUMENT_VA(this, idx, sb_file, full);
71
72 return m_opaque_up->FindFileIndex(idx, sb_file.ref(), full);
73}
74
76 LLDB_INSTRUMENT_VA(this, idx);
77
78 SBFileSpec new_spec;
79 new_spec.SetFileSpec(m_opaque_up->GetFileSpecAtIndex(idx));
80 return new_spec;
81}
82
84 return m_opaque_up.get();
85}
86
88 return m_opaque_up.get();
89}
90
92 return *m_opaque_up;
93}
94
96 return *m_opaque_up;
97}
98
99bool SBFileSpecList::GetDescription(SBStream &description) const {
100 LLDB_INSTRUMENT_VA(this, description);
101
102 Stream &strm = description.ref();
103
104 if (m_opaque_up) {
105 uint32_t num_files = m_opaque_up->GetSize();
106 strm.Printf("%d files: ", num_files);
107 for (uint32_t i = 0; i < num_files; i++) {
108 char path[PATH_MAX];
109 if (m_opaque_up->GetFileSpecAtIndex(i).GetPath(path, sizeof(path)))
110 strm.Printf("\n %s", path);
111 }
112 } else
113 strm.PutCString("No value");
114
115 return true;
116}
#define LLDB_INSTRUMENT_VA(...)
const lldb_private::FileSpecList * operator->() const
const lldb_private::FileSpecList * get() const
void Append(const SBFileSpec &sb_file)
const SBFileSpec GetFileSpecAtIndex(uint32_t idx) const
uint32_t FindFileIndex(uint32_t idx, const SBFileSpec &sb_file, bool full)
bool GetDescription(SBStream &description) const
const lldb_private::FileSpecList & operator*() const
std::unique_ptr< lldb_private::FileSpecList > m_opaque_up
const SBFileSpecList & operator=(const lldb::SBFileSpecList &rhs)
uint32_t GetSize() const
bool AppendIfUnique(const SBFileSpec &sb_file)
const lldb_private::FileSpecList & ref() const
void SetFileSpec(const lldb_private::FileSpec &fspec)
Definition: SBFileSpec.cpp:164
const lldb_private::FileSpec & ref() const
Definition: SBFileSpec.cpp:162
lldb_private::Stream & ref()
Definition: SBStream.cpp:177
A file collection class.
Definition: FileSpecList.h:91
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:134
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:65
A class that represents a running process on the host machine.
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
Definition: SBAddress.h:15
#define PATH_MAX