]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Interpreter/OptionValueBoolean.h
Merge clang 7.0.1 and several follow-up changes
[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,
54                       CompletionRequest &request) override;
55
56   //---------------------------------------------------------------------
57   // Subclass specific functions
58   //---------------------------------------------------------------------
59
60   //------------------------------------------------------------------
61   /// Convert to bool operator.
62   ///
63   /// This allows code to check a OptionValueBoolean in conditions.
64   ///
65   /// @code
66   /// OptionValueBoolean bool_value(...);
67   /// if (bool_value)
68   /// { ...
69   /// @endcode
70   ///
71   /// @return
72   ///     /b True this object contains a valid namespace decl, \b
73   ///     false otherwise.
74   //------------------------------------------------------------------
75   explicit operator bool() const { return m_current_value; }
76
77   const bool &operator=(bool b) {
78     m_current_value = b;
79     return m_current_value;
80   }
81
82   bool GetCurrentValue() const { return m_current_value; }
83
84   bool GetDefaultValue() const { return m_default_value; }
85
86   void SetCurrentValue(bool value) { m_current_value = value; }
87
88   void SetDefaultValue(bool value) { m_default_value = value; }
89
90   lldb::OptionValueSP DeepCopy() const override;
91
92 protected:
93   bool m_current_value;
94   bool m_default_value;
95 };
96
97 } // namespace lldb_private
98
99 #endif // liblldb_OptionValueBoolean_h_