summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Burgess <pete.burgess@isode.com>2018-03-26 11:17:24 (GMT)
committerPeter Burgess <pete.burgess@isode.com>2018-03-27 12:58:17 (GMT)
commit860ef54501e8c32d91160f798c8f9ecf811f2501 (patch)
tree60e3621f634b10a64fcf5cb1c5da8279c08e78a3 /Swiften/Elements/ReferencePayload.h
parent92bba873587e0cfaf53aff6749d4537b13e275e8 (diff)
downloadswift-860ef54501e8c32d91160f798c8f9ecf811f2501.zip
swift-860ef54501e8c32d91160f798c8f9ecf811f2501.tar.bz2
Add new ReferencePayload element class, parser and serializer
Added a new element object ReferencePayload, and created the parser and serializer to handle this element. Currently no functionality to send references directly in swift, nor to render their contents. Test-Information: Unit tests written and passed for serializer and parser, testing various types of valid and invalid references, and testing references with embedded payloads. Change-Id: I81fd5d9e020fac1729640f297705806af97f6388
Diffstat (limited to 'Swiften/Elements/ReferencePayload.h')
-rw-r--r--Swiften/Elements/ReferencePayload.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/Swiften/Elements/ReferencePayload.h b/Swiften/Elements/ReferencePayload.h
new file mode 100644
index 0000000..b9a394e
--- /dev/null
+++ b/Swiften/Elements/ReferencePayload.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2018 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include <boost/optional.hpp>
+
+#include <Swiften/Base/API.h>
+#include <Swiften/Elements/Payload.h>
+
+namespace Swift {
+ /**
+ * reference from XEP-0372
+ */
+ class SWIFTEN_API ReferencePayload : public Payload {
+
+ public:
+
+ typedef std::shared_ptr<ReferencePayload> ref;
+
+ enum class Type {
+ Data,
+ Mention,
+ PubSub,
+ Unknown
+ };
+
+ ReferencePayload();
+
+ const Type& getType() const;
+ const boost::optional<std::string>& getUri() const;
+ const boost::optional<std::string>& getBegin() const;
+ const boost::optional<std::string>& getEnd() const;
+ const boost::optional<std::string>& getAnchor() const;
+
+ const std::vector<std::shared_ptr<Payload>>& getPayloads() const;
+
+ void setType(const Type& type);
+ void setUri(const boost::optional<std::string>& uri);
+ void setBegin(const boost::optional<std::string>& begin);
+ void setEnd(const boost::optional<std::string>& end);
+ void setAnchor(const boost::optional<std::string>& anchor);
+
+ void addPayload(const std::shared_ptr<Payload>& payload);
+
+ private:
+
+ Type type_;
+ boost::optional<std::string> uri_;
+ boost::optional<std::string> begin_;
+ boost::optional<std::string> end_;
+ boost::optional<std::string> anchor_;
+
+ std::vector<std::shared_ptr<Payload>> payloads_;
+ };
+}