LLDB mainline
SBTypeFormat.cpp
Go to the documentation of this file.
1//===-- SBTypeFormat.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
11
12#include "lldb/API/SBStream.h"
13
15
16using namespace lldb;
17using namespace lldb_private;
18
20
22 : m_opaque_sp(
23 TypeFormatImplSP(new TypeFormatImpl_Format(format, options))) {
24 LLDB_INSTRUMENT_VA(this, format, options);
25}
26
27SBTypeFormat::SBTypeFormat(const char *type, uint32_t options)
29 ConstString(type ? type : ""), options))) {
30 LLDB_INSTRUMENT_VA(this, type, options);
31}
32
34 : m_opaque_sp(rhs.m_opaque_sp) {
35 LLDB_INSTRUMENT_VA(this, rhs);
36}
37
39
42 return this->operator bool();
43}
44SBTypeFormat::operator bool() const {
46
47 return m_opaque_sp.get() != nullptr;
48}
49
52
53 if (IsValid() && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeFormat)
54 return ((TypeFormatImpl_Format *)m_opaque_sp.get())->GetFormat();
56}
57
60
61 if (IsValid() && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeEnum)
62 return ((TypeFormatImpl_EnumType *)m_opaque_sp.get())
63 ->GetTypeName()
64 .AsCString("");
65 return "";
66}
67
70
71 if (IsValid())
72 return m_opaque_sp->GetOptions();
73 return 0;
74}
75
77 LLDB_INSTRUMENT_VA(this, fmt);
78
81}
82
83void SBTypeFormat::SetTypeName(const char *type) {
84 LLDB_INSTRUMENT_VA(this, type);
85
88 ->SetTypeName(ConstString(type ? type : ""));
89}
90
91void SBTypeFormat::SetOptions(uint32_t value) {
92 LLDB_INSTRUMENT_VA(this, value);
93
95 m_opaque_sp->SetOptions(value);
96}
97
99 lldb::DescriptionLevel description_level) {
100 LLDB_INSTRUMENT_VA(this, description, description_level);
101
102 if (!IsValid())
103 return false;
104 else {
105 description.Printf("%s\n", m_opaque_sp->GetDescription().c_str());
106 return true;
107 }
108}
109
111 LLDB_INSTRUMENT_VA(this, rhs);
112
113 if (this != &rhs) {
115 }
116 return *this;
117}
118
120 LLDB_INSTRUMENT_VA(this, rhs);
121
122 if (!IsValid())
123 return !rhs.IsValid();
124 return m_opaque_sp == rhs.m_opaque_sp;
125}
126
128 LLDB_INSTRUMENT_VA(this, rhs);
129
130 if (!IsValid())
131 return !rhs.IsValid();
132
133 if (GetFormat() == rhs.GetFormat())
134 return GetOptions() == rhs.GetOptions();
135 else
136 return false;
137}
138
140 LLDB_INSTRUMENT_VA(this, rhs);
141
142 if (!IsValid())
143 return !rhs.IsValid();
144 return m_opaque_sp != rhs.m_opaque_sp;
145}
146
148
149void SBTypeFormat::SetSP(const lldb::TypeFormatImplSP &typeformat_impl_sp) {
150 m_opaque_sp = typeformat_impl_sp;
151}
152
154 : m_opaque_sp(typeformat_impl_sp) {}
155
157 if (!IsValid())
158 return false;
159
160 if (m_opaque_sp.use_count() == 1 &&
161 ((type == Type::eTypeKeepSame) ||
162 (type == Type::eTypeFormat &&
163 m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeFormat) ||
164 (type == Type::eTypeEnum &&
165 m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeEnum)))
166 return true;
167
168 if (type == Type::eTypeKeepSame) {
169 if (m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeFormat)
170 type = Type::eTypeFormat;
171 else
172 type = Type::eTypeEnum;
173 }
174
175 if (type == Type::eTypeFormat)
176 SetSP(
178 else
181
182 return true;
183}
#define LLDB_INSTRUMENT_VA(...)
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
bool operator!=(lldb::SBTypeFormat &rhs)
void SetSP(const lldb::TypeFormatImplSP &typeformat_impl_sp)
const char * GetTypeName()
lldb::SBTypeFormat & operator=(const lldb::SBTypeFormat &rhs)
bool CopyOnWrite_Impl(Type)
void SetOptions(uint32_t)
lldb::TypeFormatImplSP m_opaque_sp
Definition: SBTypeFormat.h:67
bool IsValid() const
lldb::Format GetFormat()
lldb::TypeFormatImplSP GetSP()
void SetFormat(lldb::Format)
uint32_t GetOptions()
void SetTypeName(const char *)
bool IsEqualTo(lldb::SBTypeFormat &rhs)
bool operator==(lldb::SBTypeFormat &rhs)
A uniqued constant string class.
Definition: ConstString.h:40
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
std::shared_ptr< lldb_private::TypeFormatImpl > TypeFormatImplSP
Definition: lldb-forward.h:467
Format
Display format definitions.