diff options
author | lloyd <[email protected]> | 2010-09-03 13:55:19 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-09-03 13:55:19 +0000 |
commit | 7e54763ea43c8b34729387c7429922dd981c4f5b (patch) | |
tree | 33a1bd0f32e4ab7958a484e468316291c527dd24 /src/utils/datastor/datastor.cpp | |
parent | fb68795162b8d107cbd284c4a75d8e13ce589829 (diff) | |
parent | ec8c59af3db02ff159908f9a446e53c4ea20d474 (diff) |
propagate from branch 'net.randombit.botan' (head a29c41b4a949207b1544096c3afab668f8b5179e)
to branch 'net.randombit.botan.c++0x' (head a9d0c2f805b3c20a4c648575d7256959db8329fe)
Diffstat (limited to 'src/utils/datastor/datastor.cpp')
-rw-r--r-- | src/utils/datastor/datastor.cpp | 35 |
1 files changed, 8 insertions, 27 deletions
diff --git a/src/utils/datastor/datastor.cpp b/src/utils/datastor/datastor.cpp index b3f00ac6c..363136c69 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; } @@ -138,7 +119,7 @@ void Data_Store::add(const std::string& key, const std::string& val) */ void Data_Store::add(const std::string& key, u32bit val) { - add(key, to_string(val)); + add(key, std::to_string(val)); } /* |