1 //
2 // VMime library (http://www.vmime.org)
3 // Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 3 of
8 // the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but 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 along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // Linking this library statically or dynamically with other modules is making
20 // a combined work based on this library.  Thus, the terms and conditions of
21 // the GNU General Public License cover the whole combination.
22 //
23 
24 #include "vmime/config.hpp"
25 
26 
27 #if VMIME_HAVE_MESSAGING_FEATURES
28 
29 
30 #include "vmime/net/fetchAttributes.hpp"
31 
32 #include "vmime/utility/stringUtils.hpp"
33 
34 #include <algorithm>
35 
36 
37 namespace vmime {
38 namespace net {
39 
40 
fetchAttributes()41 fetchAttributes::fetchAttributes()
42 	: m_predefinedAttribs(0)
43 {
44 }
45 
46 
fetchAttributes(const int attribs)47 fetchAttributes::fetchAttributes(const int attribs)
48 	: m_predefinedAttribs(attribs)
49 {
50 }
51 
52 
fetchAttributes(const fetchAttributes & attribs)53 fetchAttributes::fetchAttributes(const fetchAttributes& attribs)
54 	: object()
55 {
56 	m_predefinedAttribs = attribs.m_predefinedAttribs;
57 	m_headers = attribs.m_headers;
58 }
59 
60 
add(const int attribs)61 void fetchAttributes::add(const int attribs)
62 {
63 	m_predefinedAttribs |= attribs;
64 }
65 
66 
add(const string & header)67 void fetchAttributes::add(const string& header)
68 {
69 	m_headers.push_back(utility::stringUtils::toLower(header));
70 }
71 
72 
has(const int attribs) const73 bool fetchAttributes::has(const int attribs) const
74 {
75 	return (m_predefinedAttribs & attribs) != 0;
76 }
77 
78 
has(const string & header) const79 bool fetchAttributes::has(const string& header) const
80 {
81 	return std::find(m_headers.begin(), m_headers.end(), utility::stringUtils::toLower(header)) != m_headers.end();
82 }
83 
84 
getHeaderFields() const85 const std::vector <string> fetchAttributes::getHeaderFields() const
86 {
87 	return m_headers;
88 }
89 
90 
91 } // net
92 } // vmime
93 
94 
95 #endif // VMIME_HAVE_MESSAGING_FEATURES
96