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/Examples
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/Examples')
-rw-r--r--Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp2
-rw-r--r--Swiften/Examples/LinkLocalTool/main.cpp6
-rw-r--r--Swiften/Examples/MUCListAndJoin/MUCListAndJoin.cpp10
-rw-r--r--Swiften/Examples/NetworkTool/main.cpp6
-rw-r--r--Swiften/Examples/ParserTester/ParserTester.cpp2
-rw-r--r--Swiften/Examples/SendFile/ReceiveFile.cpp6
-rw-r--r--Swiften/Examples/SendFile/SendFile.cpp2
-rw-r--r--Swiften/Examples/SendMessage/SendMessage.cpp2
8 files changed, 18 insertions, 18 deletions
diff --git a/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp b/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp
index 44a5796..c539691 100644
--- a/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp
+++ b/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp
@@ -30,7 +30,7 @@ static JID recipient;
static int exitCode = CANNOT_CONNECT;
static boost::bsignals::connection errorConnection;
-static void handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo> /*info*/, ErrorPayload::ref error) {
+static void handleServerDiscoInfoResponse(std::shared_ptr<DiscoInfo> /*info*/, ErrorPayload::ref error) {
if (!error) {
errorConnection.disconnect();
client->disconnect();
diff --git a/Swiften/Examples/LinkLocalTool/main.cpp b/Swiften/Examples/LinkLocalTool/main.cpp
index 37804fb..a853f0e 100644
--- a/Swiften/Examples/LinkLocalTool/main.cpp
+++ b/Swiften/Examples/LinkLocalTool/main.cpp
@@ -24,11 +24,11 @@ int main(int argc, char* argv[]) {
SimpleEventLoop eventLoop;
PlatformDNSSDQuerierFactory factory(&eventLoop);
- boost::shared_ptr<DNSSDQuerier> querier = factory.createQuerier();
+ std::shared_ptr<DNSSDQuerier> querier = factory.createQuerier();
querier->start();
if (std::string(argv[1]) == "browse") {
- boost::shared_ptr<DNSSDBrowseQuery> browseQuery = querier->createBrowseQuery();
+ std::shared_ptr<DNSSDBrowseQuery> browseQuery = querier->createBrowseQuery();
browseQuery->startBrowsing();
eventLoop.run();
browseQuery->stopBrowsing();
@@ -38,7 +38,7 @@ int main(int argc, char* argv[]) {
std::cerr << "Invalid parameters" << std::endl;
return -1;
}
- boost::shared_ptr<DNSSDResolveServiceQuery> resolveQuery = querier->createResolveServiceQuery(DNSSDServiceID(argv[2], argv[3], argv[4]));
+ std::shared_ptr<DNSSDResolveServiceQuery> resolveQuery = querier->createResolveServiceQuery(DNSSDServiceID(argv[2], argv[3], argv[4]));
resolveQuery->start();
eventLoop.run();
std::cerr << "Done running" << std::endl;
diff --git a/Swiften/Examples/MUCListAndJoin/MUCListAndJoin.cpp b/Swiften/Examples/MUCListAndJoin/MUCListAndJoin.cpp
index 1aaebac..c3983f1 100644
--- a/Swiften/Examples/MUCListAndJoin/MUCListAndJoin.cpp
+++ b/Swiften/Examples/MUCListAndJoin/MUCListAndJoin.cpp
@@ -5,9 +5,9 @@
*/
#include <iostream>
+#include <memory>
#include <boost/optional.hpp>
-#include <boost/shared_ptr.hpp>
#include <Swiften/Base/foreach.h>
#include <Swiften/Client/Client.h>
@@ -27,7 +27,7 @@ using namespace std;
static SimpleEventLoop eventLoop;
static BoostNetworkFactories networkFactories(&eventLoop);
-static boost::shared_ptr<Client> client;
+static std::shared_ptr<Client> client;
static MUC::ref muc;
static JID mucJID;
static JID roomJID;
@@ -39,7 +39,7 @@ static void joinMUC() {
muc->joinAs("SwiftExample");
}
-static void handleRoomsItemsResponse(boost::shared_ptr<DiscoItems> items, ErrorPayload::ref error) {
+static void handleRoomsItemsResponse(std::shared_ptr<DiscoItems> items, ErrorPayload::ref error) {
if (error) {
cout << "Error fetching list of rooms." << endl;
return;
@@ -73,7 +73,7 @@ static void handleDisconnected(const boost::optional<ClientError>&) {
cout << "Disconnected." << endl;
}
-static void handleIncomingMessage(boost::shared_ptr<Message> message) {
+static void handleIncomingMessage(std::shared_ptr<Message> message) {
if (message->getFrom().toBare() == roomJID) {
cout << "[ " << roomJID << " ] " << message->getFrom().getResource() << ": " << message->getBody().get_value_or("") << endl;
}
@@ -91,7 +91,7 @@ int main(int argc, char* argv[]) {
}
else {
mucJID = JID(argv[3]);
- client = boost::make_shared<Client>(JID(argv[1]), string(argv[2]), &networkFactories);
+ client = std::make_shared<Client>(JID(argv[1]), string(argv[2]), &networkFactories);
client->setAlwaysTrustCertificates();
// Enable the following line for detailed XML logging
diff --git a/Swiften/Examples/NetworkTool/main.cpp b/Swiften/Examples/NetworkTool/main.cpp
index 0cedfa7..c50ab67 100644
--- a/Swiften/Examples/NetworkTool/main.cpp
+++ b/Swiften/Examples/NetworkTool/main.cpp
@@ -57,7 +57,7 @@ int main(int argc, char* argv[]) {
PlatformNATTraversalWorker natTraverser(&eventLoop);
if (std::string(argv[1]) == "get-public-ip") {
- boost::shared_ptr<NATTraversalGetPublicIPRequest> query = natTraverser.createGetPublicIPRequest();
+ std::shared_ptr<NATTraversalGetPublicIPRequest> query = natTraverser.createGetPublicIPRequest();
query->onResult.connect(boost::bind(&handleGetPublicIPRequestResponse, _1));
query->start();
eventLoop.run();
@@ -66,7 +66,7 @@ int main(int argc, char* argv[]) {
if (argc < 4) {
std::cerr << "Invalid parameters" << std::endl;
}
- boost::shared_ptr<NATTraversalForwardPortRequest> query = natTraverser.createForwardPortRequest(boost::lexical_cast<int>(argv[2]), boost::lexical_cast<int>(argv[3]));
+ std::shared_ptr<NATTraversalForwardPortRequest> query = natTraverser.createForwardPortRequest(boost::lexical_cast<int>(argv[2]), boost::lexical_cast<int>(argv[3]));
query->onResult.connect(boost::bind(&handleGetForwardPortRequestResponse, _1));
query->start();
eventLoop.run();
@@ -75,7 +75,7 @@ int main(int argc, char* argv[]) {
if (argc < 4) {
std::cerr << "Invalid parameters" << std::endl;
}
- boost::shared_ptr<NATTraversalRemovePortForwardingRequest> query = natTraverser.createRemovePortForwardingRequest(boost::lexical_cast<int>(argv[2]), boost::lexical_cast<int>(argv[3]));
+ std::shared_ptr<NATTraversalRemovePortForwardingRequest> query = natTraverser.createRemovePortForwardingRequest(boost::lexical_cast<int>(argv[2]), boost::lexical_cast<int>(argv[3]));
query->onResult.connect(boost::bind(&handleRemovePortForwardingRequestResponse, _1));
query->start();
eventLoop.run();
diff --git a/Swiften/Examples/ParserTester/ParserTester.cpp b/Swiften/Examples/ParserTester/ParserTester.cpp
index af79ece..71b0611 100644
--- a/Swiften/Examples/ParserTester/ParserTester.cpp
+++ b/Swiften/Examples/ParserTester/ParserTester.cpp
@@ -22,7 +22,7 @@ class MyXMPPParserClient : public XMPPParserClient {
virtual void handleStreamStart(const ProtocolHeader&) {
std::cout << "-> Stream start" << std::endl;
}
- virtual void handleElement(boost::shared_ptr<ToplevelElement> element) {
+ virtual void handleElement(std::shared_ptr<ToplevelElement> element) {
std::cout << "-> Element " << typeid(*element.get()).name() << std::endl;
}
virtual void handleStreamEnd() {
diff --git a/Swiften/Examples/SendFile/ReceiveFile.cpp b/Swiften/Examples/SendFile/ReceiveFile.cpp
index c6e75e8..0b61987 100644
--- a/Swiften/Examples/SendFile/ReceiveFile.cpp
+++ b/Swiften/Examples/SendFile/ReceiveFile.cpp
@@ -5,10 +5,10 @@
*/
#include <iostream>
+#include <memory>
#include <boost/bind.hpp>
#include <boost/filesystem.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Base/Log.h>
#include <Swiften/Base/foreach.h>
@@ -82,7 +82,7 @@ class FileReceiver {
void handleIncomingFileTransfer(IncomingFileTransfer::ref transfer) {
SWIFT_LOG(debug) << "foo" << std::endl;
incomingFileTransfers.push_back(transfer);
- boost::shared_ptr<FileWriteBytestream> out = boost::make_shared<FileWriteBytestream>("out");
+ std::shared_ptr<FileWriteBytestream> out = std::make_shared<FileWriteBytestream>("out");
transfer->onFinished.connect(boost::bind(&FileReceiver::handleFileTransferFinished, this, _1, out));
transfer->accept(out);
}
@@ -94,7 +94,7 @@ class FileReceiver {
void handleFileTransferFinished(
const boost::optional<FileTransferError>& error,
- boost::shared_ptr<FileWriteBytestream> out) {
+ std::shared_ptr<FileWriteBytestream> out) {
std::cout << "File transfer finished" << std::endl;
out->close();
if (error) {
diff --git a/Swiften/Examples/SendFile/SendFile.cpp b/Swiften/Examples/SendFile/SendFile.cpp
index 1b70747..0e1fb23 100644
--- a/Swiften/Examples/SendFile/SendFile.cpp
+++ b/Swiften/Examples/SendFile/SendFile.cpp
@@ -67,7 +67,7 @@ class FileSender {
void handleCapsChanged(JID jid) {
if (jid.toBare() == recipient) {
// create ReadBytestream from file
- boost::shared_ptr<FileReadBytestream> fileStream = boost::make_shared<FileReadBytestream>(file);
+ std::shared_ptr<FileReadBytestream> fileStream = std::make_shared<FileReadBytestream>(file);
outgoingFileTransfer = client->getFileTransferManager()->createOutgoingFileTransfer(recipient, file, "Some File!", fileStream);
diff --git a/Swiften/Examples/SendMessage/SendMessage.cpp b/Swiften/Examples/SendMessage/SendMessage.cpp
index 9a954f2..2458e65 100644
--- a/Swiften/Examples/SendMessage/SendMessage.cpp
+++ b/Swiften/Examples/SendMessage/SendMessage.cpp
@@ -30,7 +30,7 @@ static boost::bsignals::connection errorConnection;
static void handleConnected() {
- boost::shared_ptr<Message> message(new Message());
+ std::shared_ptr<Message> message(new Message());
message->setBody(messageBody);
message->setTo(recipient);
client->sendMessage(message);