diff options
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp')
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp index 01a58e3..2743ff6 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.cpp @@ -1,17 +1,15 @@ /* - * Copyright (c) 2013 Isode Limited. + * Copyright (c) 2013-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ -#pragma clang diagnostic ignored "-Wunused-private-field" - #include <Swiften/Serializer/PayloadSerializers/PubSubEventItemSerializer.h> -#include <Swiften/Serializer/XML/XMLElement.h> -#include <boost/smart_ptr/make_shared.hpp> + +#include <memory> #include <Swiften/Serializer/PayloadSerializerCollection.h> -#include <Swiften/Base/foreach.h> +#include <Swiften/Serializer/XML/XMLElement.h> #include <Swiften/Serializer/XML/XMLRawTextNode.h> using namespace Swift; @@ -22,24 +20,24 @@ PubSubEventItemSerializer::PubSubEventItemSerializer(PayloadSerializerCollection PubSubEventItemSerializer::~PubSubEventItemSerializer() { } -std::string PubSubEventItemSerializer::serializePayload(boost::shared_ptr<PubSubEventItem> payload) const { - if (!payload) { - return ""; - } - XMLElement element("item", "http://jabber.org/protocol/pubsub#event"); - if (payload->getNode()) { - element.setAttribute("node", *payload->getNode()); - } - if (payload->getPublisher()) { - element.setAttribute("publisher", *payload->getPublisher()); - } - foreach(boost::shared_ptr<Payload> item, payload->getData()) { - element.addNode(boost::make_shared<XMLRawTextNode>(serializers->getPayloadSerializer(item)->serialize(item))); - } - if (payload->getID()) { - element.setAttribute("id", *payload->getID()); - } - return element.serialize(); +std::string PubSubEventItemSerializer::serializePayload(std::shared_ptr<PubSubEventItem> payload) const { + if (!payload) { + return ""; + } + XMLElement element("item", "http://jabber.org/protocol/pubsub#event"); + if (payload->getNode()) { + element.setAttribute("node", *payload->getNode()); + } + if (payload->getPublisher()) { + element.setAttribute("publisher", *payload->getPublisher()); + } + for (const auto& item : payload->getData()) { + element.addNode(std::make_shared<XMLRawTextNode>(serializers->getPayloadSerializer(item)->serialize(item))); + } + if (payload->getID()) { + element.setAttribute("id", *payload->getID()); + } + return element.serialize(); } |