1 //===-- OptionValueEnumeration.h --------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef liblldb_OptionValueEnumeration_h_ 11 #define liblldb_OptionValueEnumeration_h_ 12 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" 20 21 namespace lldb_private { 22 23 class OptionValueEnumeration : public OptionValue { 24 public: 25 typedef int64_t enum_type; 26 struct EnumeratorInfo { 27 enum_type value; 28 const char *description; 29 }; 30 typedef UniqueCStringMap<EnumeratorInfo> EnumerationMap; 31 typedef EnumerationMap::Entry EnumerationMapEntry; 32 33 OptionValueEnumeration(const OptionEnumValues &enumerators, enum_type value); 34 35 ~OptionValueEnumeration() override; 36 37 //--------------------------------------------------------------------- 38 // Virtual subclass pure virtual overrides 39 //--------------------------------------------------------------------- 40 GetType()41 OptionValue::Type GetType() const override { return eTypeEnum; } 42 43 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, 44 uint32_t dump_mask) override; 45 46 Status 47 SetValueFromString(llvm::StringRef value, 48 VarSetOperationType op = eVarSetOperationAssign) override; 49 Status 50 SetValueFromString(const char *, 51 VarSetOperationType = eVarSetOperationAssign) = delete; 52 Clear()53 bool Clear() override { 54 m_current_value = m_default_value; 55 m_value_was_set = false; 56 return true; 57 } 58 59 lldb::OptionValueSP DeepCopy() const override; 60 61 size_t AutoComplete(CommandInterpreter &interpreter, 62 CompletionRequest &request) override; 63 64 //--------------------------------------------------------------------- 65 // Subclass specific functions 66 //--------------------------------------------------------------------- 67 68 enum_type operator=(enum_type value) { 69 m_current_value = value; 70 return m_current_value; 71 } 72 GetCurrentValue()73 enum_type GetCurrentValue() const { return m_current_value; } 74 GetDefaultValue()75 enum_type GetDefaultValue() const { return m_default_value; } 76 SetCurrentValue(enum_type value)77 void SetCurrentValue(enum_type value) { m_current_value = value; } 78 SetDefaultValue(enum_type value)79 void SetDefaultValue(enum_type value) { m_default_value = value; } 80 81 protected: 82 void SetEnumerations(const OptionEnumValues &enumerators); 83 84 enum_type m_current_value; 85 enum_type m_default_value; 86 EnumerationMap m_enumerations; 87 }; 88 89 } // namespace lldb_private 90 91 #endif // liblldb_OptionValueEnumeration_h_ 92