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_
18 #include <unordered_map>
20 // Other libraries and framework includes
23 #include "lldb/lldb-public.h"
24 #include "lldb/lldb-enumerations.h"
26 #include "lldb/Core/ValueObject.h"
28 namespace lldb_private {
37 m_flags (lldb::eTypeOptionCascade)
40 Flags (const Flags& other) :
41 m_flags (other.m_flags)
44 Flags (uint32_t value) :
49 operator = (const Flags& rhs)
52 m_flags = rhs.m_flags;
58 operator = (const uint32_t& rhs)
74 return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
78 SetCascades (bool value = true)
81 m_flags |= lldb::eTypeOptionCascade;
83 m_flags &= ~lldb::eTypeOptionCascade;
88 GetSkipPointers () const
90 return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
94 SetSkipPointers (bool value = true)
97 m_flags |= lldb::eTypeOptionSkipPointers;
99 m_flags &= ~lldb::eTypeOptionSkipPointers;
104 GetSkipReferences () const
106 return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
110 SetSkipReferences (bool value = true)
113 m_flags |= lldb::eTypeOptionSkipReferences;
115 m_flags &= ~lldb::eTypeOptionSkipReferences;
120 GetNonCacheable () const
122 return (m_flags & lldb::eTypeOptionNonCacheable) == lldb::eTypeOptionNonCacheable;
126 SetNonCacheable (bool value = true)
129 m_flags |= lldb::eTypeOptionNonCacheable;
131 m_flags &= ~lldb::eTypeOptionNonCacheable;
142 SetValue (uint32_t value)
151 TypeFormatImpl (const Flags& flags = Flags());
153 typedef std::shared_ptr<TypeFormatImpl> SharedPointer;
155 virtual ~TypeFormatImpl ();
160 return m_flags.GetCascades();
164 SkipsPointers () const
166 return m_flags.GetSkipPointers();
170 SkipsReferences () const
172 return m_flags.GetSkipReferences();
176 NonCacheable () const
178 return m_flags.GetNonCacheable();
182 SetCascades (bool value)
184 m_flags.SetCascades(value);
188 SetSkipsPointers (bool value)
190 m_flags.SetSkipPointers(value);
194 SetSkipsReferences (bool value)
196 m_flags.SetSkipReferences(value);
200 SetNonCacheable (bool value)
202 m_flags.SetNonCacheable(value);
208 return m_flags.GetValue();
212 SetOptions (uint32_t value)
214 m_flags.SetValue(value);
220 return m_my_revision;
233 return Type::eTypeUnknown;
236 // we are using a ValueObject* instead of a ValueObjectSP because we do not need to hold on to this for
237 // extended periods of time and we trust the ValueObject to stay around for as long as it is required
238 // for us to generate its value
240 FormatObject (ValueObject *valobj,
241 std::string& dest) const = 0;
244 GetDescription() = 0;
248 uint32_t m_my_revision;
251 DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl);
254 class TypeFormatImpl_Format : public TypeFormatImpl
257 TypeFormatImpl_Format (lldb::Format f = lldb::eFormatInvalid,
258 const TypeFormatImpl::Flags& flags = Flags());
260 typedef std::shared_ptr<TypeFormatImpl_Format> SharedPointer;
262 ~TypeFormatImpl_Format() override;
271 SetFormat (lldb::Format fmt)
279 return TypeFormatImpl::Type::eTypeFormat;
283 FormatObject(ValueObject *valobj,
284 std::string& dest) const override;
287 GetDescription() override;
290 lldb::Format m_format;
293 DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_Format);
296 class TypeFormatImpl_EnumType : public TypeFormatImpl
299 TypeFormatImpl_EnumType (ConstString type_name = ConstString(""),
300 const TypeFormatImpl::Flags& flags = Flags());
302 typedef std::shared_ptr<TypeFormatImpl_EnumType> SharedPointer;
304 ~TypeFormatImpl_EnumType() override;
313 SetTypeName (ConstString enum_type)
315 m_enum_type = enum_type;
321 return TypeFormatImpl::Type::eTypeEnum;
325 FormatObject(ValueObject *valobj,
326 std::string& dest) const override;
329 GetDescription() override;
332 ConstString m_enum_type;
333 mutable std::unordered_map<void*,CompilerType> m_types;
336 DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_EnumType);
338 } // namespace lldb_private
340 #endif // lldb_TypeFormat_h_