1 //===-- SBStringList.cpp ----------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/API/SBStringList.h" 11 12 #include "lldb/Core/StringList.h" 13 14 using namespace lldb; 15 using namespace lldb_private; 16 17 SBStringList::SBStringList() : m_opaque_ap() {} 18 19 SBStringList::SBStringList(const lldb_private::StringList *lldb_strings_ptr) 20 : m_opaque_ap() { 21 if (lldb_strings_ptr) 22 m_opaque_ap.reset(new lldb_private::StringList(*lldb_strings_ptr)); 23 } 24 25 SBStringList::SBStringList(const SBStringList &rhs) : m_opaque_ap() { 26 if (rhs.IsValid()) 27 m_opaque_ap.reset(new lldb_private::StringList(*rhs)); 28 } 29 30 const SBStringList &SBStringList::operator=(const SBStringList &rhs) { 31 if (this != &rhs) { 32 if (rhs.IsValid()) 33 m_opaque_ap.reset(new lldb_private::StringList(*rhs)); 34 else 35 m_opaque_ap.reset(); 36 } 37 return *this; 38 } 39 40 SBStringList::~SBStringList() {} 41 42 const lldb_private::StringList *SBStringList::operator->() const { 43 return m_opaque_ap.get(); 44 } 45 46 const lldb_private::StringList &SBStringList::operator*() const { 47 return *m_opaque_ap; 48 } 49 50 bool SBStringList::IsValid() const { return (m_opaque_ap.get() != NULL); } 51 52 void SBStringList::AppendString(const char *str) { 53 if (str != NULL) { 54 if (IsValid()) 55 m_opaque_ap->AppendString(str); 56 else 57 m_opaque_ap.reset(new lldb_private::StringList(str)); 58 } 59 } 60 61 void SBStringList::AppendList(const char **strv, int strc) { 62 if ((strv != NULL) && (strc > 0)) { 63 if (IsValid()) 64 m_opaque_ap->AppendList(strv, strc); 65 else 66 m_opaque_ap.reset(new lldb_private::StringList(strv, strc)); 67 } 68 } 69 70 void SBStringList::AppendList(const SBStringList &strings) { 71 if (strings.IsValid()) { 72 if (!IsValid()) 73 m_opaque_ap.reset(new lldb_private::StringList()); 74 m_opaque_ap->AppendList(*(strings.m_opaque_ap)); 75 } 76 } 77 78 uint32_t SBStringList::GetSize() const { 79 if (IsValid()) { 80 return m_opaque_ap->GetSize(); 81 } 82 return 0; 83 } 84 85 const char *SBStringList::GetStringAtIndex(size_t idx) { 86 if (IsValid()) { 87 return m_opaque_ap->GetStringAtIndex(idx); 88 } 89 return NULL; 90 } 91 92 const char *SBStringList::GetStringAtIndex(size_t idx) const { 93 if (IsValid()) { 94 return m_opaque_ap->GetStringAtIndex(idx); 95 } 96 return NULL; 97 } 98 99 void SBStringList::Clear() { 100 if (IsValid()) { 101 m_opaque_ap->Clear(); 102 } 103 } 104