1 //===-- OptionValueFormatEntity.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_OPTIONVALUEFORMATENTITY_H
10 #define LLDB_INTERPRETER_OPTIONVALUEFORMATENTITY_H
11 
12 #include "lldb/Core/FormatEntity.h"
13 #include "lldb/Interpreter/OptionValue.h"
14 
15 namespace lldb_private {
16 
17 class OptionValueFormatEntity
18     : public Cloneable<OptionValueFormatEntity, OptionValue> {
19 public:
20   OptionValueFormatEntity(const char *default_format);
21 
22   ~OptionValueFormatEntity() override = default;
23 
24   // Virtual subclass pure virtual overrides
25 
GetType()26   OptionValue::Type GetType() const override { return eTypeFormatEntity; }
27 
28   void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
29                  uint32_t dump_mask) override;
30 
31   llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override;
32 
33   Status
34   SetValueFromString(llvm::StringRef value,
35                      VarSetOperationType op = eVarSetOperationAssign) override;
36 
37   void Clear() override;
38 
39   void AutoComplete(CommandInterpreter &interpreter,
40                     CompletionRequest &request) override;
41 
42   // Subclass specific functions
43 
GetCurrentValue()44   FormatEntity::Entry &GetCurrentValue() { return m_current_entry; }
45 
GetCurrentValue()46   const FormatEntity::Entry &GetCurrentValue() const { return m_current_entry; }
47 
SetCurrentValue(const FormatEntity::Entry & value)48   void SetCurrentValue(const FormatEntity::Entry &value) {
49     m_current_entry = value;
50   }
51 
GetDefaultValue()52   FormatEntity::Entry &GetDefaultValue() { return m_default_entry; }
53 
GetDefaultValue()54   const FormatEntity::Entry &GetDefaultValue() const { return m_default_entry; }
55 
56 protected:
57   std::string m_current_format;
58   std::string m_default_format;
59   FormatEntity::Entry m_current_entry;
60   FormatEntity::Entry m_default_entry;
61 };
62 
63 } // namespace lldb_private
64 
65 #endif // LLDB_INTERPRETER_OPTIONVALUEFORMATENTITY_H
66