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 SBStringList()17SBStringList::SBStringList () : 18 m_opaque_ap () 19 { 20 } 21 SBStringList(const lldb_private::StringList * lldb_strings_ptr)22SBStringList::SBStringList (const lldb_private::StringList *lldb_strings_ptr) : 23 m_opaque_ap () 24 { 25 if (lldb_strings_ptr) 26 m_opaque_ap.reset (new lldb_private::StringList (*lldb_strings_ptr)); 27 } 28 SBStringList(const SBStringList & rhs)29SBStringList::SBStringList (const SBStringList &rhs) : 30 m_opaque_ap () 31 { 32 if (rhs.IsValid()) 33 m_opaque_ap.reset (new lldb_private::StringList(*rhs)); 34 } 35 36 37 const SBStringList & operator =(const SBStringList & rhs)38SBStringList::operator = (const SBStringList &rhs) 39 { 40 if (this != &rhs) 41 { 42 if (rhs.IsValid()) 43 m_opaque_ap.reset(new lldb_private::StringList(*rhs)); 44 else 45 m_opaque_ap.reset(); 46 } 47 return *this; 48 } 49 ~SBStringList()50SBStringList::~SBStringList () 51 { 52 } 53 54 const lldb_private::StringList * operator ->() const55SBStringList::operator->() const 56 { 57 return m_opaque_ap.get(); 58 } 59 60 const lldb_private::StringList & operator *() const61SBStringList::operator*() const 62 { 63 return *m_opaque_ap; 64 } 65 66 bool IsValid() const67SBStringList::IsValid() const 68 { 69 return (m_opaque_ap.get() != NULL); 70 } 71 72 void AppendString(const char * str)73SBStringList::AppendString (const char *str) 74 { 75 if (str != NULL) 76 { 77 if (IsValid()) 78 m_opaque_ap->AppendString (str); 79 else 80 m_opaque_ap.reset (new lldb_private::StringList (str)); 81 } 82 83 } 84 85 void AppendList(const char ** strv,int strc)86SBStringList::AppendList (const char **strv, int strc) 87 { 88 if ((strv != NULL) 89 && (strc > 0)) 90 { 91 if (IsValid()) 92 m_opaque_ap->AppendList (strv, strc); 93 else 94 m_opaque_ap.reset (new lldb_private::StringList (strv, strc)); 95 } 96 } 97 98 void AppendList(const SBStringList & strings)99SBStringList::AppendList (const SBStringList &strings) 100 { 101 if (strings.IsValid()) 102 { 103 if (! IsValid()) 104 m_opaque_ap.reset (new lldb_private::StringList()); 105 m_opaque_ap->AppendList (*(strings.m_opaque_ap)); 106 } 107 } 108 109 uint32_t GetSize() const110SBStringList::GetSize () const 111 { 112 if (IsValid()) 113 { 114 return m_opaque_ap->GetSize(); 115 } 116 return 0; 117 } 118 119 const char * GetStringAtIndex(size_t idx)120SBStringList::GetStringAtIndex (size_t idx) 121 { 122 if (IsValid()) 123 { 124 return m_opaque_ap->GetStringAtIndex (idx); 125 } 126 return NULL; 127 } 128 129 void Clear()130SBStringList::Clear () 131 { 132 if (IsValid()) 133 { 134 m_opaque_ap->Clear(); 135 } 136 } 137