Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame^] | 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 liblldb_OptionValueArch_h_ |
| 10 | #define liblldb_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 | bool Clear() override { |
| 51 | m_current_value = m_default_value; |
| 52 | m_value_was_set = false; |
| 53 | return true; |
| 54 | } |
| 55 | |
| 56 | lldb::OptionValueSP DeepCopy() const override; |
| 57 | |
| 58 | size_t AutoComplete(CommandInterpreter &interpreter, |
| 59 | lldb_private::CompletionRequest &request) override; |
| 60 | |
| 61 | // Subclass specific functions |
| 62 | |
| 63 | ArchSpec &GetCurrentValue() { return m_current_value; } |
| 64 | |
| 65 | const ArchSpec &GetCurrentValue() const { return m_current_value; } |
| 66 | |
| 67 | const ArchSpec &GetDefaultValue() const { return m_default_value; } |
| 68 | |
| 69 | void SetCurrentValue(const ArchSpec &value, bool set_value_was_set) { |
| 70 | m_current_value = value; |
| 71 | if (set_value_was_set) |
| 72 | m_value_was_set = true; |
| 73 | } |
| 74 | |
| 75 | void SetDefaultValue(const ArchSpec &value) { m_default_value = value; } |
| 76 | |
| 77 | protected: |
| 78 | ArchSpec m_current_value; |
| 79 | ArchSpec m_default_value; |
| 80 | }; |
| 81 | |
| 82 | } // namespace lldb_private |
| 83 | |
| 84 | #endif // liblldb_OptionValueArch_h_ |