]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Interpreter/OptionValueBoolean.h
Merge ^/head r303250 through r308226.
[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 {
23 public:
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     ~OptionValueBoolean() override
39     {
40     }
41     
42     //---------------------------------------------------------------------
43     // Virtual subclass pure virtual overrides
44     //---------------------------------------------------------------------
45     
46     OptionValue::Type
47     GetType() const override
48     {
49         return eTypeBoolean;
50     }
51     
52     void
53     DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
54     
55     Error
56     SetValueFromString(llvm::StringRef value,
57                        VarSetOperationType op = eVarSetOperationAssign) override;
58     
59     bool
60     Clear() override
61     {
62         m_current_value = m_default_value;
63         m_value_was_set = false;
64         return true;
65     }
66
67     size_t
68     AutoComplete(CommandInterpreter &interpreter,
69                  const char *s,
70                  int match_start_point,
71                  int max_return_elements,
72                  bool &word_complete,
73                  StringList &matches) override;
74
75     //---------------------------------------------------------------------
76     // Subclass specific functions
77     //---------------------------------------------------------------------
78     
79     //------------------------------------------------------------------
80     /// Convert to bool operator.
81     ///
82     /// This allows code to check a OptionValueBoolean in conditions.
83     ///
84     /// @code
85     /// OptionValueBoolean bool_value(...);
86     /// if (bool_value)
87     /// { ...
88     /// @endcode
89     ///
90     /// @return
91     ///     /b True this object contains a valid namespace decl, \b 
92     ///     false otherwise.
93     //------------------------------------------------------------------
94     explicit operator bool() const
95     {
96         return m_current_value;
97     }
98     
99     const bool &
100     operator = (bool b)
101     {
102         m_current_value = b;
103         return m_current_value;
104     }
105
106     bool
107     GetCurrentValue() const
108     {
109         return m_current_value;
110     }
111     
112     bool
113     GetDefaultValue() const
114     {
115         return m_default_value;
116     }
117     
118     void
119     SetCurrentValue (bool value)
120     {
121         m_current_value = value;
122     }
123     
124     void
125     SetDefaultValue (bool value)
126     {
127         m_default_value = value;
128     }
129     
130     lldb::OptionValueSP
131     DeepCopy() const override;
132
133 protected:
134     bool m_current_value;
135     bool m_default_value;
136 };
137
138 } // namespace lldb_private
139
140 #endif // liblldb_OptionValueBoolean_h_