1 //===-- OptionValueDictionary.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 liblldb_OptionValueDictionary_h_ 10 #define liblldb_OptionValueDictionary_h_ 11 12 #include <map> 13 14 #include "lldb/Interpreter/OptionValue.h" 15 16 namespace lldb_private { 17 18 class OptionValueDictionary : public OptionValue { 19 public: 20 OptionValueDictionary(uint32_t type_mask = UINT32_MAX, 21 bool raw_value_dump = true) 22 : OptionValue(), m_type_mask(type_mask), m_values(), 23 m_raw_value_dump(raw_value_dump) {} 24 25 ~OptionValueDictionary() override {} 26 27 // Virtual subclass pure virtual overrides 28 29 OptionValue::Type GetType() const override { return eTypeDictionary; } 30 31 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, 32 uint32_t dump_mask) override; 33 34 Status 35 SetValueFromString(llvm::StringRef value, 36 VarSetOperationType op = eVarSetOperationAssign) override; 37 38 bool Clear() override { 39 m_values.clear(); 40 m_value_was_set = false; 41 return true; 42 } 43 44 lldb::OptionValueSP DeepCopy() const override; 45 46 bool IsAggregateValue() const override { return true; } 47 48 bool IsHomogenous() const { 49 return ConvertTypeMaskToType(m_type_mask) != eTypeInvalid; 50 } 51 52 // Subclass specific functions 53 54 size_t GetNumValues() const { return m_values.size(); } 55 56 lldb::OptionValueSP GetValueForKey(ConstString key) const; 57 58 lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx, 59 llvm::StringRef name, bool will_modify, 60 Status &error) const override; 61 62 Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op, 63 llvm::StringRef name, llvm::StringRef value) override; 64 65 bool SetValueForKey(ConstString key, 66 const lldb::OptionValueSP &value_sp, 67 bool can_replace = true); 68 69 bool DeleteValueForKey(ConstString key); 70 71 size_t GetArgs(Args &args) const; 72 73 Status SetArgs(const Args &args, VarSetOperationType op); 74 75 protected: 76 typedef std::map<ConstString, lldb::OptionValueSP> collection; 77 uint32_t m_type_mask; 78 collection m_values; 79 bool m_raw_value_dump; 80 }; 81 82 } // namespace lldb_private 83 84 #endif // liblldb_OptionValueDictionary_h_ 85