1//===-- OptionValueUInt64.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_OPTIONVALUEUINT64_H
11#define LLDB_INTERPRETER_OPTIONVALUEUINT64_H
12
13#include "lldb/Interpreter/OptionValue.h"
14
15namespace lldb_private {
16
17class OptionValueUInt64 : public Cloneable<OptionValueUInt64, OptionValue> {
18public:
19 OptionValueUInt64() = default;
20
21 OptionValueUInt64(uint64_t value)
22 : m_current_value(value), m_default_value(value) {}
23
24 OptionValueUInt64(uint64_t current_value, uint64_t default_value)
25 : m_current_value(current_value), m_default_value(default_value) {}
26
27 ~OptionValueUInt64() override = default;
28
29 // Decode a uint64_t from "value_cstr" return a OptionValueUInt64 object
30 // inside of a lldb::OptionValueSP object if all goes well. If the string
31 // isn't a uint64_t value or any other error occurs, return an empty
32 // lldb::OptionValueSP and fill error in with the correct stuff.
33 static lldb::OptionValueSP Create(llvm::StringRef value_str, Status &error);
34 // Virtual subclass pure virtual overrides
35
36 OptionValue::Type GetType() const override { return eTypeUInt64; }
37
38 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
39 uint32_t dump_mask) override;
40
41 llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
42 return m_current_value;
43 }
44
45 Status
46 SetValueFromString(llvm::StringRef value,
47 VarSetOperationType op = eVarSetOperationAssign) override;
48
49 void Clear() override {
50 m_current_value = m_default_value;
51 m_value_was_set = false;
52 }
53
54 // Subclass specific functions
55
56 const uint64_t &operator=(uint64_t value) {
57 m_current_value = value;
58 return m_current_value;
59 }
60
61 operator uint64_t() const { return m_current_value; }
62
63 uint64_t GetCurrentValue() const { return m_current_value; }
64
65 uint64_t GetDefaultValue() const { return m_default_value; }
66
67 bool SetCurrentValue(uint64_t value) {
68 if (value >= m_min_value && value <= m_max_value) {
69 m_current_value = value;
70 return true;
71 }
72 return false;
73 }
74
75 bool SetDefaultValue(uint64_t value) {
76 if (value >= m_min_value && value <= m_max_value) {
77 m_default_value = value;
78 return true;
79 }
80 return false;
81 }
82
83 void SetMinimumValue(int64_t v) { m_min_value = v; }
84
85 uint64_t GetMinimumValue() const { return m_min_value; }
86
87 void SetMaximumValue(int64_t v) { m_max_value = v; }
88
89 uint64_t GetMaximumValue() const { return m_max_value; }
90
91protected:
92 uint64_t m_current_value = 0;
93 uint64_t m_default_value = 0;
94 uint64_t m_min_value = std::numeric_limits<uint64_t>::min();
95 uint64_t m_max_value = std::numeric_limits<uint64_t>::max();
96};
97
98} // namespace lldb_private
99
100#endif // LLDB_INTERPRETER_OPTIONVALUEUINT64_H
101

source code of lldb/include/lldb/Interpreter/OptionValueUInt64.h