/* * Copyright (c) 2012 Mateusz Piękos * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ #include #include namespace Swift { WhiteboardParser::WhiteboardParser() : level_(0) { } 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(""))); } ++level_; } void WhiteboardParser::handleEndElement(const std::string& element, const std::string&) { --level_; if (level_ == 0) { getPayloadInternal()->setData(data_); } } void WhiteboardParser::handleCharacterData(const std::string& data) { data_ += data; } WhiteboardPayload::Type WhiteboardParser::stringToType(const std::string& type) const { if (type.empty()) { return WhiteboardPayload::Data; } else if (type == "session-request") { return WhiteboardPayload::SessionRequest; } else if (type == "session-accept") { return WhiteboardPayload::SessionAccept; } else if (type == "session-terminate") { return WhiteboardPayload::SessionTerminate; } } }