summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2012-12-23 16:01:45 (GMT)
committerSwift Review <review@swift.im>2012-12-23 16:48:15 (GMT)
commit5ccbd7fc3de7afed6c06deb93be3967a7eb5fac2 (patch)
treed57334bf18662d6753a2cb14bff3b192ff3e7a76 /Swiften/Parser/Tree
parentfe5b5e25eadbfe9f8bdaa152b987273ab77d4711 (diff)
downloadswift-5ccbd7fc3de7afed6c06deb93be3967a7eb5fac2.zip
swift-5ccbd7fc3de7afed6c06deb93be3967a7eb5fac2.tar.bz2
Replace functors and for loops by boost::lambdas.
Change-Id: I6d2364dc85464f238d95978793f35953a2947799
Diffstat (limited to 'Swiften/Parser/Tree')
-rw-r--r--Swiften/Parser/Tree/ParserElement.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/Swiften/Parser/Tree/ParserElement.cpp b/Swiften/Parser/Tree/ParserElement.cpp
index 9d9b9b6..e5f8bc8 100644
--- a/Swiften/Parser/Tree/ParserElement.cpp
+++ b/Swiften/Parser/Tree/ParserElement.cpp
@@ -9,8 +9,12 @@
#include <Swiften/Parser/Tree/NullParserElement.h>
#include <iostream>
+#include <boost/lambda/lambda.hpp>
+#include <boost/lambda/bind.hpp>
-namespace Swift{
+namespace lambda = boost::lambda;
+
+namespace Swift {
ParserElement::ParserElement(const std::string& name, const std::string& xmlns, const AttributeMap& attributes) : name_(name), xmlns_(xmlns), attributes_(attributes) {
}
@@ -28,19 +32,10 @@ void ParserElement::appendCharacterData(const std::string& data) {
text_ += data;
}
-struct DoesntMatch {
- public:
- DoesntMatch(const std::string& tagName, const std::string& ns) : tagName(tagName), ns(ns) {}
- bool operator()(ParserElement::ref element) { return element->getName() != tagName || element->getNamespace() != ns; }
- private:
- std::string tagName;
- std::string ns;
-};
-
-
std::vector<ParserElement::ref> ParserElement::getChildren(const std::string& name, const std::string& xmlns) const {
std::vector<ParserElement::ref> result;
- std::remove_copy_if(children_.begin(), children_.end(), std::back_inserter(result), DoesntMatch(name, xmlns));
+ std::remove_copy_if(children_.begin(), children_.end(), std::back_inserter(result),
+ lambda::bind(&ParserElement::getName, *lambda::_1) != name || lambda::bind(&ParserElement::getNamespace, *lambda::_1) != xmlns);
return result;
}