LLDB  mainline
SBStringList.cpp
Go to the documentation of this file.
1 //===-- SBStringList.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"
13 
14 using namespace lldb;
15 using namespace lldb_private;
16 
18 
20  if (lldb_strings_ptr)
21  m_opaque_up = std::make_unique<StringList>(*lldb_strings_ptr);
22 }
23 
25  LLDB_INSTRUMENT_VA(this, rhs);
26 
27  m_opaque_up = clone(rhs.m_opaque_up);
28 }
29 
31  LLDB_INSTRUMENT_VA(this, rhs);
32 
33  if (this != &rhs)
34  m_opaque_up = clone(rhs.m_opaque_up);
35  return *this;
36 }
37 
38 SBStringList::~SBStringList() = default;
39 
41  return m_opaque_up.get();
42 }
43 
45  return *m_opaque_up;
46 }
47 
48 bool SBStringList::IsValid() const {
49  LLDB_INSTRUMENT_VA(this);
50  return this->operator bool();
51 }
52 SBStringList::operator bool() const {
53  LLDB_INSTRUMENT_VA(this);
54 
55  return (m_opaque_up != nullptr);
56 }
57 
58 void SBStringList::AppendString(const char *str) {
59  LLDB_INSTRUMENT_VA(this, str);
60 
61  if (str != nullptr) {
62  if (IsValid())
63  m_opaque_up->AppendString(str);
64  else
65  m_opaque_up = std::make_unique<lldb_private::StringList>(str);
66  }
67 }
68 
69 void SBStringList::AppendList(const char **strv, int strc) {
70  LLDB_INSTRUMENT_VA(this, strv, strc);
71 
72  if ((strv != nullptr) && (strc > 0)) {
73  if (IsValid())
74  m_opaque_up->AppendList(strv, strc);
75  else
76  m_opaque_up = std::make_unique<lldb_private::StringList>(strv, strc);
77  }
78 }
79 
80 void SBStringList::AppendList(const SBStringList &strings) {
81  LLDB_INSTRUMENT_VA(this, strings);
82 
83  if (strings.IsValid()) {
84  if (!IsValid())
85  m_opaque_up = std::make_unique<lldb_private::StringList>();
86  m_opaque_up->AppendList(*(strings.m_opaque_up));
87  }
88 }
89 
90 void SBStringList::AppendList(const StringList &strings) {
91  if (!IsValid())
92  m_opaque_up = std::make_unique<lldb_private::StringList>();
93  m_opaque_up->AppendList(strings);
94 }
95 
97  LLDB_INSTRUMENT_VA(this);
98 
99  if (IsValid()) {
100  return m_opaque_up->GetSize();
101  }
102  return 0;
103 }
104 
105 const char *SBStringList::GetStringAtIndex(size_t idx) {
106  LLDB_INSTRUMENT_VA(this, idx);
107 
108  if (IsValid()) {
109  return m_opaque_up->GetStringAtIndex(idx);
110  }
111  return nullptr;
112 }
113 
114 const char *SBStringList::GetStringAtIndex(size_t idx) const {
115  LLDB_INSTRUMENT_VA(this, idx);
116 
117  if (IsValid()) {
118  return m_opaque_up->GetStringAtIndex(idx);
119  }
120  return nullptr;
121 }
122 
124  LLDB_INSTRUMENT_VA(this);
125 
126  if (IsValid()) {
127  m_opaque_up->Clear();
128  }
129 }
lldb::SBStringList::operator*
const lldb_private::StringList & operator*() const
Definition: SBStringList.cpp:44
lldb::SBStringList
Definition: SBStringList.h:16
Instrumentation.h
lldb::SBStringList::AppendString
void AppendString(const char *str)
Definition: SBStringList.cpp:58
lldb::SBStringList::GetSize
uint32_t GetSize() const
Definition: SBStringList.cpp:96
SBStringList.h
lldb::SBStringList::GetStringAtIndex
const char * GetStringAtIndex(size_t idx)
Definition: SBStringList.cpp:105
bool
lldb::SBStringList::IsValid
bool IsValid() const
Definition: SBStringList.cpp:48
lldb_private::clone
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
Utils.h
lldb::SBStringList::Clear
void Clear()
Definition: SBStringList.cpp:123
lldb_private::StringList
Definition: StringList.h:26
StringList.h
lldb::SBStringList::SBStringList
SBStringList()
Definition: SBStringList.cpp:17
uint32_t
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
LLDB_INSTRUMENT_VA
#define LLDB_INSTRUMENT_VA(...)
Definition: Instrumentation.h:98
lldb::SBStringList::operator->
const lldb_private::StringList * operator->() const
Definition: SBStringList.cpp:40
lldb::SBStringList::operator=
const SBStringList & operator=(const SBStringList &rhs)
Definition: SBStringList.cpp:30
lldb::SBStringList::m_opaque_up
std::unique_ptr< lldb_private::StringList > m_opaque_up
Definition: SBStringList.h:60
lldb
Definition: SBAddress.h:15
lldb::SBStringList::~SBStringList
~SBStringList()
lldb::SBStringList::AppendList
void AppendList(const char **strv, int strc)
Definition: SBStringList.cpp:69