/[debian]/mimetic/branches/upstream/current/mimetic/body.h
ViewVC logotype

Contents of /mimetic/branches/upstream/current/mimetic/body.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 128 - (show annotations)
Sat Feb 25 16:49:20 2006 UTC (15 years, 5 months ago) by gregoa
File MIME type: text/plain
File size: 3069 byte(s)
[svn-inject] Installing original source of mimetic
1 /***************************************************************************
2 copyright : (C) 2002-2005 by Stefano Barbato
3 email : stefano@codesink.org
4
5 $Id: body.h,v 1.14 2005/02/23 10:26:14 tat Exp $
6 ***************************************************************************/
7
8 /***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16 #ifndef _MIMETIC_BODY_H_
17 #define _MIMETIC_BODY_H_
18 #include <string>
19 #include <mimetic/rfc822/body.h>
20 #include <mimetic/codec/code.h>
21 #include <mimetic/mimeentitylist.h>
22 #include <mimetic/os/file.h>
23
24
25 namespace mimetic
26 {
27
28 /// MIME message body
29 class Body: public Rfc822Body
30 {
31 public:
32 friend class MimeEntity;
33 Body();
34
35 /**
36 set body content
37 */
38 void set(const std::string&);
39
40 /**
41 load file as is, no encoding is performed
42 */
43 bool load(const std::string&);
44
45 /**
46 load file and code it using \p Codec
47 */
48 template<typename Codec>
49 bool load(const std::string&, const Codec&);
50
51 /**
52 en/decode body content
53 */
54 template<typename Codec>
55 bool code(const Codec&);
56
57 /**
58 set body \e preamble
59
60 \sa RFC822
61 */
62 void preamble(const std::string&);
63 /**
64 get body \e preamble
65
66 \sa RFC822
67 */
68 const std::string& preamble() const;
69 std::string& preamble();
70
71 /**
72 set body \e epilogue
73
74 \sa RFC822
75 */
76 void epilogue(const std::string&);
77 /**
78 get body \e epilogue
79
80 \sa RFC822
81 */
82 const std::string& epilogue() const;
83 std::string& epilogue();
84
85 /**
86 get body's parts list
87 */
88 MimeEntityList& parts();
89 const MimeEntityList& parts() const;
90
91 /**
92 get body's MimeEntity owner
93 */
94 MimeEntity* owner();
95 const MimeEntity* owner() const;
96
97 protected:
98 void owner(MimeEntity*);
99 protected:
100 MimeEntity* m_owner;
101 MimeEntityList m_parts;
102 std::string m_preamble, m_epilogue;
103 };
104
105 template<typename Codec>
106 bool Body::load(const std::string& fqn, const Codec& cc)
107 {
108 File in(fqn);
109 if(!in)
110 return false;
111 File::iterator beg = in.begin(), end = in.end();
112 Codec codec(cc);
113 mimetic::code(beg, end, codec, back_inserter(*this) );
114 return true;
115 }
116
117
118 template<typename Codec>
119 bool Body::code(const Codec& cc)
120 {
121 // OPTIMIZE
122 std::string coded;
123 Codec codec(cc);
124 mimetic::code(begin(), end(), cc, back_inserter(coded) );
125 this->assign(coded);
126 return true;
127 }
128
129 }
130
131 #endif

  ViewVC Help
Powered by ViewVC 1.1.26