1 //===-- OptionValueDictionary.h ---------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_OptionValueDictionary_h_
10 #define liblldb_OptionValueDictionary_h_
14 #include "lldb/Interpreter/OptionValue.h"
16 namespace lldb_private {
18 class OptionValueDictionary : public OptionValue {
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) {}
25 ~OptionValueDictionary() override {}
27 // Virtual subclass pure virtual overrides
29 OptionValue::Type GetType() const override { return eTypeDictionary; }
31 void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
32 uint32_t dump_mask) override;
35 SetValueFromString(llvm::StringRef value,
36 VarSetOperationType op = eVarSetOperationAssign) override;
38 bool Clear() override {
40 m_value_was_set = false;
44 lldb::OptionValueSP DeepCopy() const override;
46 bool IsAggregateValue() const override { return true; }
48 bool IsHomogenous() const {
49 return ConvertTypeMaskToType(m_type_mask) != eTypeInvalid;
52 // Subclass specific functions
54 size_t GetNumValues() const { return m_values.size(); }
56 lldb::OptionValueSP GetValueForKey(ConstString key) const;
58 lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
59 llvm::StringRef name, bool will_modify,
60 Status &error) const override;
62 Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op,
63 llvm::StringRef name, llvm::StringRef value) override;
65 bool SetValueForKey(ConstString key,
66 const lldb::OptionValueSP &value_sp,
67 bool can_replace = true);
69 bool DeleteValueForKey(ConstString key);
71 size_t GetArgs(Args &args) const;
73 Status SetArgs(const Args &args, VarSetOperationType op);
76 typedef std::map<ConstString, lldb::OptionValueSP> collection;
79 bool m_raw_value_dump;
82 } // namespace lldb_private
84 #endif // liblldb_OptionValueDictionary_h_