10b57cec5SDimitry Andric //===-- OptionValueSInt64.h --------------------------------------*- C++ 20b57cec5SDimitry Andric //-*-===// 30b57cec5SDimitry Andric // 40b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 50b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 60b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 70b57cec5SDimitry Andric // 80b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 90b57cec5SDimitry Andric 105ffd83dbSDimitry Andric #ifndef LLDB_INTERPRETER_OPTIONVALUESINT64_H 115ffd83dbSDimitry Andric #define LLDB_INTERPRETER_OPTIONVALUESINT64_H 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #include "lldb/Interpreter/OptionValue.h" 140b57cec5SDimitry Andric 150b57cec5SDimitry Andric namespace lldb_private { 160b57cec5SDimitry Andric 17fe6060f1SDimitry Andric class OptionValueSInt64 : public Cloneable<OptionValueSInt64, OptionValue> { 180b57cec5SDimitry Andric public: 19fe6060f1SDimitry Andric OptionValueSInt64() = default; 200b57cec5SDimitry Andric 210b57cec5SDimitry Andric OptionValueSInt64(int64_t value) 22fe6060f1SDimitry Andric : m_current_value(value), m_default_value(value) {} 230b57cec5SDimitry Andric 240b57cec5SDimitry Andric OptionValueSInt64(int64_t current_value, int64_t default_value) 25fe6060f1SDimitry Andric : m_current_value(current_value), m_default_value(default_value) {} 260b57cec5SDimitry Andric 27fe6060f1SDimitry Andric OptionValueSInt64(const OptionValueSInt64 &rhs) = default; 280b57cec5SDimitry Andric 29fe6060f1SDimitry Andric ~OptionValueSInt64() override = default; 300b57cec5SDimitry Andric 310b57cec5SDimitry Andric // Virtual subclass pure virtual overrides 320b57cec5SDimitry Andric 330b57cec5SDimitry Andric OptionValue::Type GetType() const override { return eTypeSInt64; } 340b57cec5SDimitry Andric 350b57cec5SDimitry Andric void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, 360b57cec5SDimitry Andric uint32_t dump_mask) override; 370b57cec5SDimitry Andric 38*bdd1243dSDimitry Andric llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override { 39*bdd1243dSDimitry Andric return m_current_value; 40*bdd1243dSDimitry Andric } 41*bdd1243dSDimitry Andric 420b57cec5SDimitry Andric Status 430b57cec5SDimitry Andric SetValueFromString(llvm::StringRef value, 440b57cec5SDimitry Andric VarSetOperationType op = eVarSetOperationAssign) override; 450b57cec5SDimitry Andric 46e8d8bef9SDimitry Andric void Clear() override { 470b57cec5SDimitry Andric m_current_value = m_default_value; 480b57cec5SDimitry Andric m_value_was_set = false; 490b57cec5SDimitry Andric } 500b57cec5SDimitry Andric 510b57cec5SDimitry Andric // Subclass specific functions 520b57cec5SDimitry Andric 530b57cec5SDimitry Andric const int64_t &operator=(int64_t value) { 540b57cec5SDimitry Andric m_current_value = value; 550b57cec5SDimitry Andric return m_current_value; 560b57cec5SDimitry Andric } 570b57cec5SDimitry Andric 580b57cec5SDimitry Andric int64_t GetCurrentValue() const { return m_current_value; } 590b57cec5SDimitry Andric 600b57cec5SDimitry Andric int64_t GetDefaultValue() const { return m_default_value; } 610b57cec5SDimitry Andric 620b57cec5SDimitry Andric bool SetCurrentValue(int64_t value) { 630b57cec5SDimitry Andric if (value >= m_min_value && value <= m_max_value) { 640b57cec5SDimitry Andric m_current_value = value; 650b57cec5SDimitry Andric return true; 660b57cec5SDimitry Andric } 670b57cec5SDimitry Andric return false; 680b57cec5SDimitry Andric } 690b57cec5SDimitry Andric 700b57cec5SDimitry Andric bool SetDefaultValue(int64_t value) { 710b57cec5SDimitry Andric if (value >= m_min_value && value <= m_max_value) { 720b57cec5SDimitry Andric m_default_value = value; 730b57cec5SDimitry Andric return true; 740b57cec5SDimitry Andric } 750b57cec5SDimitry Andric return false; 760b57cec5SDimitry Andric } 770b57cec5SDimitry Andric 780b57cec5SDimitry Andric void SetMinimumValue(int64_t v) { m_min_value = v; } 790b57cec5SDimitry Andric 800b57cec5SDimitry Andric int64_t GetMinimumValue() const { return m_min_value; } 810b57cec5SDimitry Andric 820b57cec5SDimitry Andric void SetMaximumValue(int64_t v) { m_max_value = v; } 830b57cec5SDimitry Andric 840b57cec5SDimitry Andric int64_t GetMaximumValue() const { return m_max_value; } 850b57cec5SDimitry Andric 860b57cec5SDimitry Andric protected: 87fe6060f1SDimitry Andric int64_t m_current_value = 0; 88fe6060f1SDimitry Andric int64_t m_default_value = 0; 89fe6060f1SDimitry Andric int64_t m_min_value = INT64_MIN; 90fe6060f1SDimitry Andric int64_t m_max_value = INT64_MAX; 910b57cec5SDimitry Andric }; 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric } // namespace lldb_private 940b57cec5SDimitry Andric 955ffd83dbSDimitry Andric #endif // LLDB_INTERPRETER_OPTIONVALUESINT64_H 96