[Go to site: main page, start]

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"
14
15using namespace lldb;
16using namespace lldb_private;
17
19
21 if (lldb_strings_ptr)
22 m_opaque_up = std::make_unique<StringList>(*lldb_strings_ptr);
23}
24
30
32 LLDB_INSTRUMENT_VA(this, rhs);
33
34 if (this != &rhs)
36 return *this;
37}
38
40
42 if (!IsValid())
43 m_opaque_up = std::make_unique<lldb_private::StringList>();
44
45 return m_opaque_up.get();
46}
47
51
55
58 return this->operator bool();
59}
60SBStringList::operator bool() const {
62
63 return (m_opaque_up != nullptr);
64}
65
66void SBStringList::AppendString(const char *str) {
67 LLDB_INSTRUMENT_VA(this, str);
68
69 if (str != nullptr) {
70 if (IsValid())
71 m_opaque_up->AppendString(str);
72 else
73 m_opaque_up = std::make_unique<lldb_private::StringList>(str);
74 }
75}
76
77void SBStringList::AppendList(const char **strv, int strc) {
78 LLDB_INSTRUMENT_VA(this, strv, strc);
79
80 if ((strv != nullptr) && (strc > 0)) {
81 if (IsValid())
82 m_opaque_up->AppendList(strv, strc);
83 else
84 m_opaque_up = std::make_unique<lldb_private::StringList>(strv, strc);
85 }
86}
87
89 LLDB_INSTRUMENT_VA(this, strings);
90
91 if (strings.IsValid()) {
92 if (!IsValid())
93 m_opaque_up = std::make_unique<lldb_private::StringList>();
94 m_opaque_up->AppendList(*(strings.m_opaque_up));
95 }
96}
97
99 if (!IsValid())
100 m_opaque_up = std::make_unique<lldb_private::StringList>();
101 m_opaque_up->AppendList(strings);
102}
103
104uint32_t SBStringList::GetSize() const {
105 LLDB_INSTRUMENT_VA(this);
106
107 if (IsValid()) {
108 return m_opaque_up->GetSize();
109 }
110 return 0;
111}
112
113const char *SBStringList::GetStringAtIndex(size_t idx) {
114 LLDB_INSTRUMENT_VA(this, idx);
115
116 if (IsValid()) {
117 return ConstString(m_opaque_up->GetStringAtIndex(idx)).GetCString();
118 }
119 return nullptr;
120}
121
122const char *SBStringList::GetStringAtIndex(size_t idx) const {
123 LLDB_INSTRUMENT_VA(this, idx);
124
125 if (IsValid()) {
126 return ConstString(m_opaque_up->GetStringAtIndex(idx)).GetCString();
127 }
128 return nullptr;
129}
130
132 LLDB_INSTRUMENT_VA(this);
133
134 if (IsValid()) {
135 m_opaque_up->Clear();
136 }
137}
#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)
A uniqued constant string class.
Definition ConstString.h:40
const char * GetCString() const
Get the string value as a C string.
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