Merge commit '2.5.0' into moonshot-packaging-fixes
[shibboleth/sp.git] / shibsp / attribute / filtering / impl / OrMatchFunctor.cpp
index bbf9431..c80bb24 100644 (file)
 #include "attribute/filtering/MatchFunctor.h"
 #include "util/SPConstants.h"
 
+#include <boost/bind.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xmltooling/util/XMLHelper.h>
 
 using namespace shibsp;
 using namespace xmltooling;
+using namespace boost;
 using namespace std;
 
 namespace shibsp {
@@ -48,17 +50,19 @@ namespace shibsp {
         OrMatchFunctor(const pair<const FilterPolicyContext*,const DOMElement*>& p);
 
         bool evaluatePolicyRequirement(const FilteringContext& filterContext) const {
-            for (vector<const MatchFunctor*>::const_iterator mf = m_functors.begin(); mf!=m_functors.end(); ++mf)
-                if ((*mf)->evaluatePolicyRequirement(filterContext))
-                    return true;
-            return false;
+            vector<const MatchFunctor*>::const_iterator i = find_if(
+                m_functors.begin(), m_functors.end(),
+                boost::bind(&MatchFunctor::evaluatePolicyRequirement, _1, boost::cref(filterContext)) == true
+                );
+            return (i != m_functors.end());
         }
 
         bool evaluatePermitValue(const FilteringContext& filterContext, const Attribute& attribute, size_t index) const {
-            for (vector<const MatchFunctor*>::const_iterator mf = m_functors.begin(); mf!=m_functors.end(); ++mf)
-                if ((*mf)->evaluatePermitValue(filterContext, attribute, index))
-                    return true;
-            return false;
+            vector<const MatchFunctor*>::const_iterator i = find_if(
+                m_functors.begin(), m_functors.end(),
+                boost::bind(&MatchFunctor::evaluatePermitValue, _1, boost::cref(filterContext), boost::cref(attribute), index) == true
+                );
+            return (i != m_functors.end());
         }
 
     private:
@@ -109,11 +113,11 @@ MatchFunctor* OrMatchFunctor::buildFunctor(const DOMElement* e, const FilterPoli
     if (!id.empty() && functorMap->getMatchFunctors().count(id))
         id.clear();
 
-    auto_ptr<xmltooling::QName> type(XMLHelper::getXSIType(e));
-    if (!type.get())
+    scoped_ptr<xmltooling::QName> type(XMLHelper::getXSIType(e));
+    if (!type)
         throw ConfigurationException("Child Rule found with no xsi:type.");
 
-    MatchFunctor* func = SPConfig::getConfig().MatchFunctorManager.newPlugin(*type.get(), make_pair(functorMap,e));
-    functorMap->getMatchFunctors().insert(multimap<string,MatchFunctor*>::value_type(id, func));
-    return func;
+    auto_ptr<MatchFunctor> func(SPConfig::getConfig().MatchFunctorManager.newPlugin(*type, make_pair(functorMap,e)));
+    functorMap->getMatchFunctors().insert(multimap<string,MatchFunctor*>::value_type(id, func.get()));
+    return func.release();
 }