comparison 3rdparty/vmime/src/vmime/addressList.hpp @ 0:a4671277546c tip

created the repository for the thymian project
author ferencd
date Tue, 17 Aug 2021 11:19:54 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:a4671277546c
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 #ifndef VMIME_ADDRESSLIST_HPP_INCLUDED
25 #define VMIME_ADDRESSLIST_HPP_INCLUDED
26
27
28 #include "vmime/base.hpp"
29 #include "vmime/headerFieldValue.hpp"
30
31 #include "vmime/address.hpp"
32
33
34 namespace vmime
35 {
36
37
38 class mailboxList;
39
40
41 /** A list of addresses.
42 */
43
44 class VMIME_EXPORT addressList : public headerFieldValue
45 {
46 public:
47
48 addressList();
49 addressList(const addressList& addrList);
50
51 ~addressList();
52
53
54 shared_ptr <component> clone() const;
55 void copyFrom(const component& other);
56 addressList& operator=(const addressList& other);
57 addressList& operator=(const mailboxList& other);
58
59 const std::vector <shared_ptr <component> > getChildComponents();
60
61
62 /** Add a address at the end of the list.
63 *
64 * @param addr address to append
65 */
66 void appendAddress(shared_ptr <address> addr);
67
68 /** Insert a new address before the specified address.
69 *
70 * @param beforeAddress address before which the new address will be inserted
71 * @param addr address to insert
72 * @throw std::out_of_range if the address is not in the list
73 */
74 void insertAddressBefore(shared_ptr <address> beforeAddress, shared_ptr <address> addr);
75
76 /** Insert a new address before the specified position.
77 *
78 * @param pos position at which to insert the new address (0 to insert at
79 * the beginning of the list)
80 * @param addr address to insert
81 * @throw std::out_of_range if the position is out of range
82 */
83 void insertAddressBefore(const size_t pos, shared_ptr <address> addr);
84
85 /** Insert a new address after the specified address.
86 *
87 * @param afterAddress address after which the new address will be inserted
88 * @param addr address to insert
89 * @throw std::out_of_range if the address is not in the list
90 */
91 void insertAddressAfter(shared_ptr <address> afterAddress, shared_ptr <address> addr);
92
93 /** Insert a new address after the specified position.
94 *
95 * @param pos position of the address before the new address
96 * @param addr address to insert
97 * @throw std::out_of_range if the position is out of range
98 */
99 void insertAddressAfter(const size_t pos, shared_ptr <address> addr);
100
101 /** Remove the specified address from the list.
102 *
103 * @param addr address to remove
104 * @throw std::out_of_range if the address is not in the list
105 */
106 void removeAddress(shared_ptr <address> addr);
107
108 /** Remove the address at the specified position.
109 *
110 * @param pos position of the address to remove
111 * @throw std::out_of_range if the position is out of range
112 */
113 void removeAddress(const size_t pos);
114
115 /** Remove all addresses from the list.
116 */
117 void removeAllAddresses();
118
119 /** Return the number of addresses in the list.
120 *
121 * @return number of addresses
122 */
123 size_t getAddressCount() const;
124
125 /** Tests whether the list of addresses is empty.
126 *
127 * @return true if there is no address, false otherwise
128 */
129 bool isEmpty() const;
130
131 /** Return the address at the specified position.
132 *
133 * @param pos position
134 * @return address at position 'pos'
135 * @throw std::out_of_range if the position is out of range
136 */
137 shared_ptr <address> getAddressAt(const size_t pos);
138
139 /** Return the address at the specified position.
140 *
141 * @param pos position
142 * @return address at position 'pos'
143 * @throw std::out_of_range if the position is out of range
144 */
145 const shared_ptr <const address> getAddressAt(const size_t pos) const;
146
147 /** Return the address list.
148 *
149 * @return list of addresses
150 */
151 const std::vector <shared_ptr <const address> > getAddressList() const;
152
153 /** Return the address list.
154 *
155 * @return list of addresses
156 */
157 const std::vector <shared_ptr <address> > getAddressList();
158
159 /** Return a list of mailboxes.
160 * If some addresses are actually groups, mailboxes are recursively
161 * extracted from these groups.
162 *
163 * @return list of mailboxes
164 */
165 shared_ptr <mailboxList> toMailboxList() const;
166
167 private:
168
169 std::vector <shared_ptr <address> > m_list;
170
171 protected:
172
173 // Component parsing & assembling
174 void parseImpl
175 (const parsingContext& ctx,
176 const string& buffer,
177 const size_t position,
178 const size_t end,
179 size_t* newPosition = NULL);
180
181 void generateImpl
182 (const generationContext& ctx,
183 utility::outputStream& os,
184 const size_t curLinePos = 0,
185 size_t* newLinePos = NULL) const;
186 };
187
188
189 } // vmime
190
191
192 #endif // VMIME_ADDRESSLIST_HPP_INCLUDED