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
14using namespace lldb;
15using 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
28}
29
31 LLDB_INSTRUMENT_VA(this, rhs);
32
33 if (this != &rhs)
35 return *this;
36}
37
39
41 if (!IsValid())
42 m_opaque_up = std::make_unique<lldb_private::StringList>();
43
44 return m_opaque_up.get();
45}
46
48 return m_opaque_up.get();
49}
50
52 return *m_opaque_up;
53}
54
57 return this->operator bool();
58}
59SBStringList::operator bool() const {
61
62 return (m_opaque_up != nullptr);
63}
64
65void SBStringList::AppendString(const char *str) {
66 LLDB_INSTRUMENT_VA(this, str);
67
68 if (str != nullptr) {
69 if (IsValid())
70 m_opaque_up->AppendString(str);
71 else
72 m_opaque_up = std::make_unique<lldb_private::StringList>(str);
73 }
74}
75
76void SBStringList::AppendList(const char **strv, int strc) {
77 LLDB_INSTRUMENT_VA(this, strv, strc);
78
79 if ((strv != nullptr) && (strc > 0)) {
80 if (IsValid())
81 m_opaque_up->AppendList(strv, strc);
82 else
83 m_opaque_up = std::make_unique<lldb_private::StringList>(strv, strc);
84 }
85}
86
88 LLDB_INSTRUMENT_VA(this, strings);
89
90 if (strings.IsValid()) {
91 if (!IsValid())
92 m_opaque_up = std::make_unique<lldb_private::StringList>();
93 m_opaque_up->AppendList(*(strings.m_opaque_up));
94 }
95}
96
98 if (!IsValid())
99 m_opaque_up = std::make_unique<lldb_private::StringList>();
100 m_opaque_up->AppendList(strings);
101}
102
103uint32_t SBStringList::GetSize() const {
104 LLDB_INSTRUMENT_VA(this);
105
106 if (IsValid()) {
107 return m_opaque_up->GetSize();
108 }
109 return 0;
110}
111
112const char *SBStringList::GetStringAtIndex(size_t idx) {
113 LLDB_INSTRUMENT_VA(this, idx);
114
115 if (IsValid()) {
116 return ConstString(m_opaque_up->GetStringAtIndex(idx)).GetCString();
117 }
118 return nullptr;
119}
120
121const char *SBStringList::GetStringAtIndex(size_t idx) const {
122 LLDB_INSTRUMENT_VA(this, idx);
123
124 if (IsValid()) {
125 return ConstString(m_opaque_up->GetStringAtIndex(idx)).GetCString();
126 }
127 return nullptr;
128}
129
131 LLDB_INSTRUMENT_VA(this);
132
133 if (IsValid()) {
134 m_opaque_up->Clear();
135 }
136}
#define LLDB_INSTRUMENT_VA(...)
bool IsValid() const
uint32_t GetSize() const
std::unique_ptr< lldb_private::StringList > m_opaque_up
Definition: SBStringList.h:63
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.
Definition: ConstString.h:216
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