1 //===-- SBSymbolContextList.cpp ---------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "lldb/API/SBSymbolContextList.h" 10 #include "Utils.h" 11 #include "lldb/API/SBStream.h" 12 #include "lldb/Symbol/SymbolContext.h" 13 14 using namespace lldb; 15 using namespace lldb_private; 16 17 SBSymbolContextList::SBSymbolContextList() 18 : m_opaque_up(new SymbolContextList()) {} 19 20 SBSymbolContextList::SBSymbolContextList(const SBSymbolContextList &rhs) 21 : m_opaque_up() { 22 23 m_opaque_up = clone(rhs.m_opaque_up); 24 } 25 26 SBSymbolContextList::~SBSymbolContextList() {} 27 28 const SBSymbolContextList &SBSymbolContextList:: 29 operator=(const SBSymbolContextList &rhs) { 30 if (this != &rhs) 31 m_opaque_up = clone(rhs.m_opaque_up); 32 return *this; 33 } 34 35 uint32_t SBSymbolContextList::GetSize() const { 36 if (m_opaque_up) 37 return m_opaque_up->GetSize(); 38 return 0; 39 } 40 41 SBSymbolContext SBSymbolContextList::GetContextAtIndex(uint32_t idx) { 42 SBSymbolContext sb_sc; 43 if (m_opaque_up) { 44 SymbolContext sc; 45 if (m_opaque_up->GetContextAtIndex(idx, sc)) { 46 sb_sc.SetSymbolContext(&sc); 47 } 48 } 49 return sb_sc; 50 } 51 52 void SBSymbolContextList::Clear() { 53 if (m_opaque_up) 54 m_opaque_up->Clear(); 55 } 56 57 void SBSymbolContextList::Append(SBSymbolContext &sc) { 58 if (sc.IsValid() && m_opaque_up.get()) 59 m_opaque_up->Append(*sc); 60 } 61 62 void SBSymbolContextList::Append(SBSymbolContextList &sc_list) { 63 if (sc_list.IsValid() && m_opaque_up.get()) 64 m_opaque_up->Append(*sc_list); 65 } 66 67 bool SBSymbolContextList::IsValid() const { return m_opaque_up != NULL; } 68 69 lldb_private::SymbolContextList *SBSymbolContextList::operator->() const { 70 return m_opaque_up.get(); 71 } 72 73 lldb_private::SymbolContextList &SBSymbolContextList::operator*() const { 74 assert(m_opaque_up.get()); 75 return *m_opaque_up; 76 } 77 78 bool SBSymbolContextList::GetDescription(lldb::SBStream &description) { 79 Stream &strm = description.ref(); 80 if (m_opaque_up) 81 m_opaque_up->GetDescription(&strm, lldb::eDescriptionLevelFull, NULL); 82 return true; 83 } 84