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