diff options
author | Adrian Kummerländer | 2014-05-23 20:13:42 +0200 |
---|---|---|
committer | Adrian Kummerländer | 2014-05-23 20:13:42 +0200 |
commit | afc8eb29c22447fe2bf71a503a5f2d25b4f8a7c7 (patch) | |
tree | 4401a74e8cbe01375871bf7c42bb6ca598e2818e | |
parent | 6ede83ca2c50353bb9f97260f0ef04234041e73b (diff) | |
download | InputXSLT-afc8eb29c22447fe2bf71a503a5f2d25b4f8a7c7.tar InputXSLT-afc8eb29c22447fe2bf71a503a5f2d25b4f8a7c7.tar.gz InputXSLT-afc8eb29c22447fe2bf71a503a5f2d25b4f8a7c7.tar.bz2 InputXSLT-afc8eb29c22447fe2bf71a503a5f2d25b4f8a7c7.tar.lz InputXSLT-afc8eb29c22447fe2bf71a503a5f2d25b4f8a7c7.tar.xz InputXSLT-afc8eb29c22447fe2bf71a503a5f2d25b4f8a7c7.tar.zst InputXSLT-afc8eb29c22447fe2bf71a503a5f2d25b4f8a7c7.zip |
Changed iterate functor parameter to const reference
* replaced ranged for loop with more appropriate std::for_each
-rw-r--r-- | src/support/filesystem_context.cc | 38 | ||||
-rw-r--r-- | src/support/filesystem_context.h | 20 |
2 files changed, 34 insertions, 24 deletions
diff --git a/src/support/filesystem_context.cc b/src/support/filesystem_context.cc index 8395046..a30bccc 100644 --- a/src/support/filesystem_context.cc +++ b/src/support/filesystem_context.cc @@ -29,8 +29,22 @@ boost::filesystem::path FilesystemContext::resolve( } void FilesystemContext::iterate( + const std::string& path, + const std::function<void(const boost::filesystem::path&)>& func +) const { + this->iterate(this->resolve(path), func); +} + +void FilesystemContext::iterate( + const xalan::XalanDOMString& path, + const std::function<void(const boost::filesystem::path&)>& func +) const { + this->iterate(toString(path), func); +} + +void FilesystemContext::iterate( const boost::filesystem::path& directory, - std::function<void(const boost::filesystem::path&)> func + const std::function<void(const boost::filesystem::path&)>& func ) const { std::vector<boost::filesystem::path> directoryItems; @@ -49,23 +63,11 @@ void FilesystemContext::iterate( directoryItems.end() ); - for ( auto&& item : directoryItems ) { - func(item); - } -} - -void FilesystemContext::iterate( - const std::string& path, - std::function<void(const boost::filesystem::path&)> func -) const { - this->iterate(this->resolve(path), func); -} - -void FilesystemContext::iterate( - const xalan::XalanDOMString& path, - std::function<void(const boost::filesystem::path&)> func -) const { - this->iterate(toString(path), func); + std::for_each( + directoryItems.begin(), + directoryItems.end(), + func + ); } } diff --git a/src/support/filesystem_context.h b/src/support/filesystem_context.h index 6322da6..1f574de 100644 --- a/src/support/filesystem_context.h +++ b/src/support/filesystem_context.h @@ -21,12 +21,20 @@ class FilesystemContext { boost::filesystem::path resolve(const std::string&) const; boost::filesystem::path resolve(const xalan::XalanDOMString&) const; - void iterate(const boost::filesystem::path&, - std::function<void(const boost::filesystem::path&)>) const; - void iterate(const std::string&, - std::function<void(const boost::filesystem::path&)>) const; - void iterate(const xalan::XalanDOMString&, - std::function<void(const boost::filesystem::path&)>) const; + void iterate( + const std::string&, + const std::function<void(const boost::filesystem::path&)>& + ) const; + + void iterate( + const xalan::XalanDOMString&, + const std::function<void(const boost::filesystem::path&)>& + ) const; + + void iterate( + const boost::filesystem::path&, + const std::function<void(const boost::filesystem::path&)>& + ) const; private: const boost::filesystem::path path_; |