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 
9 #ifndef LLDB_INTERPRETER_OPTIONVALUEFORMAT_H
10 #define LLDB_INTERPRETER_OPTIONVALUEFORMAT_H
11 
12 #include "lldb/Interpreter/OptionValue.h"
13 
14 namespace lldb_private {
15 
16 class OptionValueFormat : public OptionValue {
17 public:
18   OptionValueFormat(lldb::Format value)
19       : OptionValue(), m_current_value(value), m_default_value(value) {}
20 
21   OptionValueFormat(lldb::Format current_value, lldb::Format default_value)
22       : OptionValue(), m_current_value(current_value),
23         m_default_value(default_value) {}
24 
25   ~OptionValueFormat() override {}
26 
27   // Virtual subclass pure virtual overrides
28 
29   OptionValue::Type GetType() const override { return eTypeFormat; }
30 
31   void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
32                  uint32_t dump_mask) override;
33 
34   Status
35   SetValueFromString(llvm::StringRef value,
36                      VarSetOperationType op = eVarSetOperationAssign) override;
37   Status
38   SetValueFromString(const char *,
39                      VarSetOperationType = eVarSetOperationAssign) = delete;
40 
41   void Clear() override {
42     m_current_value = m_default_value;
43     m_value_was_set = false;
44   }
45 
46   lldb::OptionValueSP DeepCopy() const override;
47 
48   // Subclass specific functions
49 
50   lldb::Format GetCurrentValue() const { return m_current_value; }
51 
52   lldb::Format GetDefaultValue() const { return m_default_value; }
53 
54   void SetCurrentValue(lldb::Format value) { m_current_value = value; }
55 
56   void SetDefaultValue(lldb::Format value) { m_default_value = value; }
57 
58 protected:
59   lldb::Format m_current_value;
60   lldb::Format m_default_value;
61 };
62 
63 } // namespace lldb_private
64 
65 #endif // LLDB_INTERPRETER_OPTIONVALUEFORMAT_H
66