Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:50

0001 //===-- OptionValueBoolean.h ------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H
0010 #define LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H
0011 
0012 #include "lldb/Interpreter/OptionValue.h"
0013 
0014 namespace lldb_private {
0015 
0016 class OptionValueBoolean : public Cloneable<OptionValueBoolean, OptionValue> {
0017 public:
0018   OptionValueBoolean(bool value)
0019       : m_current_value(value), m_default_value(value) {}
0020   OptionValueBoolean(bool current_value, bool default_value)
0021       : m_current_value(current_value), m_default_value(default_value) {}
0022 
0023   ~OptionValueBoolean() override = default;
0024 
0025   // Virtual subclass pure virtual overrides
0026 
0027   OptionValue::Type GetType() const override { return eTypeBoolean; }
0028 
0029   void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
0030                  uint32_t dump_mask) override;
0031 
0032   llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
0033     return m_current_value;
0034   }
0035 
0036   Status
0037   SetValueFromString(llvm::StringRef value,
0038                      VarSetOperationType op = eVarSetOperationAssign) override;
0039 
0040   void Clear() override {
0041     m_current_value = m_default_value;
0042     m_value_was_set = false;
0043   }
0044 
0045   void AutoComplete(CommandInterpreter &interpreter,
0046                     CompletionRequest &request) override;
0047 
0048   // Subclass specific functions
0049 
0050   /// Convert to bool operator.
0051   ///
0052   /// This allows code to check a OptionValueBoolean in conditions.
0053   ///
0054   /// \code
0055   /// OptionValueBoolean bool_value(...);
0056   /// if (bool_value)
0057   /// { ...
0058   /// \endcode
0059   ///
0060   /// \return
0061   ///     /b True this object contains a valid namespace decl, \b
0062   ///     false otherwise.
0063   explicit operator bool() const { return m_current_value; }
0064 
0065   const bool &operator=(bool b) {
0066     m_current_value = b;
0067     return m_current_value;
0068   }
0069 
0070   bool GetCurrentValue() const { return m_current_value; }
0071 
0072   bool GetDefaultValue() const { return m_default_value; }
0073 
0074   void SetCurrentValue(bool value) { m_current_value = value; }
0075 
0076   void SetDefaultValue(bool value) { m_default_value = value; }
0077 
0078 protected:
0079   bool m_current_value;
0080   bool m_default_value;
0081 };
0082 
0083 } // namespace lldb_private
0084 
0085 #endif // LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H