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_
15 // Other libraries and framework includes
17 #include "lldb/Interpreter/OptionValue.h"
19 namespace lldb_private {
21 class OptionValueBoolean : public OptionValue {
23 OptionValueBoolean(bool value)
24 : OptionValue(), m_current_value(value), m_default_value(value) {}
25 OptionValueBoolean(bool current_value, bool default_value)
26 : OptionValue(), m_current_value(current_value),
27 m_default_value(default_value) {}
29 ~OptionValueBoolean() override {}
31 //---------------------------------------------------------------------
32 // Virtual subclass pure virtual overrides
33 //---------------------------------------------------------------------
35 OptionValue::Type GetType() const override { return eTypeBoolean; }
37 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
38 uint32_t dump_mask) override;
41 SetValueFromString(llvm::StringRef value,
42 VarSetOperationType op = eVarSetOperationAssign) override;
44 SetValueFromString(const char *,
45 VarSetOperationType = eVarSetOperationAssign) = delete;
47 bool Clear() override {
48 m_current_value = m_default_value;
49 m_value_was_set = false;
53 size_t AutoComplete(CommandInterpreter &interpreter, llvm::StringRef s,
54 int match_start_point, int max_return_elements,
55 bool &word_complete, StringList &matches) override;
57 //---------------------------------------------------------------------
58 // Subclass specific functions
59 //---------------------------------------------------------------------
61 //------------------------------------------------------------------
62 /// Convert to bool operator.
64 /// This allows code to check a OptionValueBoolean in conditions.
67 /// OptionValueBoolean bool_value(...);
73 /// /b True this object contains a valid namespace decl, \b
75 //------------------------------------------------------------------
76 explicit operator bool() const { return m_current_value; }
78 const bool &operator=(bool b) {
80 return m_current_value;
83 bool GetCurrentValue() const { return m_current_value; }
85 bool GetDefaultValue() const { return m_default_value; }
87 void SetCurrentValue(bool value) { m_current_value = value; }
89 void SetDefaultValue(bool value) { m_default_value = value; }
91 lldb::OptionValueSP DeepCopy() const override;
98 } // namespace lldb_private
100 #endif // liblldb_OptionValueBoolean_h_