xref: /freebsd/contrib/llvm-project/lldb/include/lldb/Interpreter/OptionValueSInt64.h (revision fe6060f10f634930ff71b7c50291ddc610da2475)
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 
17*fe6060f1SDimitry Andric class OptionValueSInt64 : public Cloneable<OptionValueSInt64, OptionValue> {
180b57cec5SDimitry Andric public:
19*fe6060f1SDimitry Andric   OptionValueSInt64() = default;
200b57cec5SDimitry Andric 
210b57cec5SDimitry Andric   OptionValueSInt64(int64_t value)
22*fe6060f1SDimitry Andric       : m_current_value(value), m_default_value(value) {}
230b57cec5SDimitry Andric 
240b57cec5SDimitry Andric   OptionValueSInt64(int64_t current_value, int64_t default_value)
25*fe6060f1SDimitry Andric       : m_current_value(current_value), m_default_value(default_value) {}
260b57cec5SDimitry Andric 
27*fe6060f1SDimitry Andric   OptionValueSInt64(const OptionValueSInt64 &rhs) = default;
280b57cec5SDimitry Andric 
29*fe6060f1SDimitry 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 
380b57cec5SDimitry Andric   Status
390b57cec5SDimitry Andric   SetValueFromString(llvm::StringRef value,
400b57cec5SDimitry Andric                      VarSetOperationType op = eVarSetOperationAssign) override;
410b57cec5SDimitry Andric 
42e8d8bef9SDimitry Andric   void Clear() override {
430b57cec5SDimitry Andric     m_current_value = m_default_value;
440b57cec5SDimitry Andric     m_value_was_set = false;
450b57cec5SDimitry Andric   }
460b57cec5SDimitry Andric 
470b57cec5SDimitry Andric   // Subclass specific functions
480b57cec5SDimitry Andric 
490b57cec5SDimitry Andric   const int64_t &operator=(int64_t value) {
500b57cec5SDimitry Andric     m_current_value = value;
510b57cec5SDimitry Andric     return m_current_value;
520b57cec5SDimitry Andric   }
530b57cec5SDimitry Andric 
540b57cec5SDimitry Andric   int64_t GetCurrentValue() const { return m_current_value; }
550b57cec5SDimitry Andric 
560b57cec5SDimitry Andric   int64_t GetDefaultValue() const { return m_default_value; }
570b57cec5SDimitry Andric 
580b57cec5SDimitry Andric   bool SetCurrentValue(int64_t value) {
590b57cec5SDimitry Andric     if (value >= m_min_value && value <= m_max_value) {
600b57cec5SDimitry Andric       m_current_value = value;
610b57cec5SDimitry Andric       return true;
620b57cec5SDimitry Andric     }
630b57cec5SDimitry Andric     return false;
640b57cec5SDimitry Andric   }
650b57cec5SDimitry Andric 
660b57cec5SDimitry Andric   bool SetDefaultValue(int64_t value) {
670b57cec5SDimitry Andric     if (value >= m_min_value && value <= m_max_value) {
680b57cec5SDimitry Andric       m_default_value = value;
690b57cec5SDimitry Andric       return true;
700b57cec5SDimitry Andric     }
710b57cec5SDimitry Andric     return false;
720b57cec5SDimitry Andric   }
730b57cec5SDimitry Andric 
740b57cec5SDimitry Andric   void SetMinimumValue(int64_t v) { m_min_value = v; }
750b57cec5SDimitry Andric 
760b57cec5SDimitry Andric   int64_t GetMinimumValue() const { return m_min_value; }
770b57cec5SDimitry Andric 
780b57cec5SDimitry Andric   void SetMaximumValue(int64_t v) { m_max_value = v; }
790b57cec5SDimitry Andric 
800b57cec5SDimitry Andric   int64_t GetMaximumValue() const { return m_max_value; }
810b57cec5SDimitry Andric 
820b57cec5SDimitry Andric protected:
83*fe6060f1SDimitry Andric   int64_t m_current_value = 0;
84*fe6060f1SDimitry Andric   int64_t m_default_value = 0;
85*fe6060f1SDimitry Andric   int64_t m_min_value = INT64_MIN;
86*fe6060f1SDimitry Andric   int64_t m_max_value = INT64_MAX;
870b57cec5SDimitry Andric };
880b57cec5SDimitry Andric 
890b57cec5SDimitry Andric } // namespace lldb_private
900b57cec5SDimitry Andric 
915ffd83dbSDimitry Andric #endif // LLDB_INTERPRETER_OPTIONVALUESINT64_H
92