LLDB mainline
OptionValueBoolean.h
Go to the documentation of this file.
1//===-- OptionValueBoolean.h ------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H
10#define LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H
11
13
14namespace lldb_private {
15
16class OptionValueBoolean : public Cloneable<OptionValueBoolean, OptionValue> {
17public:
19 : m_current_value(value), m_default_value(value) {}
20 OptionValueBoolean(bool current_value, bool default_value)
21 : m_current_value(current_value), m_default_value(default_value) {}
22
23 ~OptionValueBoolean() override = default;
24
25 // Virtual subclass pure virtual overrides
26
27 OptionValue::Type GetType() const override { return eTypeBoolean; }
28
29 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
30 uint32_t dump_mask) override;
31
32 llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override {
33 return m_current_value;
34 }
35
36 Status
37 SetValueFromString(llvm::StringRef value,
39
40 void AutoComplete(CommandInterpreter &interpreter,
41 CompletionRequest &request) override;
42
43 bool IsDefault() const override { return m_current_value == m_default_value; }
44
45 // Subclass specific functions
46
47 /// Convert to bool operator.
48 ///
49 /// This allows code to check a OptionValueBoolean in conditions.
50 ///
51 /// \code
52 /// OptionValueBoolean bool_value(...);
53 /// if (bool_value)
54 /// { ...
55 /// \endcode
56 ///
57 /// \return
58 /// /b True this object contains a valid namespace decl, \b
59 /// false otherwise.
60 explicit operator bool() const { return m_current_value; }
61
62 const bool &operator=(bool b) {
64 return m_current_value;
65 }
66
67 bool GetCurrentValue() const { return m_current_value; }
68
69 bool GetDefaultValue() const { return m_default_value; }
70
71 void SetCurrentValue(bool value) { m_current_value = value; }
72
73 void SetDefaultValue(bool value) { m_default_value = value; }
74
75protected:
76 void ClearImpl() override {
78 m_value_was_set = false;
79 }
80
83};
84
85} // namespace lldb_private
86
87#endif // LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H
A class that implements CRTP-based "virtual constructor" idiom.
Definition Cloneable.h:40
"lldb/Utility/ArgCompletionRequest.h"
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
bool IsDefault() const override
Return true if the current value equals the default value.
OptionValueBoolean(bool current_value, bool default_value)
OptionValue::Type GetType() const override
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override
~OptionValueBoolean() override=default
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
void AutoComplete(CommandInterpreter &interpreter, CompletionRequest &request) override
An error handling class.
Definition Status.h:118
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.