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 return m_opaque_up.get();
42}
43
45 return *m_opaque_up;
46}
47
50 return this->operator bool();
51}
52SBStringList::operator bool() const {
54
55 return (m_opaque_up != nullptr);
56}
57
58void 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
69void 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
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
91 if (!IsValid())
92 m_opaque_up = std::make_unique<lldb_private::StringList>();
93 m_opaque_up->AppendList(strings);
94}
95
98
99 if (IsValid()) {
100 return m_opaque_up->GetSize();
101 }
102 return 0;
103}
104
105const 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
114const 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}
#define LLDB_INSTRUMENT_VA(...)
bool IsValid() const
uint32_t GetSize() const
std::unique_ptr< lldb_private::StringList > m_opaque_up
Definition: SBStringList.h:60
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 lldb_private::StringList * operator->() const
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