ucommon
mime.h
Go to the documentation of this file.
1 // Copyright (C) 2001-2005 Open Source Telecom Corporation.
2 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free software
18 // library without restriction. Specifically, if other files instantiate
19 // templates or use macros or inline functions from this file, or you compile
20 // this file and link it with other files to produce an executable, this
21 // file does not by itself cause the resulting executable to be covered by
22 // the GNU General Public License. This exception does not however
23 // invalidate any other reasons why the executable file might be covered by
24 // the GNU General Public License.
25 //
26 // This exception applies only to the code released under the name GNU
27 // Common C++. If you copy code from other releases into a copy of GNU
28 // Common C++, as the General Public License permits, the exception does
29 // not apply to the code that you add in this way. To avoid misleading
30 // anyone as to the status of such modified files, you must delete
31 // this exception notice from them.
32 //
33 // If you write modifications of your own for GNU Common C++, it is your choice
34 // whether to permit this exception to apply to your modifications.
35 // If you do not wish that, delete this exception notice.
36 //
37 
43 #ifndef COMMONCPP_MIME_H_
44 #define COMMONCPP_MIME_H_
45 
46 #ifndef COMMONCPP_CONFIG_H_
47 #include <commoncpp/config.h>
48 #endif
49 
50 #ifndef COMMONCPP_SOCKET_H_
51 #include <commoncpp/socket.h>
52 #endif
53 
54 NAMESPACE_COMMONCPP
55 
56 class MIMEMultipart;
57 class MIMEItemPart;
58 
66 class __EXPORT MIMEMultipart
67 {
68 protected:
69  friend class MIMEItemPart;
70  char boundry[8];
71  char mtype[80];
72  char *header[16];
73  MIMEItemPart *first, *last;
74 
75  virtual ~MIMEMultipart();
76 
77 public:
83  MIMEMultipart(const char *document);
84 
91  virtual void head(std::ostream *output);
92 
99  virtual void body(std::ostream *output);
100 
107  char **getHeaders(void)
108  {return header;};
109 };
110 
119 class __EXPORT MIMEMultipartForm : public MIMEMultipart
120 {
121 protected:
122  virtual ~MIMEMultipartForm();
123 
124 public:
130 };
131 
140 class __EXPORT MIMEItemPart
141 {
142 protected:
143  friend class MIMEMultipart;
144 
145  MIMEMultipart *base;
146  MIMEItemPart *next;
147  const char *ctype;
148 
154  virtual void head(std::ostream *output);
155 
161  virtual void body(std::ostream *output) = 0;
162 
169  MIMEItemPart(MIMEMultipart *top, const char *ct);
170 
171  virtual ~MIMEItemPart();
172 };
173 
181 class __EXPORT MIMEFormData : public MIMEItemPart
182 {
183 protected:
184  const char *content;
185  const char *name;
186 
187  virtual ~MIMEFormData();
188 
189 public:
195  void head(std::ostream *output);
196 
202  void body(std::ostream *output);
203 
211  MIMEFormData(MIMEMultipartForm *top, const char *name, const char *content);
212 };
213 
214 END_NAMESPACE
215 
216 #endif
217 
virtual void head(std::ostream *output)
Stream the header(s) for the current document part.
A container class for multi-part MIME document objects which can be streamed to a std::ostream destin...
Definition: mime.h:66
virtual void body(std::ostream *output)=0
Stream the content of this document part.
The Multipart form is a MIME multipart document specific for the construction and delivery of form da...
Definition: mime.h:119
This is used to attach an item part to a MIME multipart document that is being streamed.
Definition: mime.h:140
char ** getHeaders(void)
Get a string array of the headers to use.
Definition: mime.h:107
socket operations.
This is a document part type for use in submitting multipart form data to a web server.
Definition: mime.h:181