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"
15
16using namespace lldb;
17using namespace lldb_private;
18
20
22 if (lldb_strings_ptr)
23 m_opaque_up = std::make_unique<StringList>(*lldb_strings_ptr);
24}
25
31
33 LLDB_INSTRUMENT_VA(this, rhs);
34
35 if (this != &rhs)
37 return *this;
38}
39
41
43 if (!IsValid())
44 m_opaque_up = std::make_unique<lldb_private::StringList>();
45
46 return m_opaque_up.get();
47}
48
52
56
59 return this->operator bool();
60}
61SBStringList::operator bool() const {
63
64 return (m_opaque_up != nullptr);
65}
66
67void SBStringList::AppendString(const char *str) {
68 LLDB_INSTRUMENT_VA(this, str);
69
70 if (str != nullptr) {
71 if (IsValid())
72 m_opaque_up->AppendString(str);
73 else
74 m_opaque_up = std::make_unique<lldb_private::StringList>(str);
75 }
76}
77
78void SBStringList::AppendList(const char **strv, int strc) {
79 LLDB_INSTRUMENT_VA(this, strv, strc);
80
81 if ((strv != nullptr) && (strc > 0)) {
82 if (IsValid())
83 m_opaque_up->AppendList(strv, strc);
84 else
85 m_opaque_up = std::make_unique<lldb_private::StringList>(strv, strc);
86 }
87}
88
90 LLDB_INSTRUMENT_VA(this, strings);
91
92 if (strings.IsValid()) {
93 if (!IsValid())
94 m_opaque_up = std::make_unique<lldb_private::StringList>();
95 m_opaque_up->AppendList(*(strings.m_opaque_up));
96 }
97}
98
100 if (!IsValid())
101 m_opaque_up = std::make_unique<lldb_private::StringList>();
102 m_opaque_up->AppendList(strings);
103}
104
105uint32_t SBStringList::GetSize() const {
106 LLDB_INSTRUMENT_VA(this);
107
108 if (IsValid()) {
109 return m_opaque_up->GetSize();
110 }
111 return 0;
112}
113
114const char *SBStringList::GetStringAtIndex(size_t idx) {
115 LLDB_INSTRUMENT_VA(this, idx);
116
117 if (IsValid()) {
119 m_opaque_up->GetStringAtIndex(idx));
120 }
121 return nullptr;
122}
123
124const char *SBStringList::GetStringAtIndex(size_t idx) const {
125 LLDB_INSTRUMENT_VA(this, idx);
126
127 if (IsValid()) {
129 m_opaque_up->GetStringAtIndex(idx));
130 }
131 return nullptr;
132}
133
135 LLDB_INSTRUMENT_VA(this);
136
137 if (IsValid()) {
138 m_opaque_up->Clear();
139 }
140}
#define LLDB_INSTRUMENT_VA(...)
bool IsValid() const
uint32_t GetSize() const
std::unique_ptr< lldb_private::StringList > m_opaque_up
lldb_private::StringList * operator->()
const SBStringList & operator=(const SBStringList &rhs)
void AppendString(const char *str)
void AppendList(const char **strv, int strc)
const lldb_private::StringList & operator*() const
const char * GetStringAtIndex(size_t idx)
const char * Intern(llvm::StringRef str) const
Definition StringPool.h:78
static StringPoolRef GetSystemPool()
The system pool. Only valid between Initialize and Terminate.
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:25