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/Utility/StringList.h" 13 14 using namespace lldb; 15 using namespace lldb_private; 16 SBStringList()17SBStringList::SBStringList() : m_opaque_ap() {} 18 SBStringList(const lldb_private::StringList * lldb_strings_ptr)19SBStringList::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 SBStringList(const SBStringList & rhs)25SBStringList::SBStringList(const SBStringList &rhs) : m_opaque_ap() { 26 if (rhs.IsValid()) 27 m_opaque_ap.reset(new lldb_private::StringList(*rhs)); 28 } 29 operator =(const SBStringList & rhs)30const 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 ~SBStringList()40SBStringList::~SBStringList() {} 41 operator ->() const42const lldb_private::StringList *SBStringList::operator->() const { 43 return m_opaque_ap.get(); 44 } 45 operator *() const46const lldb_private::StringList &SBStringList::operator*() const { 47 return *m_opaque_ap; 48 } 49 IsValid() const50bool SBStringList::IsValid() const { return (m_opaque_ap != NULL); } 51 AppendString(const char * str)52void 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 AppendList(const char ** strv,int strc)61void 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 AppendList(const SBStringList & strings)70void 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 AppendList(const StringList & strings)78void SBStringList::AppendList(const StringList &strings) { 79 if (!IsValid()) 80 m_opaque_ap.reset(new lldb_private::StringList()); 81 m_opaque_ap->AppendList(strings); 82 } 83 GetSize() const84uint32_t SBStringList::GetSize() const { 85 if (IsValid()) { 86 return m_opaque_ap->GetSize(); 87 } 88 return 0; 89 } 90 GetStringAtIndex(size_t idx)91const char *SBStringList::GetStringAtIndex(size_t idx) { 92 if (IsValid()) { 93 return m_opaque_ap->GetStringAtIndex(idx); 94 } 95 return NULL; 96 } 97 GetStringAtIndex(size_t idx) const98const char *SBStringList::GetStringAtIndex(size_t idx) const { 99 if (IsValid()) { 100 return m_opaque_ap->GetStringAtIndex(idx); 101 } 102 return NULL; 103 } 104 Clear()105void SBStringList::Clear() { 106 if (IsValid()) { 107 m_opaque_ap->Clear(); 108 } 109 } 110