IOStream.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_BASE_IOSTREAM_H
00013 #define ZYPP_BASE_IOSTREAM_H
00014 
00015 #include <iosfwd>
00016 #include <boost/io/ios_state.hpp>
00017 
00018 #include "zypp/base/PtrTypes.h"
00019 
00021 namespace zypp
00022 { 
00023 
00024 
00026   namespace iostr
00027   { 
00028 
00032     typedef boost::io::ios_base_all_saver IosFmtFlagsSaver;
00033 
00034 
00042     std::string getline( std::istream & str );
00043 
00044 
00066     template<class _Function>
00067       _Function & forEachLine( std::istream & str_r, _Function & consume_r )
00068       {
00069         while ( str_r )
00070           {
00071             std::string l = getline( str_r );
00072             if ( ! (str_r.fail() || str_r.bad()) )
00073               {
00074                 // l contains valid data to be consumed.
00075                 if ( ! consume_r( l ) )
00076                   break;
00077               }
00078           }
00079         return consume_r;
00080       }
00081 
00083   } // namespace iostr
00086 } // namespace zypp
00088 #endif // ZYPP_BASE_IOSTREAM_H

Generated on Thu Jul 6 00:07:20 2006 for zypp by  doxygen 1.4.6