summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/PayloadParserFactoryCollection.cpp')
-rw-r--r--Swiften/Parser/PayloadParserFactoryCollection.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/Swiften/Parser/PayloadParserFactoryCollection.cpp b/Swiften/Parser/PayloadParserFactoryCollection.cpp
new file mode 100644
index 0000000..f361ce8
--- /dev/null
+++ b/Swiften/Parser/PayloadParserFactoryCollection.cpp
@@ -0,0 +1,27 @@
+#include <boost/bind.hpp>
+#include <algorithm>
+
+#include "Swiften/Parser/PayloadParserFactoryCollection.h"
+#include "Swiften/Parser/PayloadParserFactory.h"
+
+namespace Swift {
+
+PayloadParserFactoryCollection::PayloadParserFactoryCollection() {
+}
+
+void PayloadParserFactoryCollection::addFactory(PayloadParserFactory* factory) {
+ factories_.push_back(factory);
+}
+
+void PayloadParserFactoryCollection::removeFactory(PayloadParserFactory* factory) {
+ factories_.erase(remove(factories_.begin(), factories_.end(), factory), factories_.end());
+}
+
+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(),
+ boost::bind(&PayloadParserFactory::canParse, _1, element, ns, attributes));
+ return (i != factories_.end() ? *i : NULL);
+}
+
+}