2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBStringList.cpp ----------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-09 00:52:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/API/SBStringList.h"
|
2019-03-06 08:05:55 +08:00
|
|
|
#include "Utils.h"
|
2017-03-22 02:25:04 +08:00
|
|
|
#include "lldb/Utility/StringList.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
SBStringList::SBStringList() : m_opaque_up() {}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBStringList::SBStringList(const lldb_private::StringList *lldb_strings_ptr)
|
2019-02-13 14:25:41 +08:00
|
|
|
: m_opaque_up() {
|
2016-09-07 04:57:50 +08:00
|
|
|
if (lldb_strings_ptr)
|
2019-03-06 08:05:55 +08:00
|
|
|
m_opaque_up = llvm::make_unique<StringList>(*lldb_strings_ptr);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
SBStringList::SBStringList(const SBStringList &rhs) : m_opaque_up() {
|
2019-03-06 08:05:55 +08:00
|
|
|
m_opaque_up = clone(rhs.m_opaque_up);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const SBStringList &SBStringList::operator=(const SBStringList &rhs) {
|
2019-03-06 08:05:55 +08:00
|
|
|
if (this != &rhs)
|
|
|
|
m_opaque_up = clone(rhs.m_opaque_up);
|
2016-09-07 04:57:50 +08:00
|
|
|
return *this;
|
2010-11-06 07:17:00 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
SBStringList::~SBStringList() {}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const lldb_private::StringList *SBStringList::operator->() const {
|
2019-02-13 14:25:41 +08:00
|
|
|
return m_opaque_up.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const lldb_private::StringList &SBStringList::operator*() const {
|
2019-02-13 14:25:41 +08:00
|
|
|
return *m_opaque_up;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
bool SBStringList::IsValid() const { return (m_opaque_up != NULL); }
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBStringList::AppendString(const char *str) {
|
|
|
|
if (str != NULL) {
|
|
|
|
if (IsValid())
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up->AppendString(str);
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up.reset(new lldb_private::StringList(str));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBStringList::AppendList(const char **strv, int strc) {
|
|
|
|
if ((strv != NULL) && (strc > 0)) {
|
|
|
|
if (IsValid())
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up->AppendList(strv, strc);
|
2016-09-07 04:57:50 +08:00
|
|
|
else
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up.reset(new lldb_private::StringList(strv, strc));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBStringList::AppendList(const SBStringList &strings) {
|
|
|
|
if (strings.IsValid()) {
|
|
|
|
if (!IsValid())
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up.reset(new lldb_private::StringList());
|
|
|
|
m_opaque_up->AppendList(*(strings.m_opaque_up));
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-21 06:54:49 +08:00
|
|
|
void SBStringList::AppendList(const StringList &strings) {
|
|
|
|
if (!IsValid())
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up.reset(new lldb_private::StringList());
|
|
|
|
m_opaque_up->AppendList(strings);
|
2016-09-21 06:54:49 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
uint32_t SBStringList::GetSize() const {
|
|
|
|
if (IsValid()) {
|
2019-02-13 14:25:41 +08:00
|
|
|
return m_opaque_up->GetSize();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return 0;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const char *SBStringList::GetStringAtIndex(size_t idx) {
|
|
|
|
if (IsValid()) {
|
2019-02-13 14:25:41 +08:00
|
|
|
return m_opaque_up->GetStringAtIndex(idx);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const char *SBStringList::GetStringAtIndex(size_t idx) const {
|
|
|
|
if (IsValid()) {
|
2019-02-13 14:25:41 +08:00
|
|
|
return m_opaque_up->GetStringAtIndex(idx);
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return NULL;
|
2016-04-28 09:40:57 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
void SBStringList::Clear() {
|
|
|
|
if (IsValid()) {
|
2019-02-13 14:25:41 +08:00
|
|
|
m_opaque_up->Clear();
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|