]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/llvm/tools/lldb/include/lldb/DataFormatters/FormatClasses.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / llvm / tools / lldb / include / lldb / DataFormatters / FormatClasses.h
1 //===-- FormatClasses.h -----------------------------------------*- 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 #ifndef lldb_FormatClasses_h_
11 #define lldb_FormatClasses_h_
12
13 // C Includes
14 #include <stdint.h>
15 #include <unistd.h>
16
17 // C++ Includes
18 #include <string>
19 #include <vector>
20
21 // Other libraries and framework includes
22
23 // Project includes
24 #include "lldb/lldb-public.h"
25 #include "lldb/lldb-enumerations.h"
26
27 #include "lldb/Core/ValueObject.h"
28 #include "lldb/Interpreter/ScriptInterpreterPython.h"
29 #include "lldb/Symbol/ClangASTType.h"
30 #include "lldb/Symbol/Type.h"
31
32 #include "lldb/DataFormatters/TypeFormat.h"
33 #include "lldb/DataFormatters/TypeSummary.h"
34 #include "lldb/DataFormatters/TypeSynthetic.h"
35
36 namespace lldb_private {
37
38 class TypeNameSpecifierImpl
39 {
40 public:
41     TypeNameSpecifierImpl() :
42     m_is_regex(false),
43     m_type()
44     {
45     }
46     
47     TypeNameSpecifierImpl (const char* name, bool is_regex) :
48     m_is_regex(is_regex),
49     m_type()
50     {
51         if (name)
52             m_type.m_type_name.assign(name);
53     }
54     
55     // if constructing with a given type, is_regex cannot be true since we are
56     // giving an exact type to match
57     TypeNameSpecifierImpl (lldb::TypeSP type) :
58     m_is_regex(false),
59     m_type()
60     {
61         if (type)
62         {
63             m_type.m_type_name.assign(type->GetName().GetCString());
64             m_type.m_typeimpl_sp = lldb::TypeImplSP(new TypeImpl(type));
65         }
66     }
67
68     TypeNameSpecifierImpl (ClangASTType type) :
69     m_is_regex(false),
70     m_type()
71     {
72         if (type.IsValid())
73         {
74             m_type.m_type_name.assign(type.GetConstTypeName().GetCString());
75             m_type.m_typeimpl_sp = lldb::TypeImplSP(new TypeImpl(type));
76         }
77     }
78     
79     const char*
80     GetName()
81     {
82         if (m_type.m_type_name.size())
83             return m_type.m_type_name.c_str();
84         return NULL;
85     }
86     
87     lldb::TypeSP
88     GetTypeSP ()
89     {
90         if (m_type.m_typeimpl_sp && m_type.m_typeimpl_sp->IsValid())
91             return m_type.m_typeimpl_sp->GetTypeSP();
92         return lldb::TypeSP();
93     }
94     
95     ClangASTType
96     GetClangASTType ()
97     {
98         if (m_type.m_typeimpl_sp && m_type.m_typeimpl_sp->IsValid())
99             return m_type.m_typeimpl_sp->GetClangASTType();
100         return ClangASTType();
101     }
102     
103     bool
104     IsRegex()
105     {
106         return m_is_regex;
107     }
108     
109 private:
110     bool m_is_regex;
111     // this works better than TypeAndOrName because the latter only wraps a TypeSP
112     // whereas TypeImplSP can also be backed by a ClangASTType which is more commonly
113     // used in LLDB. moreover, TypeImplSP is also what is currently backing SBType
114     struct TypeOrName
115     {
116         std::string m_type_name;
117         lldb::TypeImplSP m_typeimpl_sp;
118     };
119     TypeOrName m_type;
120     
121     
122 private:
123     DISALLOW_COPY_AND_ASSIGN(TypeNameSpecifierImpl);
124 };
125     
126 } // namespace lldb_private
127
128 #endif  // lldb_FormatClasses_h_