1 | // |
2 | // MailRecipient.cpp |
3 | // |
4 | // Library: Net |
5 | // Package: Mail |
6 | // Module: MailRecipient |
7 | // |
8 | // Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH. |
9 | // and Contributors. |
10 | // |
11 | // SPDX-License-Identifier: BSL-1.0 |
12 | // |
13 | |
14 | |
15 | #include "Poco/Net/MailRecipient.h" |
16 | #include <algorithm> |
17 | |
18 | |
19 | namespace Poco { |
20 | namespace Net { |
21 | |
22 | |
23 | MailRecipient::MailRecipient(): |
24 | _type(PRIMARY_RECIPIENT) |
25 | { |
26 | } |
27 | |
28 | |
29 | MailRecipient::MailRecipient(const MailRecipient& recipient): |
30 | _address(recipient._address), |
31 | _realName(recipient._realName), |
32 | _type(recipient._type) |
33 | { |
34 | } |
35 | |
36 | |
37 | MailRecipient::MailRecipient(MailRecipient&& recipient) : |
38 | _address(std::move(recipient._address)), |
39 | _realName(std::move(recipient._realName)), |
40 | _type(recipient._type) |
41 | { |
42 | recipient._address.clear(); |
43 | recipient._realName.clear(); |
44 | } |
45 | |
46 | |
47 | MailRecipient::MailRecipient(RecipientType type, const std::string& address): |
48 | _address(address), |
49 | _type(type) |
50 | { |
51 | } |
52 | |
53 | |
54 | MailRecipient::MailRecipient(RecipientType type, const std::string& address, const std::string& realName): |
55 | _address(address), |
56 | _realName(realName), |
57 | _type(type) |
58 | { |
59 | } |
60 | |
61 | |
62 | MailRecipient::~MailRecipient() |
63 | { |
64 | } |
65 | |
66 | |
67 | MailRecipient& MailRecipient::operator = (const MailRecipient& recipient) |
68 | { |
69 | if (this != &recipient) |
70 | { |
71 | MailRecipient tmp(recipient); |
72 | swap(tmp); |
73 | } |
74 | return *this; |
75 | } |
76 | |
77 | |
78 | MailRecipient& MailRecipient::operator = (MailRecipient&& recipient) |
79 | { |
80 | if (this != &recipient) |
81 | { |
82 | _address = std::move(recipient._address); |
83 | recipient._address.clear(); |
84 | _realName = std::move(recipient._realName); |
85 | recipient._realName.clear(); |
86 | _type = recipient._type; |
87 | } |
88 | return *this; |
89 | } |
90 | |
91 | |
92 | void MailRecipient::swap(MailRecipient& recipient) |
93 | { |
94 | std::swap(_type, recipient._type); |
95 | std::swap(_address, recipient._address); |
96 | std::swap(_realName, recipient._realName); |
97 | } |
98 | |
99 | |
100 | void MailRecipient::setType(RecipientType type) |
101 | { |
102 | _type = type; |
103 | } |
104 | |
105 | |
106 | void MailRecipient::setAddress(const std::string& address) |
107 | { |
108 | _address = address; |
109 | } |
110 | |
111 | |
112 | void MailRecipient::setRealName(const std::string& realName) |
113 | { |
114 | _realName = realName; |
115 | } |
116 | |
117 | |
118 | } } // namespace Poco::Net |
119 | |