1 //===-- SBStringList.cpp --------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBStringList.h"
11 #include "lldb/Utility/Instrumentation.h"
12 #include "lldb/Utility/StringList.h"
15 using namespace lldb_private
;
17 SBStringList::SBStringList() { LLDB_INSTRUMENT_VA(this); }
19 SBStringList::SBStringList(const lldb_private::StringList
*lldb_strings_ptr
) {
21 m_opaque_up
= std::make_unique
<StringList
>(*lldb_strings_ptr
);
24 SBStringList::SBStringList(const SBStringList
&rhs
) {
25 LLDB_INSTRUMENT_VA(this, rhs
);
27 m_opaque_up
= clone(rhs
.m_opaque_up
);
30 const SBStringList
&SBStringList::operator=(const SBStringList
&rhs
) {
31 LLDB_INSTRUMENT_VA(this, rhs
);
34 m_opaque_up
= clone(rhs
.m_opaque_up
);
38 SBStringList::~SBStringList() = default;
40 lldb_private::StringList
*SBStringList::operator->() {
42 m_opaque_up
= std::make_unique
<lldb_private::StringList
>();
44 return m_opaque_up
.get();
47 const lldb_private::StringList
*SBStringList::operator->() const {
48 return m_opaque_up
.get();
51 const lldb_private::StringList
&SBStringList::operator*() const {
55 bool SBStringList::IsValid() const {
56 LLDB_INSTRUMENT_VA(this);
57 return this->operator bool();
59 SBStringList::operator bool() const {
60 LLDB_INSTRUMENT_VA(this);
62 return (m_opaque_up
!= nullptr);
65 void SBStringList::AppendString(const char *str
) {
66 LLDB_INSTRUMENT_VA(this, str
);
70 m_opaque_up
->AppendString(str
);
72 m_opaque_up
= std::make_unique
<lldb_private::StringList
>(str
);
76 void SBStringList::AppendList(const char **strv
, int strc
) {
77 LLDB_INSTRUMENT_VA(this, strv
, strc
);
79 if ((strv
!= nullptr) && (strc
> 0)) {
81 m_opaque_up
->AppendList(strv
, strc
);
83 m_opaque_up
= std::make_unique
<lldb_private::StringList
>(strv
, strc
);
87 void SBStringList::AppendList(const SBStringList
&strings
) {
88 LLDB_INSTRUMENT_VA(this, strings
);
90 if (strings
.IsValid()) {
92 m_opaque_up
= std::make_unique
<lldb_private::StringList
>();
93 m_opaque_up
->AppendList(*(strings
.m_opaque_up
));
97 void SBStringList::AppendList(const StringList
&strings
) {
99 m_opaque_up
= std::make_unique
<lldb_private::StringList
>();
100 m_opaque_up
->AppendList(strings
);
103 uint32_t SBStringList::GetSize() const {
104 LLDB_INSTRUMENT_VA(this);
107 return m_opaque_up
->GetSize();
112 const char *SBStringList::GetStringAtIndex(size_t idx
) {
113 LLDB_INSTRUMENT_VA(this, idx
);
116 return ConstString(m_opaque_up
->GetStringAtIndex(idx
)).GetCString();
121 const char *SBStringList::GetStringAtIndex(size_t idx
) const {
122 LLDB_INSTRUMENT_VA(this, idx
);
125 return ConstString(m_opaque_up
->GetStringAtIndex(idx
)).GetCString();
130 void SBStringList::Clear() {
131 LLDB_INSTRUMENT_VA(this);
134 m_opaque_up
->Clear();