root/msg/entity.hh

Revision 11cf105fe323361072281747558cb61752f33fa8, 3.4 KB (checked in by Antti-Juhani Kaijanaho <antti-juhani@…>, 20 months ago)

#60: Add a footer to email distributed posts

Signed-off-by: Antti-Juhani Kaijanaho <antti-juhani@…>

  • Property mode set to 100644
Line 
1/*  This file is part of Alue, the multiprotocol Internet discussion daemon
2
3    Copyright © 2009, 2010 Antti-Juhani Kaijanaho
4
5    Alue is free software: you can redistribute it and/or modify it
6    under the terms of the GNU General Public License as published by
7    the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9
10    Alue is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with Alue.  If not, see <http://www.gnu.org/licenses/>.
17
18 */
19
20#ifndef GUARD_MSG_ENTITY_HH
21#define GUARD_MSG_ENTITY_HH
22
23#include "entity_header.hh"
24
25#define DEFAULT_CT "text/plain; charset=\"US-ASCII\""
26
27namespace tlate { class value; }
28
29namespace msg
30{
31        class content_type;
32        class multipart;
33
34        class entity
35        {
36        public:
37                typedef boost::shared_ptr<entity> ptr;
38                typedef boost::shared_ptr<const entity> const_ptr;
39                typedef entity_header::field_iterator field_iterator;
40
41                static ptr mk(std::string msgstr,
42                              bool validate,
43                              std::string default_ct = DEFAULT_CT);
44
45                virtual ~entity() {}
46
47                virtual ptr clone() const = 0;
48
49                virtual boost::shared_ptr<multipart> clone_as_multipart() const;
50
51                virtual boost::shared_ptr<tlate::value>
52                get_tlate_value(bool hide_addreses) const = 0;
53
54                boost::posix_time::ptime parsed_date() const {
55                        return hdr->parsed_date();
56                }
57
58                field_iterator fields_begin() const {
59                        return hdr->fields_begin();
60                }
61
62                field_iterator fields_end() const { return hdr->fields_end(); }
63
64                std::string get_header() const { return hdr->get_header(); }
65                virtual std::string get_body() const = 0;
66                virtual std::string get_decoded_body() const {
67                        return get_body();
68                }
69                std::string get_entity() const {
70                        return get_header() + "\r\n" + get_body();
71                }
72
73                bool has_field(std::string s) const{ return hdr->has_field(s); }
74
75                // returns the field unprocessed
76                std::string get_field(std::string s, bool full) const {
77                        return hdr->get_field(s, full);
78                }
79
80                size_t get_size() const;
81                size_t get_body_lines() const;
82
83                void replace_field(std::string name, std::string body) {
84                        return hdr->replace_field(name, body);
85                }
86
87                content_type get_content_type() const {
88                        return hdr->get_content_type();
89                }
90
91        protected:
92                entity(entity_header::ptr hdr)
93                        : hdr(hdr)
94                        {}
95                entity(const entity &ent)
96                        : hdr(new entity_header(*ent.hdr))
97                        {}
98
99        private:
100                entity_header::ptr hdr;
101
102                entity &operator=(const entity &); // DISABLED
103        };
104}
105
106#endif /* GUARD_MSG_ENTITY_HH */
Note: See TracBrowser for help on using the browser.