Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:51

0001 //===-- OptionValueUInt64.h --------------------------------------*- C++
0002 //-*-===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef LLDB_INTERPRETER_OPTIONVALUEUINT64_H
0011 #define LLDB_INTERPRETER_OPTIONVALUEUINT64_H
0012 
0013 #include "lldb/Interpreter/OptionValue.h"
0014 
0015 namespace lldb_private {
0016 
0017 class OptionValueUInt64 : public Cloneable<OptionValueUInt64, OptionValue> {
0018 public:
0019   OptionValueUInt64() = default;
0020 
0021   OptionValueUInt64(uint64_t value)
0022       : m_current_value(value), m_default_value(value) {}
0023 
0024   OptionValueUInt64(uint64_t current_value, uint64_t default_value)
0025       : m_current_value(current_value), m_default_value(default_value) {}
0026 
0027   ~OptionValueUInt64() override = default;
0028 
0029   // Decode a uint64_t from "value_cstr" return a OptionValueUInt64 object
0030   // inside of a lldb::OptionValueSP object if all goes well. If the string
0031   // isn't a uint64_t value or any other error occurs, return an empty
0032   // lldb::OptionValueSP and fill error in with the correct stuff.
0033   static lldb::OptionValueSP Create(llvm::StringRef value_str, Status &error);
0034   // Virtual subclass pure virtual overrides
0035 
0036   OptionValue::Type GetType() const override { return eTypeUInt64; }
0037 
0038   void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
0039                  uint32_t dump_mask) override;
0040 
0041   llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
0042     return m_current_value;
0043   }
0044 
0045   Status
0046   SetValueFromString(llvm::StringRef value,
0047                      VarSetOperationType op = eVarSetOperationAssign) override;
0048 
0049   void Clear() override {
0050     m_current_value = m_default_value;
0051     m_value_was_set = false;
0052   }
0053 
0054   // Subclass specific functions
0055 
0056   const uint64_t &operator=(uint64_t value) {
0057     m_current_value = value;
0058     return m_current_value;
0059   }
0060 
0061   operator uint64_t() const { return m_current_value; }
0062 
0063   uint64_t GetCurrentValue() const { return m_current_value; }
0064 
0065   uint64_t GetDefaultValue() const { return m_default_value; }
0066 
0067   bool SetCurrentValue(uint64_t value) {
0068     if (value >= m_min_value && value <= m_max_value) {
0069       m_current_value = value;
0070       return true;
0071     }
0072     return false;
0073   }
0074 
0075   bool SetDefaultValue(uint64_t value) {
0076     if (value >= m_min_value && value <= m_max_value) {
0077       m_default_value = value;
0078       return true;
0079     }
0080     return false;
0081   }
0082 
0083   void SetMinimumValue(int64_t v) { m_min_value = v; }
0084 
0085   uint64_t GetMinimumValue() const { return m_min_value; }
0086 
0087   void SetMaximumValue(int64_t v) { m_max_value = v; }
0088 
0089   uint64_t GetMaximumValue() const { return m_max_value; }
0090 
0091 protected:
0092   uint64_t m_current_value = 0;
0093   uint64_t m_default_value = 0;
0094   uint64_t m_min_value = std::numeric_limits<uint64_t>::min();
0095   uint64_t m_max_value = std::numeric_limits<uint64_t>::max();
0096 };
0097 
0098 } // namespace lldb_private
0099 
0100 #endif // LLDB_INTERPRETER_OPTIONVALUEUINT64_H