LLDB mainline
OptionValueSInt64.h
Go to the documentation of this file.
1//===-- OptionValueSInt64.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_OPTIONVALUESINT64_H
11#define LLDB_INTERPRETER_OPTIONVALUESINT64_H
12
14
15namespace lldb_private {
16
17class OptionValueSInt64 : public Cloneable<OptionValueSInt64, OptionValue> {
18public:
19 OptionValueSInt64() = default;
20
21 OptionValueSInt64(int64_t value)
22 : m_current_value(value), m_default_value(value) {}
23
24 OptionValueSInt64(int64_t current_value, int64_t default_value)
25 : m_current_value(current_value), m_default_value(default_value) {}
26
27 OptionValueSInt64(const OptionValueSInt64 &rhs) = default;
28
29 ~OptionValueSInt64() override = default;
30
31 // Virtual subclass pure virtual overrides
32
33 OptionValue::Type GetType() const override { return eTypeSInt64; }
34
35 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
36 uint32_t dump_mask) override;
37
38 llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
39 return m_current_value;
40 }
41
42 Status
43 SetValueFromString(llvm::StringRef value,
45
46 void Clear() override {
48 m_value_was_set = false;
49 }
50
51 // Subclass specific functions
52
53 const int64_t &operator=(int64_t value) {
54 m_current_value = value;
55 return m_current_value;
56 }
57
58 int64_t GetCurrentValue() const { return m_current_value; }
59
60 int64_t GetDefaultValue() const { return m_default_value; }
61
62 bool SetCurrentValue(int64_t value) {
63 if (value >= m_min_value && value <= m_max_value) {
64 m_current_value = value;
65 return true;
66 }
67 return false;
68 }
69
70 bool SetDefaultValue(int64_t value) {
71 if (value >= m_min_value && value <= m_max_value) {
72 m_default_value = value;
73 return true;
74 }
75 return false;
76 }
77
78 void SetMinimumValue(int64_t v) { m_min_value = v; }
79
80 int64_t GetMinimumValue() const { return m_min_value; }
81
82 void SetMaximumValue(int64_t v) { m_max_value = v; }
83
84 int64_t GetMaximumValue() const { return m_max_value; }
85
86protected:
87 int64_t m_current_value = 0;
88 int64_t m_default_value = 0;
89 int64_t m_min_value = std::numeric_limits<int64_t>::min();
90 int64_t m_max_value = std::numeric_limits<int64_t>::max();
91};
92
93} // namespace lldb_private
94
95#endif // LLDB_INTERPRETER_OPTIONVALUESINT64_H
A class that implements CRTP-based "virtual constructor" idiom.
Definition: Cloneable.h:40
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
bool SetCurrentValue(int64_t value)
OptionValueSInt64(int64_t current_value, int64_t default_value)
~OptionValueSInt64() override=default
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
const int64_t & operator=(int64_t value)
bool SetDefaultValue(int64_t value)
OptionValueSInt64(const OptionValueSInt64 &rhs)=default
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
OptionValue::Type GetType() const override
An error handling class.
Definition: Status.h:44
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
A class that represents a running process on the host machine.
VarSetOperationType
Settable state variable types.