diff --git a/include/Swiften/Elements/PubSubItem.h b/include/Swiften/Elements/PubSubItem.h index 554b7a76dbe928de0b802f49c0599dcd0e595d1e..f0b3ef7007c8162df847904f809aea97b1f52c75 100644 --- a/include/Swiften/Elements/PubSubItem.h +++ b/include/Swiften/Elements/PubSubItem.h @@ -14,12 +14,41 @@ namespace Swift { class PubSubItem : public Payload { public: - PubSubItem(const std::string &body = ""); + PubSubItem(); - const std::string& getData() const { return body_; } + 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; + + } - void setData(const std::string& body) { - body_ = body; + 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; } const std::string& getId() const { return id; } @@ -29,7 +58,7 @@ namespace Swift { } private: - std::string body_; + std::vector > payloads; std::string id; }; }