diff options
Diffstat (limited to 'Swiften/Parser/StanzaParser.cpp')
m--------- | Swiften | 0 | ||||
-rw-r--r-- | Swiften/Parser/StanzaParser.cpp | 78 |
2 files changed, 0 insertions, 78 deletions
diff --git a/Swiften b/Swiften new file mode 160000 +Subproject 8213ba16d0043d2461f4b031c881d61dda5a38c diff --git a/Swiften/Parser/StanzaParser.cpp b/Swiften/Parser/StanzaParser.cpp deleted file mode 100644 index 952265c..0000000 --- a/Swiften/Parser/StanzaParser.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "Swiften/Parser/StanzaParser.h" - -#include <iostream> -#include <cassert> - -#include "Swiften/Parser/PayloadParser.h" -#include "Swiften/Parser/PayloadParserFactory.h" -#include "Swiften/Parser/PayloadParserFactoryCollection.h" -#include "Swiften/Parser/UnknownPayloadParser.h" - -namespace Swift { - -StanzaParser::StanzaParser(PayloadParserFactoryCollection* factories) : - currentDepth_(0), factories_(factories) { -} - -StanzaParser::~StanzaParser() { -} - -void StanzaParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { - if (inStanza()) { - if (!inPayload()) { - assert(!currentPayloadParser_.get()); - PayloadParserFactory* payloadParserFactory = factories_->getPayloadParserFactory(element, ns, attributes); - if (payloadParserFactory) { - currentPayloadParser_.reset(payloadParserFactory->createPayloadParser()); - } - else { - currentPayloadParser_.reset(new UnknownPayloadParser()); - } - } - assert(currentPayloadParser_.get()); - currentPayloadParser_->handleStartElement(element, ns, attributes); - } - else { - AttributeMap::const_iterator from = attributes.find("from"); - if (from != attributes.end()) { - getStanza()->setFrom(JID(from->second)); - } - AttributeMap::const_iterator to = attributes.find("to"); - if (to != attributes.end()) { - getStanza()->setTo(JID(to->second)); - } - AttributeMap::const_iterator id = attributes.find("id"); - if (id != attributes.end()) { - getStanza()->setID(id->second); - } - handleStanzaAttributes(attributes); - } - ++currentDepth_; -} - -void StanzaParser::handleEndElement(const String& element, const String& ns) { - assert(inStanza()); - if (inPayload()) { - assert(currentPayloadParser_.get()); - currentPayloadParser_->handleEndElement(element, ns); - --currentDepth_; - if (!inPayload()) { - boost::shared_ptr<Payload> payload(currentPayloadParser_->getPayload()); - if (payload) { - getStanza()->addPayload(payload); - } - currentPayloadParser_.reset(); - } - } - else { - --currentDepth_; - } -} - -void StanzaParser::handleCharacterData(const String& data) { - if (currentPayloadParser_.get()) { - currentPayloadParser_->handleCharacterData(data); - } -} - -} |