]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- use template to search through ACL signatures 49/head
authorOndrej Kozina <okozina@redhat.com>
Mon, 24 Feb 2014 16:40:46 +0000 (17:40 +0100)
committerOndrej Kozina <okozina@redhat.com>
Mon, 24 Feb 2014 16:40:46 +0000 (17:40 +0100)
snapper/Acls.cc
snapper/File.cc
snapper/XAttributes.cc

index 83821cb2e77c802851984a0a9dba261fc021d4a5..ed9a66d5a30f91d1f671bc24d6c278c09bc343f4 100644 (file)
 #include "snapper/AppUtil.h"
 #include "snapper/Exception.h"
 #include "snapper/Log.h"
+#include "snapper/SnapperTmpl.h"
 
 namespace snapper
 {
     bool
     is_acl_signature(const std::string& name)
     {
-       for (std::vector<string>::const_iterator cit = _acl_signatures.begin(); cit != _acl_signatures.end(); cit++)
-       {
-           if (name == *cit)
-               return true;
-       }
-       return false;
+       return contains(_acl_signatures, name);
     }
 
     Acls::Acls(const string& path)
index 4e0fee5c2053da165965e4580bdf5ce76a3914f9..7865ffb8b0e1b792942a249206f2e07ce153530f 100644 (file)
@@ -572,7 +572,7 @@ namespace snapper
 
            ret_val = true;
        }
-       catch (const SnapperException& e)
+       catch (const AclException& e)
        {
            ret_val = false;
        }
index bcf8c6f6c1ab97689bb7922de4ddaa7bc32e61c1..ccb8509af6fe1dcc5fbe8b39b2d3753f29ed2990 100644 (file)
@@ -36,6 +36,7 @@
 #include "snapper/Log.h"
 #include "snapper/XAttributes.h"
 #include "snapper/Acls.h"
+#include "snapper/SnapperTmpl.h"
 
 
 namespace snapper
@@ -47,18 +48,12 @@ namespace snapper
 
        bool operator()(const xa_pair_t& pair)
        {
-           for (vector<string>::const_iterator cit = acl_sigs.begin(); cit != acl_sigs.end(); cit++)
-               if (pair.first == *cit)
-                   return true;
-           return false;
+           return contains(acl_sigs, pair.first);
        }
 
        bool operator()(const string& name)
        {
-           for (vector<string>::const_iterator cit = acl_sigs.begin(); cit != acl_sigs.end(); cit++)
-               if (name == *cit)
-                   return true;
-           return false;
+           return contains(acl_sigs, name);
        }
 
        const vector<string>& acl_sigs;
@@ -71,14 +66,8 @@ namespace snapper
        : map(xamap), acl_sigs(acl_sigs) {}
        void operator()(const xa_pair_t& xapair)
        {
-           for (vector<string>::const_iterator cit = acl_sigs.begin(); cit != acl_sigs.end(); cit++)
-           {
-               if (*cit == xapair.first)
-               {
-                   map.insert(xapair);
-                   break;
-               }
-           }
+           if (contains(acl_sigs, xapair.first))
+               map.insert(xapair);
        }
 
        xa_map_t& map;