1 //===-- OptionValueBoolean.h ------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_OptionValueBoolean_h_
11 #define liblldb_OptionValueBoolean_h_
13 #include "lldb/Interpreter/OptionValue.h"
15 namespace lldb_private {
17 class OptionValueBoolean : public OptionValue {
19 OptionValueBoolean(bool value)
20 : OptionValue(), m_current_value(value), m_default_value(value) {}
21 OptionValueBoolean(bool current_value, bool default_value)
22 : OptionValue(), m_current_value(current_value),
23 m_default_value(default_value) {}
25 ~OptionValueBoolean() override {}
27 //---------------------------------------------------------------------
28 // Virtual subclass pure virtual overrides
29 //---------------------------------------------------------------------
31 OptionValue::Type GetType() const override { return eTypeBoolean; }
33 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
34 uint32_t dump_mask) override;
37 SetValueFromString(llvm::StringRef value,
38 VarSetOperationType op = eVarSetOperationAssign) override;
40 SetValueFromString(const char *,
41 VarSetOperationType = eVarSetOperationAssign) = delete;
43 bool Clear() override {
44 m_current_value = m_default_value;
45 m_value_was_set = false;
49 size_t AutoComplete(CommandInterpreter &interpreter,
50 CompletionRequest &request) override;
52 //---------------------------------------------------------------------
53 // Subclass specific functions
54 //---------------------------------------------------------------------
56 //------------------------------------------------------------------
57 /// Convert to bool operator.
59 /// This allows code to check a OptionValueBoolean in conditions.
62 /// OptionValueBoolean bool_value(...);
68 /// /b True this object contains a valid namespace decl, \b
70 //------------------------------------------------------------------
71 explicit operator bool() const { return m_current_value; }
73 const bool &operator=(bool b) {
75 return m_current_value;
78 bool GetCurrentValue() const { return m_current_value; }
80 bool GetDefaultValue() const { return m_default_value; }
82 void SetCurrentValue(bool value) { m_current_value = value; }
84 void SetDefaultValue(bool value) { m_default_value = value; }
86 lldb::OptionValueSP DeepCopy() const override;
93 } // namespace lldb_private
95 #endif // liblldb_OptionValueBoolean_h_