1 //===-- NSDictionary.h ---------------------------------------------------*- C++ 2 //-*-===// 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef liblldb_NSDictionary_h_ 11 #define liblldb_NSDictionary_h_ 12 13 #include "lldb/Core/ValueObject.h" 14 #include "lldb/DataFormatters/TypeSummary.h" 15 #include "lldb/DataFormatters/TypeSynthetic.h" 16 #include "lldb/Utility/ConstString.h" 17 #include "lldb/Utility/Stream.h" 18 19 #include <map> 20 #include <memory> 21 22 namespace lldb_private { 23 namespace formatters { 24 template <bool name_entries> 25 bool NSDictionarySummaryProvider(ValueObject &valobj, Stream &stream, 26 const TypeSummaryOptions &options); 27 28 extern template bool 29 NSDictionarySummaryProvider<true>(ValueObject &, Stream &, 30 const TypeSummaryOptions &); 31 32 extern template bool 33 NSDictionarySummaryProvider<false>(ValueObject &, Stream &, 34 const TypeSummaryOptions &); 35 36 SyntheticChildrenFrontEnd * 37 NSDictionarySyntheticFrontEndCreator(CXXSyntheticChildren *, 38 lldb::ValueObjectSP); 39 40 class NSDictionary_Additionals { 41 public: 42 class AdditionalFormatterMatching { 43 public: 44 class Matcher { 45 public: 46 virtual ~Matcher() = default; 47 virtual bool Match(ConstString class_name) = 0; 48 49 typedef std::unique_ptr<Matcher> UP; 50 }; 51 class Prefix : public Matcher { 52 public: 53 Prefix(ConstString p); 54 ~Prefix() override = default; 55 bool Match(ConstString class_name) override; 56 57 private: 58 ConstString m_prefix; 59 }; 60 class Full : public Matcher { 61 public: 62 Full(ConstString n); 63 ~Full() override = default; 64 bool Match(ConstString class_name) override; 65 66 private: 67 ConstString m_name; 68 }; 69 typedef Matcher::UP MatcherUP; 70 71 MatcherUP GetFullMatch(ConstString n) { return std::make_unique<Full>(n); } 72 73 MatcherUP GetPrefixMatch(ConstString p) { 74 return std::make_unique<Prefix>(p); 75 } 76 }; 77 78 template <typename FormatterType> 79 using AdditionalFormatter = 80 std::pair<AdditionalFormatterMatching::MatcherUP, FormatterType>; 81 82 template <typename FormatterType> 83 using AdditionalFormatters = std::vector<AdditionalFormatter<FormatterType>>; 84 85 static AdditionalFormatters<CXXFunctionSummaryFormat::Callback> & 86 GetAdditionalSummaries(); 87 88 static AdditionalFormatters<CXXSyntheticChildren::CreateFrontEndCallback> & 89 GetAdditionalSynthetics(); 90 }; 91 } // namespace formatters 92 } // namespace lldb_private 93 94 #endif // liblldb_NSDictionary_h_ 95