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 // Other libraries and framework includes
21 #include "lldb/lldb-public.h"
22 #include "lldb/lldb-enumerations.h"
24 #include "lldb/Core/ValueObject.h"
26 namespace lldb_private {
35 m_flags (lldb::eTypeOptionCascade)
38 Flags (const Flags& other) :
39 m_flags (other.m_flags)
42 Flags (uint32_t value) :
47 operator = (const Flags& rhs)
50 m_flags = rhs.m_flags;
56 operator = (const uint32_t& rhs)
72 return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade;
76 SetCascades (bool value = true)
79 m_flags |= lldb::eTypeOptionCascade;
81 m_flags &= ~lldb::eTypeOptionCascade;
86 GetSkipPointers () const
88 return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers;
92 SetSkipPointers (bool value = true)
95 m_flags |= lldb::eTypeOptionSkipPointers;
97 m_flags &= ~lldb::eTypeOptionSkipPointers;
102 GetSkipReferences () const
104 return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences;
108 SetSkipReferences (bool value = true)
111 m_flags |= lldb::eTypeOptionSkipReferences;
113 m_flags &= ~lldb::eTypeOptionSkipReferences;
124 SetValue (uint32_t value)
133 TypeFormatImpl (const Flags& flags = Flags());
135 typedef std::shared_ptr<TypeFormatImpl> SharedPointer;
136 typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeFormatImplSP&);
138 virtual ~TypeFormatImpl () = default;
143 return m_flags.GetCascades();
146 SkipsPointers () const
148 return m_flags.GetSkipPointers();
151 SkipsReferences () const
153 return m_flags.GetSkipReferences();
157 SetCascades (bool value)
159 m_flags.SetCascades(value);
163 SetSkipsPointers (bool value)
165 m_flags.SetSkipPointers(value);
169 SetSkipsReferences (bool value)
171 m_flags.SetSkipReferences(value);
177 return m_flags.GetValue();
181 SetOptions (uint32_t value)
183 m_flags.SetValue(value);
189 return m_my_revision;
202 return Type::eTypeUnknown;
205 // we are using a ValueObject* instead of a ValueObjectSP because we do not need to hold on to this for
206 // extended periods of time and we trust the ValueObject to stay around for as long as it is required
207 // for us to generate its value
209 FormatObject (ValueObject *valobj,
210 std::string& dest) const = 0;
213 GetDescription() = 0;
217 uint32_t m_my_revision;
220 DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl);
223 class TypeFormatImpl_Format : public TypeFormatImpl
226 TypeFormatImpl_Format (lldb::Format f = lldb::eFormatInvalid,
227 const TypeFormatImpl::Flags& flags = Flags());
229 typedef std::shared_ptr<TypeFormatImpl_Format> SharedPointer;
230 typedef bool(*ValueCallback)(void*, ConstString, const TypeFormatImpl_Format::SharedPointer&);
232 virtual ~TypeFormatImpl_Format () = default;
241 SetFormat (lldb::Format fmt)
246 virtual TypeFormatImpl::Type
249 return TypeFormatImpl::Type::eTypeFormat;
253 FormatObject (ValueObject *valobj,
254 std::string& dest) const;
260 lldb::Format m_format;
263 DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_Format);
266 class TypeFormatImpl_EnumType : public TypeFormatImpl
269 TypeFormatImpl_EnumType (ConstString type_name = ConstString(""),
270 const TypeFormatImpl::Flags& flags = Flags());
272 typedef std::shared_ptr<TypeFormatImpl_EnumType> SharedPointer;
273 typedef bool(*ValueCallback)(void*, ConstString, const TypeFormatImpl_EnumType::SharedPointer&);
275 ~TypeFormatImpl_EnumType () = default;
284 SetTypeName (ConstString enum_type)
286 m_enum_type = enum_type;
289 virtual TypeFormatImpl::Type
292 return TypeFormatImpl::Type::eTypeEnum;
296 FormatObject (ValueObject *valobj,
297 std::string& dest) const;
303 ConstString m_enum_type;
304 mutable std::map<void*,ClangASTType> m_types;
307 DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_EnumType);
309 } // namespace lldb_private
311 #endif // lldb_TypeFormat_h_