Greg Clayton | 466f6c4 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 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" |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 11 | #include "lldb/API/SBStream.h" |
Greg Clayton | 466f6c4 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 12 | #include "lldb/Symbol/SymbolContext.h" |
| 13 | |
| 14 | using namespace lldb; |
| 15 | using namespace lldb_private; |
| 16 | |
| 17 | SBSymbolContextList::SBSymbolContextList () : |
Greg Clayton | 4ed315f | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 18 | m_opaque_ap (new SymbolContextList()) |
Greg Clayton | 466f6c4 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 19 | { |
| 20 | } |
| 21 | |
| 22 | SBSymbolContextList::SBSymbolContextList (const SBSymbolContextList& rhs) : |
Greg Clayton | 4ed315f | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 23 | m_opaque_ap (new SymbolContextList(*rhs.m_opaque_ap)) |
Greg Clayton | 466f6c4 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 24 | { |
Greg Clayton | 466f6c4 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | SBSymbolContextList::~SBSymbolContextList () |
| 28 | { |
| 29 | } |
| 30 | |
| 31 | const SBSymbolContextList & |
| 32 | SBSymbolContextList::operator = (const SBSymbolContextList &rhs) |
| 33 | { |
| 34 | if (this != &rhs) |
| 35 | { |
Greg Clayton | 4ed315f | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 36 | *m_opaque_ap = *rhs.m_opaque_ap; |
Greg Clayton | 466f6c4 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 37 | } |
| 38 | return *this; |
| 39 | } |
| 40 | |
| 41 | uint32_t |
| 42 | SBSymbolContextList::GetSize() const |
| 43 | { |
| 44 | if (m_opaque_ap.get()) |
| 45 | return m_opaque_ap->GetSize(); |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | SBSymbolContext |
| 50 | SBSymbolContextList::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 | |
Greg Clayton | 4ed315f | 2011-06-21 01:34:41 +0000 | [diff] [blame] | 64 | void |
| 65 | SBSymbolContextList::Clear() |
| 66 | { |
| 67 | if (m_opaque_ap.get()) |
| 68 | m_opaque_ap->Clear(); |
| 69 | } |
| 70 | |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 71 | void |
| 72 | SBSymbolContextList::Append(SBSymbolContext &sc) |
| 73 | { |
| 74 | if (sc.IsValid() && m_opaque_ap.get()) |
| 75 | m_opaque_ap->Append(*sc); |
| 76 | } |
| 77 | |
| 78 | void |
| 79 | SBSymbolContextList::Append(SBSymbolContextList &sc_list) |
| 80 | { |
| 81 | if (sc_list.IsValid() && m_opaque_ap.get()) |
| 82 | m_opaque_ap->Append(*sc_list); |
| 83 | } |
| 84 | |
Greg Clayton | 466f6c4 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 85 | |
| 86 | bool |
| 87 | SBSymbolContextList::IsValid () const |
| 88 | { |
| 89 | return m_opaque_ap.get() != NULL; |
| 90 | } |
| 91 | |
| 92 | |
| 93 | |
| 94 | lldb_private::SymbolContextList* |
| 95 | SBSymbolContextList::operator->() const |
| 96 | { |
| 97 | return m_opaque_ap.get(); |
| 98 | } |
| 99 | |
| 100 | |
| 101 | lldb_private::SymbolContextList& |
| 102 | SBSymbolContextList::operator*() const |
| 103 | { |
| 104 | assert (m_opaque_ap.get()); |
| 105 | return *m_opaque_ap.get(); |
| 106 | } |
| 107 | |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 108 | bool |
| 109 | SBSymbolContextList::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 | } |
Greg Clayton | 466f6c4 | 2010-09-10 18:31:35 +0000 | [diff] [blame] | 116 | |
| 117 | |