LLDB mainline
SBTypeNameSpecifier.cpp
Go to the documentation of this file.
1//===-- SBTypeNameSpecifier.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#include "lldb/API/SBType.h"
14
16
17using namespace lldb;
18using namespace lldb_private;
19
21
22SBTypeNameSpecifier::SBTypeNameSpecifier(const char *name, bool is_regex)
25 LLDB_INSTRUMENT_VA(this, name, is_regex);
26}
27
29 FormatterMatchType match_type)
30 : m_opaque_sp(new TypeNameSpecifierImpl(name, match_type)) {
31 LLDB_INSTRUMENT_VA(this, name, match_type);
32
33 if (name == nullptr || (*name) == 0)
34 m_opaque_sp.reset();
35}
36
38 LLDB_INSTRUMENT_VA(this, type);
39
40 if (type.IsValid())
42 new TypeNameSpecifierImpl(type.m_opaque_sp->GetCompilerType(true)));
43}
44
46 : m_opaque_sp(rhs.m_opaque_sp) {
47 LLDB_INSTRUMENT_VA(this, rhs);
48}
49
51
54 return this->operator bool();
55}
56SBTypeNameSpecifier::operator bool() const {
58
59 return m_opaque_sp.get() != nullptr;
60}
61
64
65 if (!IsValid())
66 return nullptr;
67
68 return ConstString(m_opaque_sp->GetName()).GetCString();
69}
70
73
74 if (!IsValid())
75 return SBType();
76 lldb_private::CompilerType c_type = m_opaque_sp->GetCompilerType();
77 if (c_type.IsValid())
78 return SBType(c_type);
79 return SBType();
80}
81
84 if (!IsValid())
86 return m_opaque_sp->GetMatchType();
87}
88
91
92 if (!IsValid())
93 return false;
94
95 return m_opaque_sp->GetMatchType() == eFormatterMatchRegex;
96}
97
99 lldb::SBStream &description, lldb::DescriptionLevel description_level) {
100 LLDB_INSTRUMENT_VA(this, description, description_level);
101
103 const char *match_type_str =
104 (match_type == eFormatterMatchExact ? "plain"
105 : match_type == eFormatterMatchRegex ? "regex"
106 : "callback");
107 if (!IsValid())
108 return false;
109 description.Printf("SBTypeNameSpecifier(%s,%s)", GetName(), match_type_str);
110 return true;
111}
112
115 LLDB_INSTRUMENT_VA(this, rhs);
116
117 if (this != &rhs) {
119 }
120 return *this;
121}
122
124 LLDB_INSTRUMENT_VA(this, rhs);
125
126 if (!IsValid())
127 return !rhs.IsValid();
128 return m_opaque_sp == rhs.m_opaque_sp;
129}
130
132 LLDB_INSTRUMENT_VA(this, rhs);
133
134 if (!IsValid())
135 return !rhs.IsValid();
136
137 if (GetMatchType() != rhs.GetMatchType())
138 return false;
139 if (GetName() == nullptr || rhs.GetName() == nullptr)
140 return false;
141
142 return (strcmp(GetName(), rhs.GetName()) == 0);
143}
144
146 LLDB_INSTRUMENT_VA(this, rhs);
147
148 if (!IsValid())
149 return !rhs.IsValid();
150 return m_opaque_sp != rhs.m_opaque_sp;
151}
152
154 return m_opaque_sp;
155}
156
158 const lldb::TypeNameSpecifierImplSP &type_namespec_sp) {
159 m_opaque_sp = type_namespec_sp;
160}
161
163 const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
164 : m_opaque_sp(type_namespec_sp) {}
#define LLDB_INSTRUMENT_VA(...)
void SetSP(const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
bool operator==(lldb::SBTypeNameSpecifier &rhs)
lldb::TypeNameSpecifierImplSP GetSP()
bool IsEqualTo(lldb::SBTypeNameSpecifier &rhs)
lldb::TypeNameSpecifierImplSP m_opaque_sp
lldb::FormatterMatchType GetMatchType()
bool GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level)
lldb::SBTypeNameSpecifier & operator=(const lldb::SBTypeNameSpecifier &rhs)
bool operator!=(lldb::SBTypeNameSpecifier &rhs)
lldb::TypeImplSP m_opaque_sp
Definition: SBType.h:268
bool IsValid() const
Definition: SBType.cpp:113
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
A uniqued constant string class.
Definition: ConstString.h:40
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
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::TypeNameSpecifierImpl > TypeNameSpecifierImplSP
Definition: lldb-forward.h:474
FormatterMatchType
Type of match to be performed when looking for a formatter for a data type.
@ eFormatterMatchExact
@ eFormatterMatchRegex