1 //===-- OptionValueUInt64.h --------------------------------------*- C++
4 // The LLVM Compiler Infrastructure
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef liblldb_OptionValueUInt64_h_
12 #define liblldb_OptionValueUInt64_h_
16 // Other libraries and framework includes
18 #include "lldb/Interpreter/OptionValue.h"
20 namespace lldb_private {
22 class OptionValueUInt64 : public OptionValue {
24 OptionValueUInt64() : OptionValue(), m_current_value(0), m_default_value(0) {}
26 OptionValueUInt64(uint64_t value)
27 : OptionValue(), m_current_value(value), m_default_value(value) {}
29 OptionValueUInt64(uint64_t current_value, uint64_t default_value)
30 : OptionValue(), m_current_value(current_value),
31 m_default_value(default_value) {}
33 ~OptionValueUInt64() override {}
35 //---------------------------------------------------------------------
36 // Decode a uint64_t from "value_cstr" return a OptionValueUInt64 object
37 // inside of a lldb::OptionValueSP object if all goes well. If the
38 // string isn't a uint64_t value or any other error occurs, return an
39 // empty lldb::OptionValueSP and fill error in with the correct stuff.
40 //---------------------------------------------------------------------
41 static lldb::OptionValueSP Create(const char *, Error &) = delete;
42 static lldb::OptionValueSP Create(llvm::StringRef value_str, Error &error);
43 //---------------------------------------------------------------------
44 // Virtual subclass pure virtual overrides
45 //---------------------------------------------------------------------
47 OptionValue::Type GetType() const override { return eTypeUInt64; }
49 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
50 uint32_t dump_mask) override;
53 SetValueFromString(llvm::StringRef value,
54 VarSetOperationType op = eVarSetOperationAssign) override;
56 SetValueFromString(const char *,
57 VarSetOperationType = eVarSetOperationAssign) = delete;
59 bool Clear() override {
60 m_current_value = m_default_value;
61 m_value_was_set = false;
65 lldb::OptionValueSP DeepCopy() const override;
67 //---------------------------------------------------------------------
68 // Subclass specific functions
69 //---------------------------------------------------------------------
71 const uint64_t &operator=(uint64_t value) {
72 m_current_value = value;
73 return m_current_value;
76 operator uint64_t() const { return m_current_value; }
78 uint64_t GetCurrentValue() const { return m_current_value; }
80 uint64_t GetDefaultValue() const { return m_default_value; }
82 void SetCurrentValue(uint64_t value) { m_current_value = value; }
84 void SetDefaultValue(uint64_t value) { m_default_value = value; }
87 uint64_t m_current_value;
88 uint64_t m_default_value;
91 } // namespace lldb_private
93 #endif // liblldb_OptionValueUInt64_h_