From f9913fa28a27f23fde2d4956c62cbb2fb2bc2ee8 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Thu, 21 Nov 2013 22:16:57 +0100 Subject: Boost/C++11 shared pointers. --- src/addressList.cpp | 66 ++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'src/addressList.cpp') diff --git a/src/addressList.cpp b/src/addressList.cpp index 326a54e3..957be503 100644 --- a/src/addressList.cpp +++ b/src/addressList.cpp @@ -60,7 +60,7 @@ void addressList::parseImpl while (pos < end) { - ref
parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL); + shared_ptr
parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL); if (parsedAddress != NULL) m_list.push_back(parsedAddress); @@ -84,7 +84,7 @@ void addressList::generateImpl if (!m_list.empty()) { - for (std::vector >::const_iterator i = m_list.begin() ; ; ) + for (std::vector >::const_iterator i = m_list.begin() ; ; ) { (*i)->generate(ctx, os, pos, &pos); @@ -107,10 +107,10 @@ void addressList::copyFrom(const component& other) removeAllAddresses(); - for (std::vector >::const_iterator it = addrList.m_list.begin() ; + for (std::vector >::const_iterator it = addrList.m_list.begin() ; it != addrList.m_list.end() ; ++it) { - m_list.push_back((*it)->clone().dynamicCast
()); + m_list.push_back(vmime::clone(*it)); } } @@ -127,27 +127,27 @@ addressList& addressList::operator=(const mailboxList& other) removeAllAddresses(); for (size_t i = 0 ; i < other.getMailboxCount() ; ++i) - m_list.push_back(other.getMailboxAt(i)->clone().dynamicCast
()); + m_list.push_back(dynamicCast
(other.getMailboxAt(i)->clone())); return (*this); } -ref addressList::clone() const +shared_ptr addressList::clone() const { - return vmime::create (*this); + return make_shared (*this); } -void addressList::appendAddress(ref
addr) +void addressList::appendAddress(shared_ptr
addr) { m_list.push_back(addr); } -void addressList::insertAddressBefore(ref
beforeAddress, ref
addr) +void addressList::insertAddressBefore(shared_ptr
beforeAddress, shared_ptr
addr) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), beforeAddress); if (it == m_list.end()) @@ -157,15 +157,15 @@ void addressList::insertAddressBefore(ref
beforeAddress, ref
} -void addressList::insertAddressBefore(const size_t pos, ref
addr) +void addressList::insertAddressBefore(const size_t pos, shared_ptr
addr) { m_list.insert(m_list.begin() + pos, addr); } -void addressList::insertAddressAfter(ref
afterAddress, ref
addr) +void addressList::insertAddressAfter(shared_ptr
afterAddress, shared_ptr
addr) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), afterAddress); if (it == m_list.end()) @@ -175,15 +175,15 @@ void addressList::insertAddressAfter(ref
afterAddress, ref
a } -void addressList::insertAddressAfter(const size_t pos, ref
addr) +void addressList::insertAddressAfter(const size_t pos, shared_ptr
addr) { m_list.insert(m_list.begin() + pos + 1, addr); } -void addressList::removeAddress(ref
addr) +void addressList::removeAddress(shared_ptr
addr) { - const std::vector >::iterator it = std::find + const std::vector >::iterator it = std::find (m_list.begin(), m_list.end(), addr); if (it == m_list.end()) @@ -195,7 +195,7 @@ void addressList::removeAddress(ref
addr) void addressList::removeAddress(const size_t pos) { - const std::vector >::iterator it = m_list.begin() + pos; + const std::vector >::iterator it = m_list.begin() + pos; m_list.erase(it); } @@ -219,25 +219,25 @@ bool addressList::isEmpty() const } -ref
addressList::getAddressAt(const size_t pos) +shared_ptr
addressList::getAddressAt(const size_t pos) { return (m_list[pos]); } -const ref addressList::getAddressAt(const size_t pos) const +const shared_ptr addressList::getAddressAt(const size_t pos) const { return (m_list[pos]); } -const std::vector > addressList::getAddressList() const +const std::vector > addressList::getAddressList() const { - std::vector > list; + std::vector > list; list.reserve(m_list.size()); - for (std::vector >::const_iterator it = m_list.begin() ; + for (std::vector >::const_iterator it = m_list.begin() ; it != m_list.end() ; ++it) { list.push_back(*it); @@ -247,15 +247,15 @@ const std::vector > addressList::getAddressList() const } -const std::vector > addressList::getAddressList() +const std::vector > addressList::getAddressList() { return (m_list); } -const std::vector > addressList::getChildComponents() +const std::vector > addressList::getChildComponents() { - std::vector > list; + std::vector > list; copy_vector(m_list, list); @@ -263,21 +263,21 @@ const std::vector > addressList::getChildComponents() } -ref addressList::toMailboxList() const +shared_ptr addressList::toMailboxList() const { - ref res = vmime::create (); + shared_ptr res = make_shared (); - for (std::vector >::const_iterator it = m_list.begin() ; + for (std::vector >::const_iterator it = m_list.begin() ; it != m_list.end() ; ++it) { - ref addr = *it; + shared_ptr addr = *it; if (addr->isGroup()) { - const std::vector > mailboxes = - addr.dynamicCast ()->getMailboxList(); + const std::vector > mailboxes = + dynamicCast (addr)->getMailboxList(); - for (std::vector >::const_iterator jt = mailboxes.begin() ; + for (std::vector >::const_iterator jt = mailboxes.begin() ; jt != mailboxes.end() ; ++jt) { res->appendMailbox(vmime::clone(*jt)); @@ -285,7 +285,7 @@ ref addressList::toMailboxList() const } else { - res->appendMailbox(addr->clone().dynamicCast ()); + res->appendMailbox(dynamicCast (addr->clone())); } } -- cgit