summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Piekos <mateuszpiekos@gmail.com>2012-06-15 13:47:48 (GMT)
committerMateusz Piekos <mateuszpiekos@gmail.com>2012-06-15 13:47:48 (GMT)
commitf3cc4c80787657ea770468915ec716dea2676d22 (patch)
treec4645d6e1376d7f327de35522d163510d8ed7939 /Swiften/Parser
parent1dc6b7f7a3d96df848edad85c0d07d99340e3a3e (diff)
downloadswift-contrib-f3cc4c80787657ea770468915ec716dea2676d22.zip
swift-contrib-f3cc4c80787657ea770468915ec716dea2676d22.tar.bz2
Moved elements parsing to WhiteboardParser
Diffstat (limited to 'Swiften/Parser')
-rw-r--r--Swiften/Parser/PayloadParsers/WhiteboardParser.cpp12
-rw-r--r--Swiften/Parser/PayloadParsers/WhiteboardParser.h1
2 files changed, 12 insertions, 1 deletions
diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp
index 4306497..ef3c119 100644
--- a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp
+++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp
@@ -5,7 +5,9 @@
*/
#include <Swiften/Parser/PayloadParsers/WhiteboardParser.h>
+#include <Swiften/Whiteboard/Elements/WhiteboardLineElement.h>
#include <boost/optional.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
namespace Swift {
WhiteboardParser::WhiteboardParser() : level_(0) {
@@ -13,8 +15,16 @@ namespace Swift {
void WhiteboardParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) {
if (level_ == 0) {
-// std::string type = attributes.getAttribute("type");
getPayloadInternal()->setType(stringToType(attributes.getAttributeValue("type").get_value_or("")));
+ } else if (level_ == 1) {
+ if (element == "line") {
+ int x1 = std::atoi(attributes.getAttributeValue("x1").get_value_or("0").c_str());
+ int y1 = std::atoi(attributes.getAttributeValue("y1").get_value_or("0").c_str());
+ int x2 = std::atoi(attributes.getAttributeValue("x2").get_value_or("0").c_str());
+ int y2 = std::atoi(attributes.getAttributeValue("y2").get_value_or("0").c_str());
+ WhiteboardLineElement::ref whiteboardElement = boost::make_shared<WhiteboardLineElement>(x1, y1, x2, y2);
+ getPayloadInternal()->setElement(whiteboardElement);
+ }
}
++level_;
}
diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.h b/Swiften/Parser/PayloadParsers/WhiteboardParser.h
index faa698b..79d0f27 100644
--- a/Swiften/Parser/PayloadParsers/WhiteboardParser.h
+++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.h
@@ -8,6 +8,7 @@
#include <Swiften/Elements/WhiteboardPayload.h>
#include <Swiften/Parser/GenericPayloadParser.h>
+#include <Swiften/Whiteboard/Elements/WhiteboardElement.h>
namespace Swift {
class WhiteboardParser : public Swift::GenericPayloadParser<WhiteboardPayload> {