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;
119 GetNonCacheable () const
121 return (m_flags & lldb::eTypeOptionNonCacheable) == lldb::eTypeOptionNonCacheable;
125 SetNonCacheable (bool value = true)
128 m_flags |= lldb::eTypeOptionNonCacheable;
130 m_flags &= ~lldb::eTypeOptionNonCacheable;
141 SetValue (uint32_t value)
150 TypeFormatImpl (const Flags& flags = Flags());
152 typedef std::shared_ptr<TypeFormatImpl> SharedPointer;
153 typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeFormatImplSP&);
155 virtual ~TypeFormatImpl ();
160 return m_flags.GetCascades();
163 SkipsPointers () const
165 return m_flags.GetSkipPointers();
168 SkipsReferences () const
170 return m_flags.GetSkipReferences();
173 NonCacheable () const
175 return m_flags.GetNonCacheable();
179 SetCascades (bool value)
181 m_flags.SetCascades(value);
185 SetSkipsPointers (bool value)
187 m_flags.SetSkipPointers(value);
191 SetSkipsReferences (bool value)
193 m_flags.SetSkipReferences(value);
197 SetNonCacheable (bool value)
199 m_flags.SetNonCacheable(value);
205 return m_flags.GetValue();
209 SetOptions (uint32_t value)
211 m_flags.SetValue(value);
217 return m_my_revision;
230 return Type::eTypeUnknown;
233 // we are using a ValueObject* instead of a ValueObjectSP because we do not need to hold on to this for
234 // extended periods of time and we trust the ValueObject to stay around for as long as it is required
235 // for us to generate its value
237 FormatObject (ValueObject *valobj,
238 std::string& dest) const = 0;
241 GetDescription() = 0;
245 uint32_t m_my_revision;
248 DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl);
251 class TypeFormatImpl_Format : public TypeFormatImpl
254 TypeFormatImpl_Format (lldb::Format f = lldb::eFormatInvalid,
255 const TypeFormatImpl::Flags& flags = Flags());
257 typedef std::shared_ptr<TypeFormatImpl_Format> SharedPointer;
258 typedef bool(*ValueCallback)(void*, ConstString, const TypeFormatImpl_Format::SharedPointer&);
260 virtual ~TypeFormatImpl_Format ();
269 SetFormat (lldb::Format fmt)
274 virtual TypeFormatImpl::Type
277 return TypeFormatImpl::Type::eTypeFormat;
281 FormatObject (ValueObject *valobj,
282 std::string& dest) const;
288 lldb::Format m_format;
291 DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_Format);
294 class TypeFormatImpl_EnumType : public TypeFormatImpl
297 TypeFormatImpl_EnumType (ConstString type_name = ConstString(""),
298 const TypeFormatImpl::Flags& flags = Flags());
300 typedef std::shared_ptr<TypeFormatImpl_EnumType> SharedPointer;
301 typedef bool(*ValueCallback)(void*, ConstString, const TypeFormatImpl_EnumType::SharedPointer&);
303 ~TypeFormatImpl_EnumType ();
312 SetTypeName (ConstString enum_type)
314 m_enum_type = enum_type;
317 virtual TypeFormatImpl::Type
320 return TypeFormatImpl::Type::eTypeEnum;
324 FormatObject (ValueObject *valobj,
325 std::string& dest) const;
331 ConstString m_enum_type;
332 mutable std::unordered_map<void*,ClangASTType> m_types;
335 DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_EnumType);
337 } // namespace lldb_private
339 #endif // lldb_TypeFormat_h_