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

source code of lldb/source/API/SBSymbolContextList.cpp