1//===-- OptionValueDictionary.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_OptionValueDictionary_h_ 11#define liblldb_OptionValueDictionary_h_ 12 13// C Includes 14// C++ Includes 15#include <map> 16 17// Other libraries and framework includes 18// Project includes 19#include "lldb/Interpreter/OptionValue.h" 20 21namespace lldb_private { 22 23class OptionValueDictionary : public OptionValue 24{ 25public: 26 OptionValueDictionary (uint32_t type_mask = UINT32_MAX, bool raw_value_dump = true) : 27 OptionValue(), 28 m_type_mask (type_mask), 29 m_values (), 30 m_raw_value_dump (raw_value_dump) 31 { 32 } 33 34 virtual 35 ~OptionValueDictionary() 36 { 37 } 38 39 //--------------------------------------------------------------------- 40 // Virtual subclass pure virtual overrides 41 //--------------------------------------------------------------------- 42 43 virtual OptionValue::Type 44 GetType () const 45 { 46 return eTypeDictionary; 47 } 48 49 virtual void 50 DumpValue (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask); 51 52 virtual Error 53 SetValueFromCString (const char *value, 54 VarSetOperationType op = eVarSetOperationAssign); 55 56 virtual bool 57 Clear () 58 { 59 m_values.clear(); 60 m_value_was_set = false; 61 return true; 62 } 63 64 virtual lldb::OptionValueSP 65 DeepCopy () const; 66 67 virtual bool 68 IsAggregateValue () const 69 { 70 return true; 71 } 72 73 bool 74 IsHomogenous() const 75 { 76 return ConvertTypeMaskToType (m_type_mask) != eTypeInvalid; 77 } 78 79 //--------------------------------------------------------------------- 80 // Subclass specific functions 81 //--------------------------------------------------------------------- 82 83 size_t 84 GetNumValues() const 85 { 86 return m_values.size(); 87 } 88 89 lldb::OptionValueSP 90 GetValueForKey (const ConstString &key) const; 91 92 virtual lldb::OptionValueSP 93 GetSubValue (const ExecutionContext *exe_ctx, 94 const char *name, 95 bool will_modify, 96 Error &error) const; 97 98 virtual Error 99 SetSubValue (const ExecutionContext *exe_ctx, 100 VarSetOperationType op, 101 const char *name, 102 const char *value); 103 104 //--------------------------------------------------------------------- 105 // String value getters and setters 106 //--------------------------------------------------------------------- 107 const char * 108 GetStringValueForKey (const ConstString &key); 109 110 bool 111 SetStringValueForKey (const ConstString &key, 112 const char *value, 113 bool can_replace = true); 114 115 116 bool 117 SetValueForKey (const ConstString &key, 118 const lldb::OptionValueSP &value_sp, 119 bool can_replace = true); 120 121 bool 122 DeleteValueForKey (const ConstString &key); 123 124 size_t 125 GetArgs (Args &args) const; 126 127 Error 128 SetArgs (const Args &args, VarSetOperationType op); 129 130protected: 131 typedef std::map<ConstString, lldb::OptionValueSP> collection; 132 uint32_t m_type_mask; 133 collection m_values; 134 bool m_raw_value_dump; 135}; 136 137} // namespace lldb_private 138 139#endif // liblldb_OptionValueDictionary_h_ 140