1 //===-- OptionValueEnumeration.h --------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_OptionValueEnumeration_h_
11 #define liblldb_OptionValueEnumeration_h_
13 #include "lldb/Core/UniqueCStringMap.h"
14 #include "lldb/Interpreter/OptionValue.h"
15 #include "lldb/Utility/ConstString.h"
16 #include "lldb/Utility/Status.h"
17 #include "lldb/Utility/Stream.h"
18 #include "lldb/Utility/StreamString.h"
19 #include "lldb/lldb-private-types.h"
21 namespace lldb_private {
23 class OptionValueEnumeration : public OptionValue {
25 typedef int64_t enum_type;
26 struct EnumeratorInfo {
28 const char *description;
30 typedef UniqueCStringMap<EnumeratorInfo> EnumerationMap;
31 typedef EnumerationMap::Entry EnumerationMapEntry;
33 OptionValueEnumeration(const OptionEnumValueElement *enumerators,
36 ~OptionValueEnumeration() override;
38 //---------------------------------------------------------------------
39 // Virtual subclass pure virtual overrides
40 //---------------------------------------------------------------------
42 OptionValue::Type GetType() const override { return eTypeEnum; }
44 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
45 uint32_t dump_mask) override;
48 SetValueFromString(llvm::StringRef value,
49 VarSetOperationType op = eVarSetOperationAssign) override;
51 SetValueFromString(const char *,
52 VarSetOperationType = eVarSetOperationAssign) = delete;
54 bool Clear() override {
55 m_current_value = m_default_value;
56 m_value_was_set = false;
60 lldb::OptionValueSP DeepCopy() const override;
62 size_t AutoComplete(CommandInterpreter &interpreter, llvm::StringRef s,
63 int match_start_point, int max_return_elements,
64 bool &word_complete, StringList &matches) override;
66 //---------------------------------------------------------------------
67 // Subclass specific functions
68 //---------------------------------------------------------------------
70 enum_type operator=(enum_type value) {
71 m_current_value = value;
72 return m_current_value;
75 enum_type GetCurrentValue() const { return m_current_value; }
77 enum_type GetDefaultValue() const { return m_default_value; }
79 void SetCurrentValue(enum_type value) { m_current_value = value; }
81 void SetDefaultValue(enum_type value) { m_default_value = value; }
84 void SetEnumerations(const OptionEnumValueElement *enumerators);
86 enum_type m_current_value;
87 enum_type m_default_value;
88 EnumerationMap m_enumerations;
91 } // namespace lldb_private
93 #endif // liblldb_OptionValueEnumeration_h_