1 //===-- OptionValueBoolean.h ------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef liblldb_OptionValueBoolean_h_ 11 #define liblldb_OptionValueBoolean_h_ 12 13 #include "lldb/Interpreter/OptionValue.h" 14 15 namespace lldb_private { 16 17 class OptionValueBoolean : public OptionValue { 18 public: OptionValueBoolean(bool value)19 OptionValueBoolean(bool value) 20 : OptionValue(), m_current_value(value), m_default_value(value) {} OptionValueBoolean(bool current_value,bool default_value)21 OptionValueBoolean(bool current_value, bool default_value) 22 : OptionValue(), m_current_value(current_value), 23 m_default_value(default_value) {} 24 ~OptionValueBoolean()25 ~OptionValueBoolean() override {} 26 27 //--------------------------------------------------------------------- 28 // Virtual subclass pure virtual overrides 29 //--------------------------------------------------------------------- 30 GetType()31 OptionValue::Type GetType() const override { return eTypeBoolean; } 32 33 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, 34 uint32_t dump_mask) override; 35 36 Status 37 SetValueFromString(llvm::StringRef value, 38 VarSetOperationType op = eVarSetOperationAssign) override; 39 Status 40 SetValueFromString(const char *, 41 VarSetOperationType = eVarSetOperationAssign) = delete; 42 Clear()43 bool Clear() override { 44 m_current_value = m_default_value; 45 m_value_was_set = false; 46 return true; 47 } 48 49 size_t AutoComplete(CommandInterpreter &interpreter, 50 CompletionRequest &request) override; 51 52 //--------------------------------------------------------------------- 53 // Subclass specific functions 54 //--------------------------------------------------------------------- 55 56 //------------------------------------------------------------------ 57 /// Convert to bool operator. 58 /// 59 /// This allows code to check a OptionValueBoolean in conditions. 60 /// 61 /// @code 62 /// OptionValueBoolean bool_value(...); 63 /// if (bool_value) 64 /// { ... 65 /// @endcode 66 /// 67 /// @return 68 /// /b True this object contains a valid namespace decl, \b 69 /// false otherwise. 70 //------------------------------------------------------------------ 71 explicit operator bool() const { return m_current_value; } 72 73 const bool &operator=(bool b) { 74 m_current_value = b; 75 return m_current_value; 76 } 77 GetCurrentValue()78 bool GetCurrentValue() const { return m_current_value; } 79 GetDefaultValue()80 bool GetDefaultValue() const { return m_default_value; } 81 SetCurrentValue(bool value)82 void SetCurrentValue(bool value) { m_current_value = value; } 83 SetDefaultValue(bool value)84 void SetDefaultValue(bool value) { m_default_value = value; } 85 86 lldb::OptionValueSP DeepCopy() const override; 87 88 protected: 89 bool m_current_value; 90 bool m_default_value; 91 }; 92 93 } // namespace lldb_private 94 95 #endif // liblldb_OptionValueBoolean_h_ 96