summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/PayloadParsers/WhiteboardParser.cpp')
-rw-r--r--Swiften/Parser/PayloadParsers/WhiteboardParser.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp
index ea00335..cdcbb8c 100644
--- a/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp
+++ b/Swiften/Parser/PayloadParsers/WhiteboardParser.cpp
@@ -21,6 +21,7 @@
namespace Swift {
WhiteboardParser::WhiteboardParser() : actualIsText(false), level_(0) {
+ operation = NULL;
}
void WhiteboardParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) {
@@ -30,31 +31,21 @@ namespace Swift {
std::string type = attributes.getAttributeValue("type").get_value_or("");
if (type == "insert") {
WhiteboardInsertOperation::ref insertOp = boost::make_shared<WhiteboardInsertOperation>();
- try {
- insertOp->setID(attributes.getAttributeValue("id").get_value_or(""));
- insertOp->setParentID(attributes.getAttributeValue("parentid").get_value_or(""));
- insertOp->setPos(boost::lexical_cast<int>(attributes.getAttributeValue("pos").get_value_or("0")));
- } catch (boost::bad_lexical_cast&) {
- }
operation = insertOp;
} else if (type == "update") {
WhiteboardUpdateOperation::ref updateOp = boost::make_shared<WhiteboardUpdateOperation>();
- try {
- updateOp->setID(attributes.getAttributeValue("id").get_value_or(""));
- updateOp->setParentID(attributes.getAttributeValue("parentid").get_value_or(""));
- updateOp->setPos(boost::lexical_cast<int>(attributes.getAttributeValue("pos").get_value_or("0")));
- } catch (boost::bad_lexical_cast&) {
- }
operation = updateOp;
} else if (type == "delete") {
WhiteboardDeleteOperation::ref deleteOp = boost::make_shared<WhiteboardDeleteOperation>();
+ operation = deleteOp;
+ }
+ if (operation) {
try {
- deleteOp->setID(attributes.getAttributeValue("id").get_value_or(""));
- deleteOp->setParentID(attributes.getAttributeValue("parentid").get_value_or(""));
- deleteOp->setPos(boost::lexical_cast<int>(attributes.getAttributeValue("pos").get_value_or("0")));
+ operation->setID(attributes.getAttributeValue("id").get_value_or(""));
+ operation->setParentID(attributes.getAttributeValue("parentid").get_value_or(""));
+ operation->setPos(boost::lexical_cast<int>(attributes.getAttributeValue("pos").get_value_or("0")));
} catch (boost::bad_lexical_cast&) {
}
- operation = deleteOp;
}
} else if (level_ == 2) {