diff options
author | lloyd <[email protected]> | 2009-11-18 07:16:11 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-11-18 07:16:11 +0000 |
commit | d84018a253bfb87102fe32a77068398ed72a715c (patch) | |
tree | 3da2a95cb04056aa83727ce09e1efbd9560b67cc /src/utils/datastor/datastor.cpp | |
parent | 5e80eff19cc7377d67314c1266a0060f1f201882 (diff) | |
parent | 866a1be9b5a0136c600c463a140bd0aaa69173ff (diff) |
propagate from branch 'net.randombit.botan' (head 23f95467137a0531f74574d1e3eb822734f0c5f2)
to branch 'net.randombit.botan.c++0x' (head 427be8496e669880b1bf532eb829ebbdbeaf34c9)
Diffstat (limited to 'src/utils/datastor/datastor.cpp')
-rw-r--r-- | src/utils/datastor/datastor.cpp | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/src/utils/datastor/datastor.cpp b/src/utils/datastor/datastor.cpp index 129dad9bf..5e7c94634 100644 --- a/src/utils/datastor/datastor.cpp +++ b/src/utils/datastor/datastor.cpp @@ -14,16 +14,6 @@ namespace Botan { /* -* Default Matcher transform operation (identity) -*/ -std::pair<std::string, std::string> -Data_Store::Matcher::transform(const std::string& key, - const std::string& value) const - { - return std::make_pair(key, value); - } - -/* * Data_Store Equality Comparison */ bool Data_Store::operator==(const Data_Store& other) const @@ -42,20 +32,14 @@ bool Data_Store::has_value(const std::string& key) const /* * Search based on an arbitrary predicate */ -std::multimap<std::string, std::string> -Data_Store::search_with(const Matcher& matcher) const +std::multimap<std::string, std::string> Data_Store::search_for( + std::function<bool (std::string, std::string)> predicate) const { std::multimap<std::string, std::string> out; - std::multimap<std::string, std::string>::const_iterator i = - contents.begin(); - - while(i != contents.end()) - { - if(matcher(i->first, i->second)) - out.insert(matcher.transform(i->first, i->second)); - ++i; - } + for(auto i = contents.begin(); i != contents.end(); ++i) + if(predicate(i->first, i->second)) + out.insert(std::make_pair(i->first, i->second)); return out; } @@ -65,12 +49,9 @@ Data_Store::search_with(const Matcher& matcher) const */ std::vector<std::string> Data_Store::get(const std::string& looking_for) const { - typedef std::multimap<std::string, std::string>::const_iterator iter; - - std::pair<iter, iter> range = contents.equal_range(looking_for); - std::vector<std::string> out; - for(iter i = range.first; i != range.second; ++i) + auto range = contents.equal_range(looking_for); + for(auto i = range.first; i != range.second; ++i) out.push_back(i->second); return out; } |