/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Interpreter/OptionValueBoolean.h
Line | Count | Source |
1 | | //===-- OptionValueBoolean.h ------------------------------------*- C++ -*-===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | |
9 | | #ifndef LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H |
10 | | #define LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H |
11 | | |
12 | | #include "lldb/Interpreter/OptionValue.h" |
13 | | |
14 | | namespace lldb_private { |
15 | | |
16 | | class OptionValueBoolean : public Cloneable<OptionValueBoolean, OptionValue> { |
17 | | public: |
18 | | OptionValueBoolean(bool value) |
19 | 394k | : m_current_value(value), m_default_value(value) {} |
20 | | OptionValueBoolean(bool current_value, bool default_value) |
21 | 110k | : m_current_value(current_value), m_default_value(default_value) {} |
22 | | |
23 | 546k | ~OptionValueBoolean() override = default; |
24 | | |
25 | | // Virtual subclass pure virtual overrides |
26 | | |
27 | 7.33M | OptionValue::Type GetType() const override { return eTypeBoolean; } |
28 | | |
29 | | void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, |
30 | | uint32_t dump_mask) override; |
31 | | |
32 | 71 | llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override { |
33 | 71 | return m_current_value; |
34 | 71 | } |
35 | | |
36 | | Status |
37 | | SetValueFromString(llvm::StringRef value, |
38 | | VarSetOperationType op = eVarSetOperationAssign) override; |
39 | | |
40 | 253k | void Clear() override { |
41 | 253k | m_current_value = m_default_value; |
42 | 253k | m_value_was_set = false; |
43 | 253k | } |
44 | | |
45 | | void AutoComplete(CommandInterpreter &interpreter, |
46 | | CompletionRequest &request) override; |
47 | | |
48 | | // Subclass specific functions |
49 | | |
50 | | /// Convert to bool operator. |
51 | | /// |
52 | | /// This allows code to check a OptionValueBoolean in conditions. |
53 | | /// |
54 | | /// \code |
55 | | /// OptionValueBoolean bool_value(...); |
56 | | /// if (bool_value) |
57 | | /// { ... |
58 | | /// \endcode |
59 | | /// |
60 | | /// \return |
61 | | /// /b True this object contains a valid namespace decl, \b |
62 | | /// false otherwise. |
63 | 8.76k | explicit operator bool() const { return m_current_value; } |
64 | | |
65 | 375 | const bool &operator=(bool b) { |
66 | 375 | m_current_value = b; |
67 | 375 | return m_current_value; |
68 | 375 | } |
69 | | |
70 | 7.33M | bool GetCurrentValue() const { return m_current_value; } |
71 | | |
72 | 45 | bool GetDefaultValue() const { return m_default_value; } |
73 | | |
74 | 6.72k | void SetCurrentValue(bool value) { m_current_value = value; } |
75 | | |
76 | 2 | void SetDefaultValue(bool value) { m_default_value = value; } |
77 | | |
78 | | protected: |
79 | | bool m_current_value; |
80 | | bool m_default_value; |
81 | | }; |
82 | | |
83 | | } // namespace lldb_private |
84 | | |
85 | | #endif // LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H |