1 //===-- SBSymbolContextList.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/SBSymbolContextList.h" 11 #include "lldb/API/SBStream.h" 12 #include "lldb/Symbol/SymbolContext.h" 13 14 using namespace lldb; 15 using namespace lldb_private; 16 SBSymbolContextList()17SBSymbolContextList::SBSymbolContextList () : 18 m_opaque_ap (new SymbolContextList()) 19 { 20 } 21 SBSymbolContextList(const SBSymbolContextList & rhs)22SBSymbolContextList::SBSymbolContextList (const SBSymbolContextList& rhs) : 23 m_opaque_ap (new SymbolContextList(*rhs.m_opaque_ap)) 24 { 25 } 26 ~SBSymbolContextList()27SBSymbolContextList::~SBSymbolContextList () 28 { 29 } 30 31 const SBSymbolContextList & operator =(const SBSymbolContextList & rhs)32SBSymbolContextList::operator = (const SBSymbolContextList &rhs) 33 { 34 if (this != &rhs) 35 { 36 *m_opaque_ap = *rhs.m_opaque_ap; 37 } 38 return *this; 39 } 40 41 uint32_t GetSize() const42SBSymbolContextList::GetSize() const 43 { 44 if (m_opaque_ap.get()) 45 return m_opaque_ap->GetSize(); 46 return 0; 47 } 48 49 SBSymbolContext GetContextAtIndex(uint32_t idx)50SBSymbolContextList::GetContextAtIndex (uint32_t idx) 51 { 52 SBSymbolContext sb_sc; 53 if (m_opaque_ap.get()) 54 { 55 SymbolContext sc; 56 if (m_opaque_ap->GetContextAtIndex (idx, sc)) 57 { 58 sb_sc.SetSymbolContext(&sc); 59 } 60 } 61 return sb_sc; 62 } 63 64 void Clear()65SBSymbolContextList::Clear() 66 { 67 if (m_opaque_ap.get()) 68 m_opaque_ap->Clear(); 69 } 70 71 void Append(SBSymbolContext & sc)72SBSymbolContextList::Append(SBSymbolContext &sc) 73 { 74 if (sc.IsValid() && m_opaque_ap.get()) 75 m_opaque_ap->Append(*sc); 76 } 77 78 void Append(SBSymbolContextList & sc_list)79SBSymbolContextList::Append(SBSymbolContextList &sc_list) 80 { 81 if (sc_list.IsValid() && m_opaque_ap.get()) 82 m_opaque_ap->Append(*sc_list); 83 } 84 85 86 bool IsValid() const87SBSymbolContextList::IsValid () const 88 { 89 return m_opaque_ap.get() != NULL; 90 } 91 92 93 94 lldb_private::SymbolContextList* operator ->() const95SBSymbolContextList::operator->() const 96 { 97 return m_opaque_ap.get(); 98 } 99 100 101 lldb_private::SymbolContextList& operator *() const102SBSymbolContextList::operator*() const 103 { 104 assert (m_opaque_ap.get()); 105 return *m_opaque_ap.get(); 106 } 107 108 bool GetDescription(lldb::SBStream & description)109SBSymbolContextList::GetDescription (lldb::SBStream &description) 110 { 111 Stream &strm = description.ref(); 112 if (m_opaque_ap.get()) 113 m_opaque_ap->GetDescription (&strm, lldb::eDescriptionLevelFull, NULL); 114 return true; 115 } 116 117 118