diff --git a/include/Swiften/Elements/PubSubPayload.h b/include/Swiften/Elements/PubSubPayload.h new file mode 100644 index 0000000000000000000000000000000000000000..46c8b82e5f7fc6df0fff8d1c176fdcaabc06d494 --- /dev/null +++ b/include/Swiften/Elements/PubSubPayload.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2012 Jan Kaluza + * Licensed under the Simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include + +#include +#include + +namespace Swift { + class PubSubPayload : public Payload { + public: + PubSubPayload(); + + void addPayload(boost::shared_ptr payload) { + payloads.push_back(payload); + } + + const std::vector > getPayloads() const { + return payloads; + } + + template + const std::vector > getPayloads() const { + std::vector > matched_payloads; + for (std::vector >::const_iterator i = payloads.begin(); i != payloads.end(); ++i) { + boost::shared_ptr result = boost::dynamic_pointer_cast(*i); + if (result) { + matched_payloads.push_back(result); + } + } + + return matched_payloads; + + } + + template + const boost::shared_ptr getPayload() const { + boost::shared_ptr result; + for (std::vector >::const_iterator i = payloads.begin(); i != payloads.end(); ++i) { + result = boost::dynamic_pointer_cast(*i); + if (result) { + return result; + } + } + + return result; + } + + private: + std::vector > payloads; + }; +}