OptionValueEnumeration.h revision 73844aa19a7360b662e2be710fc3c969d6c86606
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// C Includes 14// C++ Includes 15// Other libraries and framework includes 16// Project includes 17#include "lldb/Core/ConstString.h" 18#include "lldb/Core/Error.h" 19#include "lldb/Core/Stream.h" 20#include "lldb/Core/StreamString.h" 21#include "lldb/Core/UniqueCStringMap.h" 22#include "lldb/Interpreter/OptionValue.h" 23 24namespace lldb_private { 25 26 27class OptionValueEnumeration : public OptionValue 28{ 29public: 30 typedef int64_t enum_type; 31 struct EnumeratorInfo 32 { 33 enum_type value; 34 const char *description; 35 }; 36 typedef UniqueCStringMap<EnumeratorInfo> EnumerationMap; 37 typedef typename EnumerationMap::Entry EnumerationMapEntry; 38 39 OptionValueEnumeration (const OptionEnumValueElement *enumerators, enum_type value); 40 41 virtual 42 ~OptionValueEnumeration(); 43 44 //--------------------------------------------------------------------- 45 // Virtual subclass pure virtual overrides 46 //--------------------------------------------------------------------- 47 48 virtual OptionValue::Type 49 GetType () const 50 { 51 return eTypeEnum; 52 } 53 54 virtual void 55 DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); 56 57 virtual Error 58 SetValueFromCString (const char *value, 59 VarSetOperationType op = eVarSetOperationAssign); 60 61 virtual bool 62 Clear () 63 { 64 m_current_value = m_default_value; 65 m_value_was_set = false; 66 return true; 67 } 68 69 virtual lldb::OptionValueSP 70 DeepCopy () const; 71 72 //--------------------------------------------------------------------- 73 // Subclass specific functions 74 //--------------------------------------------------------------------- 75 76 enum_type 77 operator = (enum_type value) 78 { 79 m_current_value = value; 80 return m_current_value; 81 } 82 83 enum_type 84 GetCurrentValue() const 85 { 86 return m_current_value; 87 } 88 89 enum_type 90 GetDefaultValue() const 91 { 92 return m_default_value; 93 } 94 95 void 96 SetCurrentValue (enum_type value) 97 { 98 m_current_value = value; 99 } 100 101 void 102 SetDefaultValue (enum_type value) 103 { 104 m_default_value = value; 105 } 106 107protected: 108 void 109 SetEnumerations (const OptionEnumValueElement *enumerators); 110 111 enum_type m_current_value; 112 enum_type m_default_value; 113 EnumerationMap m_enumerations; 114}; 115 116} // namespace lldb_private 117 118#endif // liblldb_OptionValueEnumeration_h_ 119