OptionValueBoolean.h revision 73844aa19a7360b662e2be710fc3c969d6c86606
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// C Includes 14// C++ Includes 15// Other libraries and framework includes 16// Project includes 17#include "lldb/Interpreter/OptionValue.h" 18 19namespace lldb_private { 20 21class OptionValueBoolean : public OptionValue 22{ 23public: 24 OptionValueBoolean (bool value) : 25 OptionValue(), 26 m_current_value (value), 27 m_default_value (value) 28 { 29 } 30 OptionValueBoolean (bool current_value, 31 bool default_value) : 32 OptionValue(), 33 m_current_value (current_value), 34 m_default_value (default_value) 35 { 36 } 37 38 virtual 39 ~OptionValueBoolean() 40 { 41 } 42 43 //--------------------------------------------------------------------- 44 // Virtual subclass pure virtual overrides 45 //--------------------------------------------------------------------- 46 47 virtual OptionValue::Type 48 GetType () const 49 { 50 return eTypeBoolean; 51 } 52 53 virtual void 54 DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); 55 56 virtual Error 57 SetValueFromCString (const char *value, 58 VarSetOperationType op = eVarSetOperationAssign); 59 60 virtual bool 61 Clear () 62 { 63 m_current_value = m_default_value; 64 m_value_was_set = false; 65 return true; 66 } 67 68 //--------------------------------------------------------------------- 69 // Subclass specific functions 70 //--------------------------------------------------------------------- 71 72 //------------------------------------------------------------------ 73 /// Convert to bool operator. 74 /// 75 /// This allows code to check a OptionValueBoolean in conditions. 76 /// 77 /// @code 78 /// OptionValueBoolean bool_value(...); 79 /// if (bool_value) 80 /// { ... 81 /// @endcode 82 /// 83 /// @return 84 /// /b True this object contains a valid namespace decl, \b 85 /// false otherwise. 86 //------------------------------------------------------------------ 87 operator bool() const 88 { 89 return m_current_value; 90 } 91 92 const bool & 93 operator = (bool b) 94 { 95 m_current_value = b; 96 return m_current_value; 97 } 98 99 bool 100 GetCurrentValue() const 101 { 102 return m_current_value; 103 } 104 105 bool 106 GetDefaultValue() const 107 { 108 return m_default_value; 109 } 110 111 void 112 SetCurrentValue (bool value) 113 { 114 m_current_value = value; 115 } 116 117 void 118 SetDefaultValue (bool value) 119 { 120 m_default_value = value; 121 } 122 123 virtual lldb::OptionValueSP 124 DeepCopy () const; 125 126protected: 127 bool m_current_value; 128 bool m_default_value; 129}; 130 131} // namespace lldb_private 132 133#endif // liblldb_OptionValueBoolean_h_ 134