1 //===-- SBTypeNameSpecifier.cpp ------------------------------------*- C++
4 // The LLVM Compiler Infrastructure
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #include "lldb/API/SBTypeNameSpecifier.h"
13 #include "lldb/API/SBStream.h"
14 #include "lldb/API/SBType.h"
16 #include "lldb/DataFormatters/DataVisualization.h"
19 using namespace lldb_private;
21 SBTypeNameSpecifier::SBTypeNameSpecifier() : m_opaque_sp() {}
23 SBTypeNameSpecifier::SBTypeNameSpecifier(const char *name, bool is_regex)
24 : m_opaque_sp(new TypeNameSpecifierImpl(name, is_regex)) {
25 if (name == NULL || (*name) == 0)
29 SBTypeNameSpecifier::SBTypeNameSpecifier(SBType type) : m_opaque_sp() {
31 m_opaque_sp = TypeNameSpecifierImplSP(
32 new TypeNameSpecifierImpl(type.m_opaque_sp->GetCompilerType(true)));
35 SBTypeNameSpecifier::SBTypeNameSpecifier(const lldb::SBTypeNameSpecifier &rhs)
36 : m_opaque_sp(rhs.m_opaque_sp) {}
38 SBTypeNameSpecifier::~SBTypeNameSpecifier() {}
40 bool SBTypeNameSpecifier::IsValid() const { return m_opaque_sp.get() != NULL; }
42 const char *SBTypeNameSpecifier::GetName() {
46 return m_opaque_sp->GetName();
49 SBType SBTypeNameSpecifier::GetType() {
52 lldb_private::CompilerType c_type = m_opaque_sp->GetCompilerType();
54 return SBType(c_type);
58 bool SBTypeNameSpecifier::IsRegex() {
62 return m_opaque_sp->IsRegex();
65 bool SBTypeNameSpecifier::GetDescription(
66 lldb::SBStream &description, lldb::DescriptionLevel description_level) {
69 description.Printf("SBTypeNameSpecifier(%s,%s)", GetName(),
70 IsRegex() ? "regex" : "plain");
74 lldb::SBTypeNameSpecifier &SBTypeNameSpecifier::
75 operator=(const lldb::SBTypeNameSpecifier &rhs) {
77 m_opaque_sp = rhs.m_opaque_sp;
82 bool SBTypeNameSpecifier::operator==(lldb::SBTypeNameSpecifier &rhs) {
84 return !rhs.IsValid();
85 return m_opaque_sp == rhs.m_opaque_sp;
88 bool SBTypeNameSpecifier::IsEqualTo(lldb::SBTypeNameSpecifier &rhs) {
90 return !rhs.IsValid();
92 if (IsRegex() != rhs.IsRegex())
94 if (GetName() == NULL || rhs.GetName() == NULL)
97 return (strcmp(GetName(), rhs.GetName()) == 0);
100 bool SBTypeNameSpecifier::operator!=(lldb::SBTypeNameSpecifier &rhs) {
102 return !rhs.IsValid();
103 return m_opaque_sp != rhs.m_opaque_sp;
106 lldb::TypeNameSpecifierImplSP SBTypeNameSpecifier::GetSP() {
110 void SBTypeNameSpecifier::SetSP(
111 const lldb::TypeNameSpecifierImplSP &type_namespec_sp) {
112 m_opaque_sp = type_namespec_sp;
115 SBTypeNameSpecifier::SBTypeNameSpecifier(
116 const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
117 : m_opaque_sp(type_namespec_sp) {}