diff options
author | Tobias Markmann <tm@ayena.de> | 2016-04-01 17:23:49 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-04-04 08:28:23 (GMT) |
commit | 741c45b74d5f634622eb5f757c49323274fb8937 (patch) | |
tree | b9cfa6c2fe2e79e03cc8cb7c1ca1e9cf45aa5328 /Swift/Controllers/XMPPEvents | |
parent | eddd92ed76ae68cb1e202602fd3ebd11b69191a2 (diff) | |
download | swift-741c45b74d5f634622eb5f757c49323274fb8937.zip swift-741c45b74d5f634622eb5f757c49323274fb8937.tar.bz2 |
Modernize code to use C++11 shared_ptr instead of Boost's
This change was done by applying the following 'gsed'
replacement calls to all source files:
's/\#include <boost\/shared_ptr\.hpp>/\#include <memory>/g'
's/\#include <boost\/enable_shared_from_this\.hpp>/\#include <memory>/g'
's/\#include <boost\/smart_ptr\/make_shared\.hpp>/\#include <memory>/g'
's/\#include <boost\/make_shared\.hpp>/\#include <memory>/g'
's/\#include <boost\/weak_ptr\.hpp>/\#include <memory>/g'
's/boost::make_shared/std::make_shared/g'
's/boost::dynamic_pointer_cast/std::dynamic_pointer_cast/g'
's/boost::shared_ptr/std::shared_ptr/g'
's/boost::weak_ptr/std::weak_ptr/g'
's/boost::enable_shared_from_this/std::enable_shared_from_this/g'
The remaining issues have been fixed manually.
Test-Information:
Code builds on OS X 10.11.4 and unit tests pass.
Change-Id: Ia7ae34eab869fb9ad6387a1348426b71ae4acd5f
Diffstat (limited to 'Swift/Controllers/XMPPEvents')
-rw-r--r-- | Swift/Controllers/XMPPEvents/ErrorEvent.h | 3 | ||||
-rw-r--r-- | Swift/Controllers/XMPPEvents/EventController.cpp | 22 | ||||
-rw-r--r-- | Swift/Controllers/XMPPEvents/EventController.h | 13 | ||||
-rw-r--r-- | Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h | 6 | ||||
-rw-r--r-- | Swift/Controllers/XMPPEvents/MUCInviteEvent.h | 7 | ||||
-rw-r--r-- | Swift/Controllers/XMPPEvents/MessageEvent.h | 11 | ||||
-rw-r--r-- | Swift/Controllers/XMPPEvents/StanzaEvent.h | 3 | ||||
-rw-r--r-- | Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h | 3 |
8 files changed, 32 insertions, 36 deletions
diff --git a/Swift/Controllers/XMPPEvents/ErrorEvent.h b/Swift/Controllers/XMPPEvents/ErrorEvent.h index 959f210..f3888cb 100644 --- a/Swift/Controllers/XMPPEvents/ErrorEvent.h +++ b/Swift/Controllers/XMPPEvents/ErrorEvent.h @@ -7,10 +7,9 @@ #pragma once #include <cassert> +#include <memory> #include <string> -#include <boost/shared_ptr.hpp> - #include <Swiften/Base/boost_bsignals.h> #include <Swiften/JID/JID.h> diff --git a/Swift/Controllers/XMPPEvents/EventController.cpp b/Swift/Controllers/XMPPEvents/EventController.cpp index 4c6b3bc..f0debb9 100644 --- a/Swift/Controllers/XMPPEvents/EventController.cpp +++ b/Swift/Controllers/XMPPEvents/EventController.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -25,23 +25,23 @@ EventController::EventController() { } EventController::~EventController() { - foreach(boost::shared_ptr<StanzaEvent> event, events_) { + foreach(std::shared_ptr<StanzaEvent> event, events_) { event->onConclusion.disconnect(boost::bind(&EventController::handleEventConcluded, this, event)); } } -void EventController::handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceEvent) { - boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(sourceEvent); - boost::shared_ptr<SubscriptionRequestEvent> subscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(sourceEvent); - boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(sourceEvent); - boost::shared_ptr<MUCInviteEvent> mucInviteEvent = boost::dynamic_pointer_cast<MUCInviteEvent>(sourceEvent); - boost::shared_ptr<IncomingFileTransferEvent> incomingFileTransferEvent = boost::dynamic_pointer_cast<IncomingFileTransferEvent>(sourceEvent); +void EventController::handleIncomingEvent(std::shared_ptr<StanzaEvent> sourceEvent) { + std::shared_ptr<MessageEvent> messageEvent = std::dynamic_pointer_cast<MessageEvent>(sourceEvent); + std::shared_ptr<SubscriptionRequestEvent> subscriptionEvent = std::dynamic_pointer_cast<SubscriptionRequestEvent>(sourceEvent); + std::shared_ptr<ErrorEvent> errorEvent = std::dynamic_pointer_cast<ErrorEvent>(sourceEvent); + std::shared_ptr<MUCInviteEvent> mucInviteEvent = std::dynamic_pointer_cast<MUCInviteEvent>(sourceEvent); + std::shared_ptr<IncomingFileTransferEvent> incomingFileTransferEvent = std::dynamic_pointer_cast<IncomingFileTransferEvent>(sourceEvent); /* If it's a duplicate subscription request, remove the previous request first */ if (subscriptionEvent) { EventList existingEvents(events_); - foreach(boost::shared_ptr<StanzaEvent> existingEvent, existingEvents) { - boost::shared_ptr<SubscriptionRequestEvent> existingSubscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(existingEvent); + foreach(std::shared_ptr<StanzaEvent> existingEvent, existingEvents) { + std::shared_ptr<SubscriptionRequestEvent> existingSubscriptionEvent = std::dynamic_pointer_cast<SubscriptionRequestEvent>(existingEvent); if (existingSubscriptionEvent) { if (existingSubscriptionEvent->getJID() == subscriptionEvent->getJID()) { existingEvent->conclude(); @@ -61,7 +61,7 @@ void EventController::handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceE } } -void EventController::handleEventConcluded(boost::shared_ptr<StanzaEvent> event) { +void EventController::handleEventConcluded(std::shared_ptr<StanzaEvent> event) { event->onConclusion.disconnect(boost::bind(&EventController::handleEventConcluded, this, event)); events_.erase(std::remove(events_.begin(), events_.end(), event), events_.end()); onEventQueueLengthChange(boost::numeric_cast<int>(events_.size())); diff --git a/Swift/Controllers/XMPPEvents/EventController.h b/Swift/Controllers/XMPPEvents/EventController.h index 3081449..1e198cb 100644 --- a/Swift/Controllers/XMPPEvents/EventController.h +++ b/Swift/Controllers/XMPPEvents/EventController.h @@ -1,36 +1,35 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once +#include <memory> #include <vector> -#include <boost/shared_ptr.hpp> - #include <Swiften/Base/boost_bsignals.h> #include <Swift/Controllers/XMPPEvents/MessageEvent.h> #include <Swift/Controllers/XMPPEvents/StanzaEvent.h> namespace Swift { - typedef std::vector<boost::shared_ptr<StanzaEvent> > EventList; + typedef std::vector<std::shared_ptr<StanzaEvent> > EventList; class EventController { public: EventController(); ~EventController(); - void handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceEvent); + void handleIncomingEvent(std::shared_ptr<StanzaEvent> sourceEvent); boost::signal<void (int)> onEventQueueLengthChange; - boost::signal<void (boost::shared_ptr<StanzaEvent>)> onEventQueueEventAdded; + boost::signal<void (std::shared_ptr<StanzaEvent>)> onEventQueueEventAdded; const EventList& getEvents() const {return events_;} void disconnectAll(); void clear(); private: - void handleEventConcluded(boost::shared_ptr<StanzaEvent> event); + void handleEventConcluded(std::shared_ptr<StanzaEvent> event); EventList events_; }; } diff --git a/Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h b/Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h index 4c128e8..3d4303d 100644 --- a/Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h +++ b/Swift/Controllers/XMPPEvents/IncomingFileTransferEvent.h @@ -1,12 +1,12 @@ /* - * Copyright (c) 2015 Isode Limited. + * Copyright (c) 2015-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once -#include <boost/shared_ptr.hpp> +#include <memory> #include <Swiften/JID/JID.h> @@ -15,7 +15,7 @@ namespace Swift { class IncomingFileTransferEvent : public StanzaEvent { public: - typedef boost::shared_ptr<IncomingFileTransferEvent> ref; + typedef std::shared_ptr<IncomingFileTransferEvent> ref; IncomingFileTransferEvent(const JID& sender) : sender_(sender) {} diff --git a/Swift/Controllers/XMPPEvents/MUCInviteEvent.h b/Swift/Controllers/XMPPEvents/MUCInviteEvent.h index 7d333fb..4cdbbff 100644 --- a/Swift/Controllers/XMPPEvents/MUCInviteEvent.h +++ b/Swift/Controllers/XMPPEvents/MUCInviteEvent.h @@ -5,17 +5,16 @@ */ /* - * Copyright (c) 2015 Isode Limited. + * Copyright (c) 2015-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once +#include <memory> #include <string> -#include <boost/shared_ptr.hpp> - #include <Swiften/JID/JID.h> #include <Swift/Controllers/XMPPEvents/StanzaEvent.h> @@ -24,7 +23,7 @@ namespace Swift { class MUCInviteEvent : public StanzaEvent { public: - typedef boost::shared_ptr<MUCInviteEvent> ref; + typedef std::shared_ptr<MUCInviteEvent> ref; public: MUCInviteEvent(const JID& inviter, const JID& roomJID, const std::string& reason, const std::string& password, bool direct, bool impromptu) : inviter_(inviter), roomJID_(roomJID), reason_(reason), password_(password), direct_(direct), impromptu_(impromptu) {} diff --git a/Swift/Controllers/XMPPEvents/MessageEvent.h b/Swift/Controllers/XMPPEvents/MessageEvent.h index 4ec0406..7af2be6 100644 --- a/Swift/Controllers/XMPPEvents/MessageEvent.h +++ b/Swift/Controllers/XMPPEvents/MessageEvent.h @@ -7,8 +7,7 @@ #pragma once #include <cassert> - -#include <boost/shared_ptr.hpp> +#include <memory> #include <Swiften/Elements/Message.h> @@ -17,11 +16,11 @@ namespace Swift { class MessageEvent : public StanzaEvent { public: - typedef boost::shared_ptr<MessageEvent> ref; + typedef std::shared_ptr<MessageEvent> ref; - MessageEvent(boost::shared_ptr<Message> stanza) : stanza_(stanza), targetsMe_(true) {} + MessageEvent(std::shared_ptr<Message> stanza) : stanza_(stanza), targetsMe_(true) {} - boost::shared_ptr<Message> getStanza() {return stanza_;} + std::shared_ptr<Message> getStanza() {return stanza_;} bool isReadable() { return getStanza()->isError() || !getStanza()->getBody().get_value_or("").empty(); @@ -41,7 +40,7 @@ namespace Swift { } private: - boost::shared_ptr<Message> stanza_; + std::shared_ptr<Message> stanza_; bool targetsMe_; }; } diff --git a/Swift/Controllers/XMPPEvents/StanzaEvent.h b/Swift/Controllers/XMPPEvents/StanzaEvent.h index fe97e23..0ddcdbe 100644 --- a/Swift/Controllers/XMPPEvents/StanzaEvent.h +++ b/Swift/Controllers/XMPPEvents/StanzaEvent.h @@ -6,8 +6,9 @@ #pragma once +#include <memory> + #include <boost/date_time/posix_time/posix_time.hpp> -#include <boost/shared_ptr.hpp> #include <Swiften/Base/boost_bsignals.h> diff --git a/Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h b/Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h index 92922e9..85d3722 100644 --- a/Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h +++ b/Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h @@ -7,10 +7,9 @@ #pragma once #include <cassert> +#include <memory> #include <string> -#include <boost/shared_ptr.hpp> - #include <Swiften/Base/boost_bsignals.h> #include <Swiften/JID/JID.h> |