1 //===-- OptionValueUInt64.h --------------------------------------*- C++ 2 //-*-===// 3 // 4 // The LLVM Compiler Infrastructure 5 // 6 // This file is distributed under the University of Illinois Open Source 7 // License. See LICENSE.TXT for details. 8 // 9 //===----------------------------------------------------------------------===// 10 11 #ifndef liblldb_OptionValueUInt64_h_ 12 #define liblldb_OptionValueUInt64_h_ 13 14 #include "lldb/Interpreter/OptionValue.h" 15 16 namespace lldb_private { 17 18 class OptionValueUInt64 : public OptionValue { 19 public: OptionValueUInt64()20 OptionValueUInt64() : OptionValue(), m_current_value(0), m_default_value(0) {} 21 OptionValueUInt64(uint64_t value)22 OptionValueUInt64(uint64_t value) 23 : OptionValue(), m_current_value(value), m_default_value(value) {} 24 OptionValueUInt64(uint64_t current_value,uint64_t default_value)25 OptionValueUInt64(uint64_t current_value, uint64_t default_value) 26 : OptionValue(), m_current_value(current_value), 27 m_default_value(default_value) {} 28 ~OptionValueUInt64()29 ~OptionValueUInt64() override {} 30 31 //--------------------------------------------------------------------- 32 // Decode a uint64_t from "value_cstr" return a OptionValueUInt64 object 33 // inside of a lldb::OptionValueSP object if all goes well. If the string 34 // isn't a uint64_t value or any other error occurs, return an empty 35 // lldb::OptionValueSP and fill error in with the correct stuff. 36 //--------------------------------------------------------------------- 37 static lldb::OptionValueSP Create(const char *, Status &) = delete; 38 static lldb::OptionValueSP Create(llvm::StringRef value_str, Status &error); 39 //--------------------------------------------------------------------- 40 // Virtual subclass pure virtual overrides 41 //--------------------------------------------------------------------- 42 GetType()43 OptionValue::Type GetType() const override { return eTypeUInt64; } 44 45 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, 46 uint32_t dump_mask) override; 47 48 Status 49 SetValueFromString(llvm::StringRef value, 50 VarSetOperationType op = eVarSetOperationAssign) override; 51 Status 52 SetValueFromString(const char *, 53 VarSetOperationType = eVarSetOperationAssign) = delete; 54 Clear()55 bool Clear() override { 56 m_current_value = m_default_value; 57 m_value_was_set = false; 58 return true; 59 } 60 61 lldb::OptionValueSP DeepCopy() const override; 62 63 //--------------------------------------------------------------------- 64 // Subclass specific functions 65 //--------------------------------------------------------------------- 66 67 const uint64_t &operator=(uint64_t value) { 68 m_current_value = value; 69 return m_current_value; 70 } 71 uint64_t()72 operator uint64_t() const { return m_current_value; } 73 GetCurrentValue()74 uint64_t GetCurrentValue() const { return m_current_value; } 75 GetDefaultValue()76 uint64_t GetDefaultValue() const { return m_default_value; } 77 SetCurrentValue(uint64_t value)78 void SetCurrentValue(uint64_t value) { m_current_value = value; } 79 SetDefaultValue(uint64_t value)80 void SetDefaultValue(uint64_t value) { m_default_value = value; } 81 82 protected: 83 uint64_t m_current_value; 84 uint64_t m_default_value; 85 }; 86 87 } // namespace lldb_private 88 89 #endif // liblldb_OptionValueUInt64_h_ 90