]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Interpreter/OptionValueBoolean.h
MFV r330591: 8984 fix for 6764 breaks ACL inheritance
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Interpreter / OptionValueBoolean.h
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
19 namespace lldb_private {
20
21 class OptionValueBoolean : public OptionValue {
22 public:
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) {}
28
29   ~OptionValueBoolean() override {}
30
31   //---------------------------------------------------------------------
32   // Virtual subclass pure virtual overrides
33   //---------------------------------------------------------------------
34
35   OptionValue::Type GetType() const override { return eTypeBoolean; }
36
37   void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
38                  uint32_t dump_mask) override;
39
40   Status
41   SetValueFromString(llvm::StringRef value,
42                      VarSetOperationType op = eVarSetOperationAssign) override;
43   Status
44   SetValueFromString(const char *,
45                      VarSetOperationType = eVarSetOperationAssign) = delete;
46
47   bool Clear() override {
48     m_current_value = m_default_value;
49     m_value_was_set = false;
50     return true;
51   }
52
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;
56
57   //---------------------------------------------------------------------
58   // Subclass specific functions
59   //---------------------------------------------------------------------
60
61   //------------------------------------------------------------------
62   /// Convert to bool operator.
63   ///
64   /// This allows code to check a OptionValueBoolean in conditions.
65   ///
66   /// @code
67   /// OptionValueBoolean bool_value(...);
68   /// if (bool_value)
69   /// { ...
70   /// @endcode
71   ///
72   /// @return
73   ///     /b True this object contains a valid namespace decl, \b
74   ///     false otherwise.
75   //------------------------------------------------------------------
76   explicit operator bool() const { return m_current_value; }
77
78   const bool &operator=(bool b) {
79     m_current_value = b;
80     return m_current_value;
81   }
82
83   bool GetCurrentValue() const { return m_current_value; }
84
85   bool GetDefaultValue() const { return m_default_value; }
86
87   void SetCurrentValue(bool value) { m_current_value = value; }
88
89   void SetDefaultValue(bool value) { m_default_value = value; }
90
91   lldb::OptionValueSP DeepCopy() const override;
92
93 protected:
94   bool m_current_value;
95   bool m_default_value;
96 };
97
98 } // namespace lldb_private
99
100 #endif // liblldb_OptionValueBoolean_h_