/* * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #pragma once #include #include #include #include namespace Swift { template class BlockSerializer : public GenericPayloadSerializer { public: BlockSerializer(std::string tag) : GenericPayloadSerializer(), tag(tag) { } virtual std::string serializePayload(boost::shared_ptr payload) const { XMLElement element(tag, "urn:xmpp:blocking"); const std::vector& items = payload->getItems(); for (std::vector::const_iterator i = items.begin(); i != items.end(); ++i) { boost::shared_ptr item = boost::make_shared("item"); item->setAttribute("jid", *i); element.addNode(item); } return element.serialize(); } private: std::string tag; }; }