OptionValueFormat.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //===-- OptionValueFormat.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. #ifndef LLDB_INTERPRETER_OPTIONVALUEFORMAT_H
  9. #define LLDB_INTERPRETER_OPTIONVALUEFORMAT_H
  10. #include "lldb/Interpreter/OptionValue.h"
  11. namespace lldb_private {
  12. class OptionValueFormat
  13. : public Cloneable<OptionValueFormat, OptionValue> {
  14. public:
  15. OptionValueFormat(lldb::Format value)
  16. : m_current_value(value), m_default_value(value) {}
  17. OptionValueFormat(lldb::Format current_value, lldb::Format default_value)
  18. : m_current_value(current_value), m_default_value(default_value) {}
  19. ~OptionValueFormat() override = default;
  20. // Virtual subclass pure virtual overrides
  21. OptionValue::Type GetType() const override { return eTypeFormat; }
  22. void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
  23. uint32_t dump_mask) override;
  24. Status
  25. SetValueFromString(llvm::StringRef value,
  26. VarSetOperationType op = eVarSetOperationAssign) override;
  27. void Clear() override {
  28. m_current_value = m_default_value;
  29. m_value_was_set = false;
  30. }
  31. // Subclass specific functions
  32. lldb::Format GetCurrentValue() const { return m_current_value; }
  33. lldb::Format GetDefaultValue() const { return m_default_value; }
  34. void SetCurrentValue(lldb::Format value) { m_current_value = value; }
  35. void SetDefaultValue(lldb::Format value) { m_default_value = value; }
  36. protected:
  37. lldb::Format m_current_value;
  38. lldb::Format m_default_value;
  39. };
  40. } // namespace lldb_private
  41. #endif // LLDB_INTERPRETER_OPTIONVALUEFORMAT_H