1 //===-- OptionValueArch.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_OPTIONVALUEARCH_H 10 #define LLDB_INTERPRETER_OPTIONVALUEARCH_H 11 12 #include "lldb/Interpreter/OptionValue.h" 13 #include "lldb/Utility/ArchSpec.h" 14 #include "lldb/Utility/CompletionRequest.h" 15 16 namespace lldb_private { 17 18 class OptionValueArch : public OptionValue { 19 public: 20 OptionValueArch() : OptionValue(), m_current_value(), m_default_value() {} 21 22 OptionValueArch(const char *triple) 23 : OptionValue(), m_current_value(triple), m_default_value() { 24 m_default_value = m_current_value; 25 } 26 27 OptionValueArch(const ArchSpec &value) 28 : OptionValue(), m_current_value(value), m_default_value(value) {} 29 30 OptionValueArch(const ArchSpec ¤t_value, const ArchSpec &default_value) 31 : OptionValue(), m_current_value(current_value), 32 m_default_value(default_value) {} 33 34 ~OptionValueArch() override {} 35 36 // Virtual subclass pure virtual overrides 37 38 OptionValue::Type GetType() const override { return eTypeArch; } 39 40 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, 41 uint32_t dump_mask) override; 42 43 Status 44 SetValueFromString(llvm::StringRef value, 45 VarSetOperationType op = eVarSetOperationAssign) override; 46 Status 47 SetValueFromString(const char *, 48 VarSetOperationType = eVarSetOperationAssign) = delete; 49 50 void Clear() override { 51 m_current_value = m_default_value; 52 m_value_was_set = false; 53 } 54 55 lldb::OptionValueSP DeepCopy() const override; 56 57 void AutoComplete(CommandInterpreter &interpreter, 58 lldb_private::CompletionRequest &request) override; 59 60 // Subclass specific functions 61 62 ArchSpec &GetCurrentValue() { return m_current_value; } 63 64 const ArchSpec &GetCurrentValue() const { return m_current_value; } 65 66 const ArchSpec &GetDefaultValue() const { return m_default_value; } 67 68 void SetCurrentValue(const ArchSpec &value, bool set_value_was_set) { 69 m_current_value = value; 70 if (set_value_was_set) 71 m_value_was_set = true; 72 } 73 74 void SetDefaultValue(const ArchSpec &value) { m_default_value = value; } 75 76 protected: 77 ArchSpec m_current_value; 78 ArchSpec m_default_value; 79 }; 80 81 } // namespace lldb_private 82 83 #endif // LLDB_INTERPRETER_OPTIONVALUEARCH_H 84