1 //===-- TypeFormat.h ----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef lldb_TypeFormat_h_
11 #define lldb_TypeFormat_h_
17 #include <unordered_map>
19 // Other libraries and framework includes
22 #include "lldb/lldb-public.h"
23 #include "lldb/lldb-enumerations.h"
25 #include "lldb/Core/ValueObject.h"
27 namespace lldb_private {
36 m_flags (lldb::eTypeOptionCascade)
39 Flags (const Flags& other) :
40 m_flags (other.m_flags)
43 Flags (uint32_t value) :
48 operator = (const Flags& rhs)
51 m_flags = rhs.m_flags;
57 operator = (const uint32_t& rhs)
73 return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
77 SetCascades (bool value = true)
80 m_flags |= lldb::eTypeOptionCascade;
82 m_flags &= ~lldb::eTypeOptionCascade;
87 GetSkipPointers () const
89 return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
93 SetSkipPointers (bool value = true)
96 m_flags |= lldb::eTypeOptionSkipPointers;
98 m_flags &= ~lldb::eTypeOptionSkipPointers;
103 GetSkipReferences () const
105 return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
109 SetSkipReferences (bool value = true)
112 m_flags |= lldb::eTypeOptionSkipReferences;
114 m_flags &= ~lldb::eTypeOptionSkipReferences;
125 SetValue (uint32_t value)
134 TypeFormatImpl (const Flags& flags = Flags());
136 typedef std::shared_ptr<TypeFormatImpl> SharedPointer;
137 typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeFormatImplSP&);
139 virtual ~TypeFormatImpl ();
144 return m_flags.GetCascades();
147 SkipsPointers () const
149 return m_flags.GetSkipPointers();
152 SkipsReferences () const
154 return m_flags.GetSkipReferences();
158 SetCascades (bool value)
160 m_flags.SetCascades(value);
164 SetSkipsPointers (bool value)
166 m_flags.SetSkipPointers(value);
170 SetSkipsReferences (bool value)
172 m_flags.SetSkipReferences(value);
178 return m_flags.GetValue();
182 SetOptions (uint32_t value)
184 m_flags.SetValue(value);
190 return m_my_revision;
203 return Type::eTypeUnknown;
206 // we are using a ValueObject* instead of a ValueObjectSP because we do not need to hold on to this for
207 // extended periods of time and we trust the ValueObject to stay around for as long as it is required
208 // for us to generate its value
210 FormatObject (ValueObject *valobj,
211 std::string& dest) const = 0;
214 GetDescription() = 0;
218 uint32_t m_my_revision;
221 DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl);
224 class TypeFormatImpl_Format : public TypeFormatImpl
227 TypeFormatImpl_Format (lldb::Format f = lldb::eFormatInvalid,
228 const TypeFormatImpl::Flags& flags = Flags());
230 typedef std::shared_ptr<TypeFormatImpl_Format> SharedPointer;
231 typedef bool(*ValueCallback)(void*, ConstString, const TypeFormatImpl_Format::SharedPointer&);
233 virtual ~TypeFormatImpl_Format ();
242 SetFormat (lldb::Format fmt)
247 virtual TypeFormatImpl::Type
250 return TypeFormatImpl::Type::eTypeFormat;
254 FormatObject (ValueObject *valobj,
255 std::string& dest) const;
261 lldb::Format m_format;
264 DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_Format);
267 class TypeFormatImpl_EnumType : public TypeFormatImpl
270 TypeFormatImpl_EnumType (ConstString type_name = ConstString(""),
271 const TypeFormatImpl::Flags& flags = Flags());
273 typedef std::shared_ptr<TypeFormatImpl_EnumType> SharedPointer;
274 typedef bool(*ValueCallback)(void*, ConstString, const TypeFormatImpl_EnumType::SharedPointer&);
276 ~TypeFormatImpl_EnumType ();
285 SetTypeName (ConstString enum_type)
287 m_enum_type = enum_type;
290 virtual TypeFormatImpl::Type
293 return TypeFormatImpl::Type::eTypeEnum;
297 FormatObject (ValueObject *valobj,
298 std::string& dest) const;
304 ConstString m_enum_type;
305 mutable std::unordered_map<void*,ClangASTType> m_types;
308 DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_EnumType);
310 } // namespace lldb_private
312 #endif // lldb_TypeFormat_h_