Warning, file /pim/kmime/src/kmime_headerfactory.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     kmime_header_factory.cpp
0003 
0004     KMime, the KDE Internet mail/usenet news message library.
0005     SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
0006 
0007     SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 
0010 /**
0011   @file
0012   This file is part of the API for handling MIME data and
0013   defines the HeaderFactory class.
0014 
0015   @brief
0016   Defines the HeaderFactory class.
0017 
0018   @authors Constantin Berzan \<exit3219@gmail.com\>
0019 */
0020 
0021 #include "kmime_headerfactory_p.h"
0022 #include "kmime_headers.h"
0023 
0024 #include <algorithm>
0025 
0026 using namespace KMime;
0027 using namespace KMime::Headers;
0028 
0029 #define mk_header(hdr) \
0030     if (qstrnicmp(type, hdr ::staticType(), std::max(typeLen, strlen(hdr::staticType()))) == 0) \
0031         return new hdr;
0032 
0033 Headers::Base *HeaderFactory::createHeader(const char *type, size_t typeLen)
0034 {
0035     Q_ASSERT(type && *type);
0036     switch (*type) {
0037         case 'b':
0038         case 'B':
0039             mk_header(Bcc);
0040             break;
0041         case 'c':
0042         case 'C':
0043             mk_header(Cc);
0044             mk_header(ContentDescription);
0045             mk_header(ContentDisposition);
0046             mk_header(ContentID);
0047             mk_header(ContentLocation);
0048             mk_header(ContentTransferEncoding);
0049             mk_header(ContentType);
0050             mk_header(Control);
0051             break;
0052         case 'd':
0053         case 'D':
0054             mk_header(Date);
0055             break;
0056         case 'f':
0057         case 'F':
0058             mk_header(FollowUpTo);
0059             mk_header(From);
0060             break;
0061         case 'i':
0062         case 'I':
0063             mk_header(InReplyTo);
0064             break;
0065         case 'k':
0066         case 'K':
0067             mk_header(Keywords);
0068             break;
0069         case 'l':
0070         case 'L':
0071             mk_header(Lines);
0072             break;
0073         case 'm':
0074         case 'M':
0075             mk_header(MailCopiesTo);
0076             mk_header(MessageID);
0077             mk_header(MIMEVersion);
0078             break;
0079         case 'n':
0080         case 'N':
0081             mk_header(Newsgroups);
0082             break;
0083         case 'o':
0084         case 'O':
0085             mk_header(Organization);
0086             break;
0087         case 'r':
0088         case 'R':
0089             mk_header(References);
0090             mk_header(ReplyTo);
0091             mk_header(ReturnPath);
0092             break;
0093         case 's':
0094         case 'S':
0095             mk_header(Sender);
0096             mk_header(Subject);
0097             mk_header(Supersedes);
0098             break;
0099         case 't':
0100         case 'T':
0101             mk_header(To);
0102             break;
0103         case 'u':
0104         case 'U':
0105             mk_header(UserAgent);
0106             break;
0107     }
0108     return nullptr;
0109 }
0110 
0111 #undef mk_header