KMime

kmime_headerfactory.cpp
Go to the documentation of this file.
1 /*
2  kmime_header_factory.cpp
3 
4  KMime, the KDE Internet mail/usenet news message library.
5  SPDX-FileCopyrightText: 2009 Constantin Berzan <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 
10 /**
11  @file
12  This file is part of the API for handling MIME data and
13  defines the HeaderFactory class.
14 
15  @brief
16  Defines the HeaderFactory class.
17 
18  @authors Constantin Berzan <[email protected]>
19 */
20 
21 #include "kmime_headerfactory_p.h"
22 #include "kmime_headers.h"
23 
24 #include <algorithm>
25 
26 using namespace KMime;
27 using namespace KMime::Headers;
28 
29 #define mk_header(hdr) \
30  if (qstrnicmp(type, hdr ::staticType(), std::max(typeLen, strlen(hdr::staticType()))) == 0) \
31  return new hdr;
32 
33 Headers::Base *HeaderFactory::createHeader(const char *type, size_t typeLen)
34 {
35  Q_ASSERT(type && *type);
36  switch (*type) {
37  case 'b':
38  case 'B':
39  mk_header(Bcc);
40  break;
41  case 'c':
42  case 'C':
43  mk_header(Cc);
44  mk_header(ContentDescription);
45  mk_header(ContentDisposition);
46  mk_header(ContentID);
47  mk_header(ContentLocation);
48  mk_header(ContentTransferEncoding);
49  mk_header(ContentType);
50  mk_header(Control);
51  break;
52  case 'd':
53  case 'D':
54  mk_header(Date);
55  break;
56  case 'f':
57  case 'F':
58  mk_header(FollowUpTo);
59  mk_header(From);
60  break;
61  case 'i':
62  case 'I':
63  mk_header(InReplyTo);
64  break;
65  case 'k':
66  case 'K':
67  mk_header(Keywords);
68  break;
69  case 'l':
70  case 'L':
71  mk_header(Lines);
72  break;
73  case 'm':
74  case 'M':
75  mk_header(MailCopiesTo);
76  mk_header(MessageID);
77  mk_header(MIMEVersion);
78  break;
79  case 'n':
80  case 'N':
81  mk_header(Newsgroups);
82  break;
83  case 'o':
84  case 'O':
85  mk_header(Organization);
86  break;
87  case 'r':
88  case 'R':
89  mk_header(References);
90  mk_header(ReplyTo);
91  mk_header(ReturnPath);
92  break;
93  case 's':
94  case 'S':
95  mk_header(Sender);
96  mk_header(Subject);
97  mk_header(Supersedes);
98  break;
99  case 't':
100  case 'T':
101  mk_header(To);
102  break;
103  case 'u':
104  case 'U':
105  mk_header(UserAgent);
106  break;
107  }
108  return nullptr;
109 }
110 
111 #undef mk_header
Represents a "Message-ID" header.
Represents a "Content-Disposition" header.
Represents a "Date" header.
Represents a "References" header.
Represents a "Mail-Copies-To" header.
Represents a "Cc" header.
Represents a "To" header.
Represents a "Followup-To" header.
Represents a "Control" header.
Represents a "Content-ID" header.
Represents a "MIME-Version" header.
Represents the Return-Path header field.
Represent a "From" header.
Baseclass of all header-classes.
This file is part of the API for handling MIME data and defines the various header classes: ...
Represents a "ReplyTo" header.
Represents a "Content-Location" header.
Represents a "Lines" header.
Represents a "Keywords" header.
Represents a "Content-Description" header.
Represents a "Newsgroups" header.
Represents a "In-Reply-To" header.
Represents a "Supersedes" header.
Represents a "Subject" header.
Represents a "Organization" header.
Represents a "User-Agent" header.
Represents a "Content-Transfer-Encoding" header.
Represents a "Content-Type" header.
Represents a "Bcc" header.
Represents a "Sender" header.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Sep 27 2021 23:15:57 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.