summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-04-01 17:23:49 (GMT)
committerTobias Markmann <tm@ayena.de>2016-04-04 08:28:23 (GMT)
commit741c45b74d5f634622eb5f757c49323274fb8937 (patch)
treeb9cfa6c2fe2e79e03cc8cb7c1ca1e9cf45aa5328 /Swiften/StreamStack
parenteddd92ed76ae68cb1e202602fd3ebd11b69191a2 (diff)
downloadswift-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 'Swiften/StreamStack')
-rw-r--r--Swiften/StreamStack/ConnectionLayer.cpp6
-rw-r--r--Swiften/StreamStack/ConnectionLayer.h10
-rw-r--r--Swiften/StreamStack/StreamStack.h3
-rw-r--r--Swiften/StreamStack/TLSLayer.cpp2
-rw-r--r--Swiften/StreamStack/TLSLayer.h6
-rw-r--r--Swiften/StreamStack/UnitTest/StreamStackTest.cpp16
-rw-r--r--Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp6
-rw-r--r--Swiften/StreamStack/WhitespacePingLayer.h5
-rw-r--r--Swiften/StreamStack/XMPPLayer.cpp4
-rw-r--r--Swiften/StreamStack/XMPPLayer.h9
10 files changed, 34 insertions, 33 deletions
diff --git a/Swiften/StreamStack/ConnectionLayer.cpp b/Swiften/StreamStack/ConnectionLayer.cpp
index 09b6f87..b0c4deb 100644
--- a/Swiften/StreamStack/ConnectionLayer.cpp
+++ b/Swiften/StreamStack/ConnectionLayer.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.
*/
@@ -10,7 +10,7 @@
namespace Swift {
-ConnectionLayer::ConnectionLayer(boost::shared_ptr<Connection> connection) : connection(connection) {
+ConnectionLayer::ConnectionLayer(std::shared_ptr<Connection> connection) : connection(connection) {
connection->onDataRead.connect(boost::bind(&ConnectionLayer::handleDataRead, this, _1));
}
@@ -18,7 +18,7 @@ ConnectionLayer::~ConnectionLayer() {
connection->onDataRead.disconnect(boost::bind(&ConnectionLayer::handleDataRead, this, _1));
}
-void ConnectionLayer::handleDataRead(boost::shared_ptr<SafeByteArray> data) {
+void ConnectionLayer::handleDataRead(std::shared_ptr<SafeByteArray> data) {
writeDataToParentLayer(*data);
}
diff --git a/Swiften/StreamStack/ConnectionLayer.h b/Swiften/StreamStack/ConnectionLayer.h
index c2d0fde..d1775ee 100644
--- a/Swiften/StreamStack/ConnectionLayer.h
+++ b/Swiften/StreamStack/ConnectionLayer.h
@@ -1,12 +1,12 @@
/*
- * 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 <boost/shared_ptr.hpp>
+#include <memory>
#include <Swiften/Base/API.h>
#include <Swiften/Network/Connection.h>
@@ -15,7 +15,7 @@
namespace Swift {
class SWIFTEN_API ConnectionLayer : public LowLayer {
public:
- ConnectionLayer(boost::shared_ptr<Connection> connection);
+ ConnectionLayer(std::shared_ptr<Connection> connection);
virtual ~ConnectionLayer();
void writeData(const SafeByteArray& data) {
@@ -23,9 +23,9 @@ namespace Swift {
}
private:
- void handleDataRead(boost::shared_ptr<SafeByteArray>);
+ void handleDataRead(std::shared_ptr<SafeByteArray>);
private:
- boost::shared_ptr<Connection> connection;
+ std::shared_ptr<Connection> connection;
};
}
diff --git a/Swiften/StreamStack/StreamStack.h b/Swiften/StreamStack/StreamStack.h
index 74b92d7..718aa32 100644
--- a/Swiften/StreamStack/StreamStack.h
+++ b/Swiften/StreamStack/StreamStack.h
@@ -6,10 +6,9 @@
#pragma once
+#include <memory>
#include <vector>
-#include <boost/shared_ptr.hpp>
-
#include <Swiften/Base/API.h>
#include <Swiften/Base/boost_bsignals.h>
#include <Swiften/Elements/Stanza.h>
diff --git a/Swiften/StreamStack/TLSLayer.cpp b/Swiften/StreamStack/TLSLayer.cpp
index 3ab885a..ced879e 100644
--- a/Swiften/StreamStack/TLSLayer.cpp
+++ b/Swiften/StreamStack/TLSLayer.cpp
@@ -49,7 +49,7 @@ std::vector<Certificate::ref> TLSLayer::getPeerCertificateChain() const {
return context->getPeerCertificateChain();
}
-boost::shared_ptr<CertificateVerificationError> TLSLayer::getPeerCertificateVerificationError() const {
+std::shared_ptr<CertificateVerificationError> TLSLayer::getPeerCertificateVerificationError() const {
return context->getPeerCertificateVerificationError();
}
diff --git a/Swiften/StreamStack/TLSLayer.h b/Swiften/StreamStack/TLSLayer.h
index b9072f3..8782753 100644
--- a/Swiften/StreamStack/TLSLayer.h
+++ b/Swiften/StreamStack/TLSLayer.h
@@ -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.
*/
@@ -30,7 +30,7 @@ namespace Swift {
Certificate::ref getPeerCertificate() const;
std::vector<Certificate::ref> getPeerCertificateChain() const;
- boost::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;
+ std::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;
void writeData(const SafeByteArray& data);
void handleDataRead(const SafeByteArray& data);
@@ -40,7 +40,7 @@ namespace Swift {
}
public:
- boost::signal<void (boost::shared_ptr<TLSError>)> onError;
+ boost::signal<void (std::shared_ptr<TLSError>)> onError;
boost::signal<void ()> onConnected;
private:
diff --git a/Swiften/StreamStack/UnitTest/StreamStackTest.cpp b/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
index 7044ad9..6d50b77 100644
--- a/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
+++ b/Swiften/StreamStack/UnitTest/StreamStackTest.cpp
@@ -61,7 +61,7 @@ class StreamStackTest : public CppUnit::TestFixture {
void testWriteData_OneIntermediateStream() {
StreamStack testling(xmppStream_, physicalStream_);
- boost::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
+ std::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
testling.addLayer(xStream.get());
xmppStream_->writeData("foo");
@@ -72,8 +72,8 @@ class StreamStackTest : public CppUnit::TestFixture {
void testWriteData_TwoIntermediateStreamStack() {
StreamStack testling(xmppStream_, physicalStream_);
- boost::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
- boost::shared_ptr<MyStreamLayer> yStream(new MyStreamLayer("Y"));
+ std::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
+ std::shared_ptr<MyStreamLayer> yStream(new MyStreamLayer("Y"));
testling.addLayer(xStream.get());
testling.addLayer(yStream.get());
@@ -95,7 +95,7 @@ class StreamStackTest : public CppUnit::TestFixture {
void testReadData_OneIntermediateStream() {
StreamStack testling(xmppStream_, physicalStream_);
xmppStream_->onElement.connect(boost::bind(&StreamStackTest::handleElement, this, _1));
- boost::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("<"));
+ std::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("<"));
testling.addLayer(xStream.get());
physicalStream_->onDataRead(createSafeByteArray("stream:stream xmlns:stream='http://etherx.jabber.org/streams'><presence/>"));
@@ -106,8 +106,8 @@ class StreamStackTest : public CppUnit::TestFixture {
void testReadData_TwoIntermediateStreamStack() {
StreamStack testling(xmppStream_, physicalStream_);
xmppStream_->onElement.connect(boost::bind(&StreamStackTest::handleElement, this, _1));
- boost::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("s"));
- boost::shared_ptr<MyStreamLayer> yStream(new MyStreamLayer("<"));
+ std::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("s"));
+ std::shared_ptr<MyStreamLayer> yStream(new MyStreamLayer("<"));
testling.addLayer(xStream.get());
testling.addLayer(yStream.get());
@@ -119,7 +119,7 @@ class StreamStackTest : public CppUnit::TestFixture {
void testAddLayer_ExistingOnWriteDataSlot() {
StreamStack testling(xmppStream_, physicalStream_);
xmppStream_->onWriteData.connect(boost::bind(&StreamStackTest::handleWriteData, this, _1));
- boost::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
+ std::shared_ptr<MyStreamLayer> xStream(new MyStreamLayer("X"));
testling.addLayer(xStream.get());
xmppStream_->writeData("foo");
@@ -127,7 +127,7 @@ class StreamStackTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(1, dataWriteReceived_);
}
- void handleElement(boost::shared_ptr<ToplevelElement>) {
+ void handleElement(std::shared_ptr<ToplevelElement>) {
++elementsReceived_;
}
diff --git a/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp b/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
index 86e02ba..6d1d537 100644
--- a/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
+++ b/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
@@ -85,7 +85,7 @@ class XMPPLayerTest : public CppUnit::TestFixture {
}
void testWriteElement() {
- testling_->writeElement(boost::make_shared<Presence>());
+ testling_->writeElement(std::make_shared<Presence>());
CPPUNIT_ASSERT_EQUAL(std::string("<presence/>"), lowLayer_->writtenData);
}
@@ -96,11 +96,11 @@ class XMPPLayerTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT_EQUAL(std::string("</stream:stream>"), lowLayer_->writtenData);
}
- void handleElement(boost::shared_ptr<ToplevelElement>) {
+ void handleElement(std::shared_ptr<ToplevelElement>) {
++elementsReceived_;
}
- void handleElementAndReset(boost::shared_ptr<ToplevelElement>) {
+ void handleElementAndReset(std::shared_ptr<ToplevelElement>) {
++elementsReceived_;
testling_->resetParser();
}
diff --git a/Swiften/StreamStack/WhitespacePingLayer.h b/Swiften/StreamStack/WhitespacePingLayer.h
index 41189ba..c9ffe92 100644
--- a/Swiften/StreamStack/WhitespacePingLayer.h
+++ b/Swiften/StreamStack/WhitespacePingLayer.h
@@ -6,8 +6,9 @@
#pragma once
+#include <memory>
+
#include <boost/noncopyable.hpp>
-#include <boost/shared_ptr.hpp>
#include <Swiften/Base/API.h>
#include <Swiften/StreamStack/StreamLayer.h>
@@ -35,6 +36,6 @@ namespace Swift {
private:
bool isActive;
- boost::shared_ptr<Timer> timer;
+ std::shared_ptr<Timer> timer;
};
}
diff --git a/Swiften/StreamStack/XMPPLayer.cpp b/Swiften/StreamStack/XMPPLayer.cpp
index e0d683c..2eed906 100644
--- a/Swiften/StreamStack/XMPPLayer.cpp
+++ b/Swiften/StreamStack/XMPPLayer.cpp
@@ -41,7 +41,7 @@ void XMPPLayer::writeFooter() {
writeDataInternal(createSafeByteArray(xmppSerializer_->serializeFooter()));
}
-void XMPPLayer::writeElement(boost::shared_ptr<ToplevelElement> element) {
+void XMPPLayer::writeElement(std::shared_ptr<ToplevelElement> element) {
writeDataInternal(xmppSerializer_->serializeElement(element));
}
@@ -81,7 +81,7 @@ void XMPPLayer::handleStreamStart(const ProtocolHeader& header) {
onStreamStart(header);
}
-void XMPPLayer::handleElement(boost::shared_ptr<ToplevelElement> stanza) {
+void XMPPLayer::handleElement(std::shared_ptr<ToplevelElement> stanza) {
onElement(stanza);
}
diff --git a/Swiften/StreamStack/XMPPLayer.h b/Swiften/StreamStack/XMPPLayer.h
index 25d48bf..74ea519 100644
--- a/Swiften/StreamStack/XMPPLayer.h
+++ b/Swiften/StreamStack/XMPPLayer.h
@@ -6,8 +6,9 @@
#pragma once
+#include <memory>
+
#include <boost/noncopyable.hpp>
-#include <boost/shared_ptr.hpp>
#include <Swiften/Base/API.h>
#include <Swiften/Base/SafeByteArray.h>
@@ -39,7 +40,7 @@ namespace Swift {
void writeHeader(const ProtocolHeader& header);
void writeFooter();
- void writeElement(boost::shared_ptr<ToplevelElement>);
+ void writeElement(std::shared_ptr<ToplevelElement>);
void writeData(const std::string& data);
void resetParser();
@@ -50,14 +51,14 @@ namespace Swift {
public:
boost::signal<void (const ProtocolHeader&)> onStreamStart;
- boost::signal<void (boost::shared_ptr<ToplevelElement>)> onElement;
+ boost::signal<void (std::shared_ptr<ToplevelElement>)> onElement;
boost::signal<void (const SafeByteArray&)> onWriteData;
boost::signal<void (const SafeByteArray&)> onDataRead;
boost::signal<void ()> onError;
private:
void handleStreamStart(const ProtocolHeader&);
- void handleElement(boost::shared_ptr<ToplevelElement>);
+ void handleElement(std::shared_ptr<ToplevelElement>);
void handleStreamEnd();
void doResetParser();