summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/PayloadParsers/ThreadParser.cpp')
-rw-r--r--Swiften/Parser/PayloadParsers/ThreadParser.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/Swiften/Parser/PayloadParsers/ThreadParser.cpp b/Swiften/Parser/PayloadParsers/ThreadParser.cpp
new file mode 100644
index 0000000..0d0aca8
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/ThreadParser.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#include <Swiften/Parser/PayloadParsers/ThreadParser.h>
+
+#include <boost/optional.hpp>
+
+namespace Swift {
+
+ThreadParser::ThreadParser() : level_(0) {
+}
+
+ThreadParser::~ThreadParser() {
+}
+
+void ThreadParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) {
+ ++level_;
+ if (element == "thread") {
+ getPayloadInternal()->setParent(attributes.getAttributeValue("parent").get_value_or(""));
+ }
+}
+
+void ThreadParser::handleEndElement(const std::string&, const std::string&) {
+ --level_;
+ if (level_ == 0) {
+ getPayloadInternal()->setText(text_);
+ }
+}
+
+void ThreadParser::handleCharacterData(const std::string& data) {
+ if (level_ == 1) {
+ text_ += data;
+ }
+}
+
+}