File indexing completed on 2024-12-22 05:05:19

0001 // SPDX-FileCopyrightText: 2004 Marc Mutz <mutz@kde.org>,
0002 // SPDX-FileCopyrightText: 2004 Ingo Kloecker <kloecker@kde.org>
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004 
0005 #pragma once
0006 
0007 #include <QByteArray>
0008 #include <map>
0009 #include <memory>
0010 
0011 namespace MimeTreeParser
0012 {
0013 
0014 namespace Interface
0015 {
0016 class BodyPartFormatter;
0017 }
0018 
0019 struct ltstr {
0020     bool operator()(const char *s1, const char *s2) const
0021     {
0022         return qstricmp(s1, s2) < 0;
0023     }
0024 };
0025 
0026 typedef std::multimap<const char *, Interface::BodyPartFormatter *, ltstr> SubtypeRegistry;
0027 typedef std::map<const char *, MimeTreeParser::SubtypeRegistry, MimeTreeParser::ltstr> TypeRegistry;
0028 
0029 class BodyPartFormatterBaseFactoryPrivate;
0030 
0031 class BodyPartFormatterBaseFactory
0032 {
0033 public:
0034     BodyPartFormatterBaseFactory();
0035     ~BodyPartFormatterBaseFactory();
0036 
0037     const SubtypeRegistry &subtypeRegistry(const char *type) const;
0038 
0039 protected:
0040     void insert(const char *type, const char *subtype, Interface::BodyPartFormatter *formatter);
0041 
0042 private:
0043     static BodyPartFormatterBaseFactory *mSelf;
0044 
0045     std::unique_ptr<BodyPartFormatterBaseFactoryPrivate> d;
0046     friend class BodyPartFormatterBaseFactoryPrivate;
0047 
0048 private:
0049     // disabled
0050     const BodyPartFormatterBaseFactory &operator=(const BodyPartFormatterBaseFactory &);
0051     BodyPartFormatterBaseFactory(const BodyPartFormatterBaseFactory &);
0052 };
0053 
0054 }