1 //===-- TypeFormat.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_TypeFormat_h_ 11 #define lldb_TypeFormat_h_ 12 13 // C Includes 14 15 // C++ Includes 16 #include <string> 17 18 // Other libraries and framework includes 19 20 // Project includes 21 #include "lldb/lldb-public.h" 22 #include "lldb/lldb-enumerations.h" 23 24 #include "lldb/Core/ValueObject.h" 25 26 namespace lldb_private { 27 class TypeFormatImpl 28 { 29 public: 30 class Flags 31 { 32 public: 33 Flags()34 Flags () : 35 m_flags (lldb::eTypeOptionCascade) 36 {} 37 Flags(const Flags & other)38 Flags (const Flags& other) : 39 m_flags (other.m_flags) 40 {} 41 Flags(uint32_t value)42 Flags (uint32_t value) : 43 m_flags (value) 44 {} 45 46 Flags& 47 operator = (const Flags& rhs) 48 { 49 if (&rhs != this) 50 m_flags = rhs.m_flags; 51 52 return *this; 53 } 54 55 Flags& 56 operator = (const uint32_t& rhs) 57 { 58 m_flags = rhs; 59 return *this; 60 } 61 62 Flags& Clear()63 Clear() 64 { 65 m_flags = 0; 66 return *this; 67 } 68 69 bool GetCascades()70 GetCascades () const 71 { 72 return (m_flags & lldb::eTypeOptionCascade) == lldb::eTypeOptionCascade; 73 } 74 75 Flags& 76 SetCascades (bool value = true) 77 { 78 if (value) 79 m_flags |= lldb::eTypeOptionCascade; 80 else 81 m_flags &= ~lldb::eTypeOptionCascade; 82 return *this; 83 } 84 85 bool GetSkipPointers()86 GetSkipPointers () const 87 { 88 return (m_flags & lldb::eTypeOptionSkipPointers) == lldb::eTypeOptionSkipPointers; 89 } 90 91 Flags& 92 SetSkipPointers (bool value = true) 93 { 94 if (value) 95 m_flags |= lldb::eTypeOptionSkipPointers; 96 else 97 m_flags &= ~lldb::eTypeOptionSkipPointers; 98 return *this; 99 } 100 101 bool GetSkipReferences()102 GetSkipReferences () const 103 { 104 return (m_flags & lldb::eTypeOptionSkipReferences) == lldb::eTypeOptionSkipReferences; 105 } 106 107 Flags& 108 SetSkipReferences (bool value = true) 109 { 110 if (value) 111 m_flags |= lldb::eTypeOptionSkipReferences; 112 else 113 m_flags &= ~lldb::eTypeOptionSkipReferences; 114 return *this; 115 } 116 117 uint32_t GetValue()118 GetValue () 119 { 120 return m_flags; 121 } 122 123 void SetValue(uint32_t value)124 SetValue (uint32_t value) 125 { 126 m_flags = value; 127 } 128 129 private: 130 uint32_t m_flags; 131 }; 132 133 TypeFormatImpl (lldb::Format f = lldb::eFormatInvalid, 134 const Flags& flags = Flags()); 135 136 typedef std::shared_ptr<TypeFormatImpl> SharedPointer; 137 typedef bool(*ValueCallback)(void*, ConstString, const lldb::TypeFormatImplSP&); 138 ~TypeFormatImpl()139 ~TypeFormatImpl () 140 { 141 } 142 143 bool Cascades()144 Cascades () const 145 { 146 return m_flags.GetCascades(); 147 } 148 bool SkipsPointers()149 SkipsPointers () const 150 { 151 return m_flags.GetSkipPointers(); 152 } 153 bool SkipsReferences()154 SkipsReferences () const 155 { 156 return m_flags.GetSkipReferences(); 157 } 158 159 void SetCascades(bool value)160 SetCascades (bool value) 161 { 162 m_flags.SetCascades(value); 163 } 164 165 void SetSkipsPointers(bool value)166 SetSkipsPointers (bool value) 167 { 168 m_flags.SetSkipPointers(value); 169 } 170 171 void SetSkipsReferences(bool value)172 SetSkipsReferences (bool value) 173 { 174 m_flags.SetSkipReferences(value); 175 } 176 177 lldb::Format GetFormat()178 GetFormat () const 179 { 180 return m_format; 181 } 182 183 void SetFormat(lldb::Format fmt)184 SetFormat (lldb::Format fmt) 185 { 186 m_format = fmt; 187 } 188 189 uint32_t GetOptions()190 GetOptions () 191 { 192 return m_flags.GetValue(); 193 } 194 195 void SetOptions(uint32_t value)196 SetOptions (uint32_t value) 197 { 198 m_flags.SetValue(value); 199 } 200 201 uint32_t& GetRevision()202 GetRevision () 203 { 204 return m_my_revision; 205 } 206 207 std::string 208 GetDescription(); 209 210 protected: 211 Flags m_flags; 212 lldb::Format m_format; 213 uint32_t m_my_revision; 214 215 private: 216 DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl); 217 }; 218 } // namespace lldb_private 219 220 #endif // lldb_TypeFormat_h_ 221