• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
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)
OptionValue()22       : OptionValue(), m_type_mask(type_mask), m_values(),
23         m_raw_value_dump(raw_value_dump) {}
24 
~OptionValueDictionary()25   ~OptionValueDictionary() override {}
26 
27   // Virtual subclass pure virtual overrides
28 
GetType()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 
Clear()38   void Clear() override {
39     m_values.clear();
40     m_value_was_set = false;
41   }
42 
43   lldb::OptionValueSP DeepCopy() const override;
44 
IsAggregateValue()45   bool IsAggregateValue() const override { return true; }
46 
IsHomogenous()47   bool IsHomogenous() const {
48     return ConvertTypeMaskToType(m_type_mask) != eTypeInvalid;
49   }
50 
51   // Subclass specific functions
52 
GetNumValues()53   size_t GetNumValues() const { return m_values.size(); }
54 
55   lldb::OptionValueSP GetValueForKey(ConstString key) const;
56 
57   lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
58                                   llvm::StringRef name, bool will_modify,
59                                   Status &error) const override;
60 
61   Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op,
62                      llvm::StringRef name, llvm::StringRef value) override;
63 
64   bool SetValueForKey(ConstString key,
65                       const lldb::OptionValueSP &value_sp,
66                       bool can_replace = true);
67 
68   bool DeleteValueForKey(ConstString key);
69 
70   size_t GetArgs(Args &args) const;
71 
72   Status SetArgs(const Args &args, VarSetOperationType op);
73 
74 protected:
75   typedef std::map<ConstString, lldb::OptionValueSP> collection;
76   uint32_t m_type_mask;
77   collection m_values;
78   bool m_raw_value_dump;
79 };
80 
81 } // namespace lldb_private
82 
83 #endif // LLDB_INTERPRETER_OPTIONVALUEDICTIONARY_H
84