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 liblldb_OptionValueBoolean_h_
10 #define liblldb_OptionValueBoolean_h_
11 
13 
14 namespace lldb_private {
15 
17 public:
18  OptionValueBoolean(bool value)
19  : OptionValue(), m_current_value(value), m_default_value(value) {}
20  OptionValueBoolean(bool current_value, bool default_value)
21  : OptionValue(), m_current_value(current_value),
22  m_default_value(default_value) {}
23 
24  ~OptionValueBoolean() override {}
25 
26  // Virtual subclass pure virtual overrides
27 
28  OptionValue::Type GetType() const override { return eTypeBoolean; }
29 
30  void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
31  uint32_t dump_mask) override;
32 
33  Status
34  SetValueFromString(llvm::StringRef value,
36  Status
37  SetValueFromString(const char *,
39 
40  bool Clear() override {
42  m_value_was_set = false;
43  return true;
44  }
45 
46  size_t AutoComplete(CommandInterpreter &interpreter,
47  CompletionRequest &request) override;
48 
49  // Subclass specific functions
50 
51  /// Convert to bool operator.
52  ///
53  /// This allows code to check a OptionValueBoolean in conditions.
54  ///
55  /// \code
56  /// OptionValueBoolean bool_value(...);
57  /// if (bool_value)
58  /// { ...
59  /// \endcode
60  ///
61  /// \return
62  /// /b True this object contains a valid namespace decl, \b
63  /// false otherwise.
64  explicit operator bool() const { return m_current_value; }
65 
66  const bool &operator=(bool b) {
67  m_current_value = b;
68  return m_current_value;
69  }
70 
71  bool GetCurrentValue() const { return m_current_value; }
72 
73  bool GetDefaultValue() const { return m_default_value; }
74 
75  void SetCurrentValue(bool value) { m_current_value = value; }
76 
77  void SetDefaultValue(bool value) { m_default_value = value; }
78 
79  lldb::OptionValueSP DeepCopy() const override;
80 
81 protected:
84 };
85 
86 } // namespace lldb_private
87 
88 #endif // liblldb_OptionValueBoolean_h_
OptionValue::Type GetType() const override
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
"lldb/Utility/ArgCompletionRequest.h"
VarSetOperationType
Settable state variable types.
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
size_t AutoComplete(CommandInterpreter &interpreter, CompletionRequest &request) override
lldb::OptionValueSP DeepCopy() const override
OptionValueBoolean(bool current_value, bool default_value)
An error handling class.
Definition: Status.h:44