Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:50

0001 //===-- OptionValueDictionary.h ---------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_INTERPRETER_OPTIONVALUEDICTIONARY_H
0010 #define LLDB_INTERPRETER_OPTIONVALUEDICTIONARY_H
0011 
0012 #include "lldb/Interpreter/OptionValue.h"
0013 #include "lldb/lldb-private-types.h"
0014 
0015 #include "llvm/ADT/StringMap.h"
0016 
0017 namespace lldb_private {
0018 
0019 class OptionValueDictionary
0020     : public Cloneable<OptionValueDictionary, OptionValue> {
0021 public:
0022   OptionValueDictionary(uint32_t type_mask = UINT32_MAX,
0023                         OptionEnumValues enum_values = OptionEnumValues(),
0024                         bool raw_value_dump = true)
0025       : m_type_mask(type_mask), m_enum_values(enum_values),
0026         m_raw_value_dump(raw_value_dump) {}
0027 
0028   ~OptionValueDictionary() override = default;
0029 
0030   // Virtual subclass pure virtual overrides
0031 
0032   OptionValue::Type GetType() const override { return eTypeDictionary; }
0033 
0034   void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
0035                  uint32_t dump_mask) override;
0036 
0037   llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override;
0038 
0039   Status
0040   SetValueFromString(llvm::StringRef value,
0041                      VarSetOperationType op = eVarSetOperationAssign) override;
0042 
0043   void Clear() override {
0044     m_values.clear();
0045     m_value_was_set = false;
0046   }
0047 
0048   lldb::OptionValueSP
0049   DeepCopy(const lldb::OptionValueSP &new_parent) const override;
0050 
0051   bool IsAggregateValue() const override { return true; }
0052 
0053   bool IsHomogenous() const {
0054     return ConvertTypeMaskToType(m_type_mask) != eTypeInvalid;
0055   }
0056 
0057   // Subclass specific functions
0058 
0059   size_t GetNumValues() const { return m_values.size(); }
0060 
0061   lldb::OptionValueSP GetValueForKey(llvm::StringRef key) const;
0062 
0063   lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
0064                                   llvm::StringRef name,
0065                                   Status &error) const override;
0066 
0067   Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op,
0068                      llvm::StringRef name, llvm::StringRef value) override;
0069 
0070   bool SetValueForKey(llvm::StringRef key, const lldb::OptionValueSP &value_sp,
0071                       bool can_replace = true);
0072 
0073   bool DeleteValueForKey(llvm::StringRef key);
0074 
0075   size_t GetArgs(Args &args) const;
0076 
0077   Status SetArgs(const Args &args, VarSetOperationType op);
0078 
0079 protected:
0080   uint32_t m_type_mask;
0081   OptionEnumValues m_enum_values;
0082   llvm::StringMap<lldb::OptionValueSP> m_values;
0083   bool m_raw_value_dump;
0084 };
0085 
0086 } // namespace lldb_private
0087 
0088 #endif // LLDB_INTERPRETER_OPTIONVALUEDICTIONARY_H