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 Cloneable<OptionValueSInt64, OptionValue> { 18 public: 19 OptionValueSInt64() = default; 20 21 OptionValueSInt64(int64_t value) 22 : m_current_value(value), m_default_value(value) {} 23 24 OptionValueSInt64(int64_t current_value, int64_t default_value) 25 : m_current_value(current_value), m_default_value(default_value) {} 26 27 OptionValueSInt64(const OptionValueSInt64 &rhs) = default; 28 29 ~OptionValueSInt64() override = default; 30 31 // Virtual subclass pure virtual overrides 32 33 OptionValue::Type GetType() const override { return eTypeSInt64; } 34 35 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, 36 uint32_t dump_mask) override; 37 38 Status 39 SetValueFromString(llvm::StringRef value, 40 VarSetOperationType op = eVarSetOperationAssign) override; 41 42 void Clear() override { 43 m_current_value = m_default_value; 44 m_value_was_set = false; 45 } 46 47 // Subclass specific functions 48 49 const int64_t &operator=(int64_t value) { 50 m_current_value = value; 51 return m_current_value; 52 } 53 54 int64_t GetCurrentValue() const { return m_current_value; } 55 56 int64_t GetDefaultValue() const { return m_default_value; } 57 58 bool SetCurrentValue(int64_t value) { 59 if (value >= m_min_value && value <= m_max_value) { 60 m_current_value = value; 61 return true; 62 } 63 return false; 64 } 65 66 bool SetDefaultValue(int64_t value) { 67 if (value >= m_min_value && value <= m_max_value) { 68 m_default_value = value; 69 return true; 70 } 71 return false; 72 } 73 74 void SetMinimumValue(int64_t v) { m_min_value = v; } 75 76 int64_t GetMinimumValue() const { return m_min_value; } 77 78 void SetMaximumValue(int64_t v) { m_max_value = v; } 79 80 int64_t GetMaximumValue() const { return m_max_value; } 81 82 protected: 83 int64_t m_current_value = 0; 84 int64_t m_default_value = 0; 85 int64_t m_min_value = INT64_MIN; 86 int64_t m_max_value = INT64_MAX; 87 }; 88 89 } // namespace lldb_private 90 91 #endif // LLDB_INTERPRETER_OPTIONVALUESINT64_H 92