1 //===-- OptionValueSInt64.h --------------------------------------*- C++ 2 //-*-===// 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLDB_INTERPRETER_OPTIONVALUESINT64_H 11 #define LLDB_INTERPRETER_OPTIONVALUESINT64_H 12 13 #include "lldb/Interpreter/OptionValue.h" 14 15 namespace lldb_private { 16 17 class OptionValueSInt64 : public OptionValue { 18 public: 19 OptionValueSInt64() 20 : OptionValue(), m_current_value(0), m_default_value(0), 21 m_min_value(INT64_MIN), m_max_value(INT64_MAX) {} 22 23 OptionValueSInt64(int64_t value) 24 : OptionValue(), m_current_value(value), m_default_value(value), 25 m_min_value(INT64_MIN), m_max_value(INT64_MAX) {} 26 27 OptionValueSInt64(int64_t current_value, int64_t default_value) 28 : OptionValue(), m_current_value(current_value), 29 m_default_value(default_value), m_min_value(INT64_MIN), 30 m_max_value(INT64_MAX) {} 31 32 OptionValueSInt64(const OptionValueSInt64 &rhs) 33 : OptionValue(rhs), m_current_value(rhs.m_current_value), 34 m_default_value(rhs.m_default_value), m_min_value(rhs.m_min_value), 35 m_max_value(rhs.m_max_value) {} 36 37 ~OptionValueSInt64() override {} 38 39 // Virtual subclass pure virtual overrides 40 41 OptionValue::Type GetType() const override { return eTypeSInt64; } 42 43 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, 44 uint32_t dump_mask) override; 45 46 Status 47 SetValueFromString(llvm::StringRef value, 48 VarSetOperationType op = eVarSetOperationAssign) override; 49 Status 50 SetValueFromString(const char *, 51 VarSetOperationType = eVarSetOperationAssign) = delete; 52 53 bool Clear() override { 54 m_current_value = m_default_value; 55 m_value_was_set = false; 56 return true; 57 } 58 59 lldb::OptionValueSP DeepCopy() const override; 60 61 // Subclass specific functions 62 63 const int64_t &operator=(int64_t value) { 64 m_current_value = value; 65 return m_current_value; 66 } 67 68 int64_t GetCurrentValue() const { return m_current_value; } 69 70 int64_t GetDefaultValue() const { return m_default_value; } 71 72 bool SetCurrentValue(int64_t value) { 73 if (value >= m_min_value && value <= m_max_value) { 74 m_current_value = value; 75 return true; 76 } 77 return false; 78 } 79 80 bool SetDefaultValue(int64_t value) { 81 if (value >= m_min_value && value <= m_max_value) { 82 m_default_value = value; 83 return true; 84 } 85 return false; 86 } 87 88 void SetMinimumValue(int64_t v) { m_min_value = v; } 89 90 int64_t GetMinimumValue() const { return m_min_value; } 91 92 void SetMaximumValue(int64_t v) { m_max_value = v; } 93 94 int64_t GetMaximumValue() const { return m_max_value; } 95 96 protected: 97 int64_t m_current_value; 98 int64_t m_default_value; 99 int64_t m_min_value; 100 int64_t m_max_value; 101 }; 102 103 } // namespace lldb_private 104 105 #endif // LLDB_INTERPRETER_OPTIONVALUESINT64_H 106