Author: mlandres Date: Tue Oct 28 12:54:31 2008 New Revision: 11522 URL: http://svn.opensuse.org/viewcvs/zypp?rev=11522&view=rev Log: Add functor::GetAll to store results found to some output_iterator. Modified: trunk/libzypp/zypp/base/Functional.h Modified: trunk/libzypp/zypp/base/Functional.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/base/Functional.h?rev=11522&r1=11521&r2=11522&view=diff ============================================================================== --- trunk/libzypp/zypp/base/Functional.h (original) +++ trunk/libzypp/zypp/base/Functional.h Tue Oct 28 12:54:31 2008 @@ -383,6 +383,33 @@ { return GetLast<_Tp>( result_r ); } + /** Store all results found to some output_iterator. + * \code + * std::vectorparser::ProductFileData result; + * parser::ProductFileReader::scanDir( functor::getAll( std::back_inserter( result ) ), + sysRoot / "etc/products.d" ); + * \endcode + */ + template<class _OutputIterator> + struct GetAll + { + GetAll( _OutputIterator result_r ) + : _result( result_r ) + {} + + template<class _Tp> + bool operator()( const _Tp & val_r ) const + { *(_result++) = val_r; return true; } + + private: + mutable _OutputIterator _result; + }; + + /** Convenience function for creating \ref GetAll. */ + template<class _OutputIterator> + GetAll<_OutputIterator> getAll( _OutputIterator result_r ) + { return GetAll<_OutputIterator>( result_r ); } + //@} /////////////////////////////////////////////////////////////////// -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org