summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/PayloadParserFactoryCollection.cpp')
-rw-r--r--Swiften/Parser/PayloadParserFactoryCollection.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/Swiften/Parser/PayloadParserFactoryCollection.cpp b/Swiften/Parser/PayloadParserFactoryCollection.cpp
index f361ce8..6d3a4cf 100644
--- a/Swiften/Parser/PayloadParserFactoryCollection.cpp
+++ b/Swiften/Parser/PayloadParserFactoryCollection.cpp
@@ -6,7 +6,7 @@
namespace Swift {
-PayloadParserFactoryCollection::PayloadParserFactoryCollection() {
+PayloadParserFactoryCollection::PayloadParserFactoryCollection() : defaultFactory_(NULL) {
}
void PayloadParserFactoryCollection::addFactory(PayloadParserFactory* factory) {
@@ -17,11 +17,15 @@ void PayloadParserFactoryCollection::removeFactory(PayloadParserFactory* factory
factories_.erase(remove(factories_.begin(), factories_.end(), factory), factories_.end());
}
+void PayloadParserFactoryCollection::setDefaultFactory(PayloadParserFactory* factory) {
+ defaultFactory_ = factory;
+}
+
PayloadParserFactory* PayloadParserFactoryCollection::getPayloadParserFactory(const String& element, const String& ns, const AttributeMap& attributes) {
- std::vector<PayloadParserFactory*>::const_iterator i = std::find_if(
- factories_.begin(), factories_.end(),
+ std::vector<PayloadParserFactory*>::reverse_iterator i = std::find_if(
+ factories_.rbegin(), factories_.rend(),
boost::bind(&PayloadParserFactory::canParse, _1, element, ns, attributes));
- return (i != factories_.end() ? *i : NULL);
+ return (i != factories_.rend() ? *i : defaultFactory_);
}
}