summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/StanzaParser.cpp')
-rw-r--r--Swiften/Parser/StanzaParser.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/Swiften/Parser/StanzaParser.cpp b/Swiften/Parser/StanzaParser.cpp
index 64c4901..271fbf0 100644
--- a/Swiften/Parser/StanzaParser.cpp
+++ b/Swiften/Parser/StanzaParser.cpp
@@ -4,15 +4,16 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#include "Swiften/Parser/StanzaParser.h"
+#include <Swiften/Parser/StanzaParser.h>
#include <iostream>
+#include <boost/optional.hpp>
#include <cassert>
-#include "Swiften/Parser/PayloadParser.h"
-#include "Swiften/Parser/PayloadParserFactory.h"
-#include "Swiften/Parser/PayloadParserFactoryCollection.h"
-#include "Swiften/Parser/UnknownPayloadParser.h"
+#include <Swiften/Parser/PayloadParser.h>
+#include <Swiften/Parser/PayloadParserFactory.h>
+#include <Swiften/Parser/PayloadParserFactoryCollection.h>
+#include <Swiften/Parser/UnknownPayloadParser.h>
namespace Swift {
@@ -26,7 +27,7 @@ StanzaParser::~StanzaParser() {
void StanzaParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
if (inStanza()) {
if (!inPayload()) {
- assert(!currentPayloadParser_.get());
+ assert(!currentPayloadParser_);
PayloadParserFactory* payloadParserFactory = factories_->getPayloadParserFactory(element, ns, attributes);
if (payloadParserFactory) {
currentPayloadParser_.reset(payloadParserFactory->createPayloadParser());
@@ -35,21 +36,21 @@ void StanzaParser::handleStartElement(const std::string& element, const std::str
currentPayloadParser_.reset(new UnknownPayloadParser());
}
}
- assert(currentPayloadParser_.get());
+ assert(currentPayloadParser_);
currentPayloadParser_->handleStartElement(element, ns, attributes);
}
else {
- AttributeMap::const_iterator from = attributes.find("from");
- if (from != attributes.end()) {
- getStanza()->setFrom(JID(from->second));
+ boost::optional<std::string> from = attributes.getAttributeValue("from");
+ if (from) {
+ getStanza()->setFrom(JID(*from));
}
- AttributeMap::const_iterator to = attributes.find("to");
- if (to != attributes.end()) {
- getStanza()->setTo(JID(to->second));
+ boost::optional<std::string> to = attributes.getAttributeValue("to");
+ if (to) {
+ getStanza()->setTo(JID(*to));
}
- AttributeMap::const_iterator id = attributes.find("id");
- if (id != attributes.end()) {
- getStanza()->setID(id->second);
+ boost::optional<std::string> id = attributes.getAttributeValue("id");
+ if (id) {
+ getStanza()->setID(*id);
}
handleStanzaAttributes(attributes);
}
@@ -59,7 +60,7 @@ void StanzaParser::handleStartElement(const std::string& element, const std::str
void StanzaParser::handleEndElement(const std::string& element, const std::string& ns) {
assert(inStanza());
if (inPayload()) {
- assert(currentPayloadParser_.get());
+ assert(currentPayloadParser_);
currentPayloadParser_->handleEndElement(element, ns);
--currentDepth_;
if (!inPayload()) {
@@ -76,7 +77,7 @@ void StanzaParser::handleEndElement(const std::string& element, const std::strin
}
void StanzaParser::handleCharacterData(const std::string& data) {
- if (currentPayloadParser_.get()) {
+ if (currentPayloadParser_) {
currentPayloadParser_->handleCharacterData(data);
}
}