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 
14 namespace lldb_private {
15 
16 class OptionValueBoolean : public Cloneable<OptionValueBoolean, OptionValue> {
17 public:
18  OptionValueBoolean(bool value)
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  Status
33  SetValueFromString(llvm::StringRef value,
35 
36  void Clear() override {
38  m_value_was_set = false;
39  }
40 
41  void AutoComplete(CommandInterpreter &interpreter,
42  CompletionRequest &request) override;
43 
44  // Subclass specific functions
45 
46  /// Convert to bool operator.
47  ///
48  /// This allows code to check a OptionValueBoolean in conditions.
49  ///
50  /// \code
51  /// OptionValueBoolean bool_value(...);
52  /// if (bool_value)
53  /// { ...
54  /// \endcode
55  ///
56  /// \return
57  /// /b True this object contains a valid namespace decl, \b
58  /// false otherwise.
59  explicit operator bool() const { return m_current_value; }
60 
61  const bool &operator=(bool b) {
62  m_current_value = b;
63  return m_current_value;
64  }
65 
66  bool GetCurrentValue() const { return m_current_value; }
67 
68  bool GetDefaultValue() const { return m_default_value; }
69 
70  void SetCurrentValue(bool value) { m_current_value = value; }
71 
72  void SetDefaultValue(bool value) { m_default_value = value; }
73 
74 protected:
77 };
78 
79 } // namespace lldb_private
80 
81 #endif // LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H
lldb_private::OptionValueBoolean::DumpValue
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
Definition: OptionValueBoolean.cpp:20
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::OptionValueBoolean::SetCurrentValue
void SetCurrentValue(bool value)
Definition: OptionValueBoolean.h:70
lldb_private::OptionValueBoolean
Definition: OptionValueBoolean.h:16
lldb_private::OptionValueBoolean::AutoComplete
void AutoComplete(CommandInterpreter &interpreter, CompletionRequest &request) override
Definition: OptionValueBoolean.cpp:70
lldb_private::OptionValue::eTypeBoolean
@ eTypeBoolean
Definition: OptionValue.h:31
lldb_private::Stream
Definition: Stream.h:28
lldb_private::OptionValueBoolean::GetCurrentValue
bool GetCurrentValue() const
Definition: OptionValueBoolean.h:66
lldb_private::OptionValueBoolean::~OptionValueBoolean
~OptionValueBoolean() override=default
lldb_private::Cloneable
Definition: Cloneable.h:40
OptionValue.h
lldb_private::VarSetOperationType
VarSetOperationType
Settable state variable types.
Definition: lldb-private-enumerations.h:83
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:214
lldb_private::OptionValueBoolean::GetType
OptionValue::Type GetType() const override
Definition: OptionValueBoolean.h:27
lldb_private::OptionValueBoolean::OptionValueBoolean
OptionValueBoolean(bool value)
Definition: OptionValueBoolean.h:18
lldb_private::OptionValueBoolean::Clear
void Clear() override
Definition: OptionValueBoolean.h:36
lldb_private::Status
Definition: Status.h:44
lldb_private::OptionValue::Type
Type
Definition: OptionValue.h:26
uint32_t
lldb_private::OptionValue::m_value_was_set
bool m_value_was_set
Definition: OptionValue.h:332
lldb_private::OptionValueBoolean::SetDefaultValue
void SetDefaultValue(bool value)
Definition: OptionValueBoolean.h:72
lldb_private::OptionValueBoolean::operator=
const bool & operator=(bool b)
Definition: OptionValueBoolean.h:61
lldb_private::OptionValueBoolean::OptionValueBoolean
OptionValueBoolean(bool current_value, bool default_value)
Definition: OptionValueBoolean.h:20
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::OptionValueBoolean::m_current_value
bool m_current_value
Definition: OptionValueBoolean.h:75
lldb_private::OptionValueBoolean::GetDefaultValue
bool GetDefaultValue() const
Definition: OptionValueBoolean.h:68
lldb_private::OptionValueBoolean::SetValueFromString
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
Definition: OptionValueBoolean.cpp:33
lldb_private::OptionValueBoolean::m_default_value
bool m_default_value
Definition: OptionValueBoolean.h:76
lldb_private::CompletionRequest
Definition: CompletionRequest.h:100
lldb_private::eVarSetOperationAssign
@ eVarSetOperationAssign
Definition: lldb-private-enumerations.h:90