diff options
| author | Remko Tronçon <git@el-tramo.be> | 2012-12-23 16:01:45 (GMT) | 
|---|---|---|
| committer | Swift Review <review@swift.im> | 2012-12-23 16:48:15 (GMT) | 
| commit | 5ccbd7fc3de7afed6c06deb93be3967a7eb5fac2 (patch) | |
| tree | d57334bf18662d6753a2cb14bff3b192ff3e7a76 /Swiften/Parser/AttributeMap.cpp | |
| parent | fe5b5e25eadbfe9f8bdaa152b987273ab77d4711 (diff) | |
| download | swift-5ccbd7fc3de7afed6c06deb93be3967a7eb5fac2.zip swift-5ccbd7fc3de7afed6c06deb93be3967a7eb5fac2.tar.bz2  | |
Replace functors and for loops by boost::lambdas.
Change-Id: I6d2364dc85464f238d95978793f35953a2947799
Diffstat (limited to 'Swiften/Parser/AttributeMap.cpp')
| -rw-r--r-- | Swiften/Parser/AttributeMap.cpp | 25 | 
1 files changed, 9 insertions, 16 deletions
diff --git a/Swiften/Parser/AttributeMap.cpp b/Swiften/Parser/AttributeMap.cpp index 1aeaf99..d508157 100644 --- a/Swiften/Parser/AttributeMap.cpp +++ b/Swiften/Parser/AttributeMap.cpp @@ -8,27 +8,18 @@  #include <algorithm>  #include <boost/optional.hpp> +#include <boost/lambda/lambda.hpp> +#include <boost/lambda/bind.hpp>  using namespace Swift; - -namespace { -	struct AttributeIs { -		AttributeIs(const Attribute& attribute) : attribute(attribute) { -		} - -		bool operator()(const AttributeMap::Entry& o) const { -			return o.getAttribute() == attribute; -		} - -		Attribute attribute; -	}; -} +namespace lambda = boost::lambda;  AttributeMap::AttributeMap() {  }  std::string AttributeMap::getAttribute(const std::string& attribute, const std::string& ns) const { -	AttributeValueMap::const_iterator i = std::find_if(attributes.begin(), attributes.end(), AttributeIs(Attribute(attribute, ns))); +	AttributeValueMap::const_iterator i = std::find_if(attributes.begin(), attributes.end(),  +			lambda::bind(&AttributeMap::Entry::getAttribute, lambda::_1) == Attribute(attribute, ns));  	if (i == attributes.end()) {  		return "";  	} @@ -38,7 +29,8 @@ std::string AttributeMap::getAttribute(const std::string& attribute, const std::  }  bool AttributeMap::getBoolAttribute(const std::string& attribute, bool defaultValue) const { -	AttributeValueMap::const_iterator i = std::find_if(attributes.begin(), attributes.end(), AttributeIs(Attribute(attribute, ""))); +	AttributeValueMap::const_iterator i = std::find_if(attributes.begin(), attributes.end(),  +			lambda::bind(&AttributeMap::Entry::getAttribute, lambda::_1) == Attribute(attribute, ""));  	if (i == attributes.end()) {  		return defaultValue;  	} @@ -48,7 +40,8 @@ bool AttributeMap::getBoolAttribute(const std::string& attribute, bool defaultVa  }  boost::optional<std::string> AttributeMap::getAttributeValue(const std::string& attribute) const { -	AttributeValueMap::const_iterator i = std::find_if(attributes.begin(), attributes.end(), AttributeIs(Attribute(attribute, ""))); +	AttributeValueMap::const_iterator i = std::find_if(attributes.begin(), attributes.end(),  +			lambda::bind(&AttributeMap::Entry::getAttribute, lambda::_1) == Attribute(attribute, ""));  	if (i == attributes.end()) {  		return boost::optional<std::string>();  	}  | 
 Swift