1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/base/LogTools.h
12 #ifndef ZYPP_BASE_LOGTOOLS_H
13 #define ZYPP_BASE_LOGTOOLS_H
20 #include "zypp/base/Logger.h"
22 ///////////////////////////////////////////////////////////////////
24 { /////////////////////////////////////////////////////////////////
26 /** Print range defined by iterators.
28 * intro [ pfx ITEM [ { sep ITEM }+ ] sfx ] extro
30 * The defaults print the range enclosed in \c {}, one item per
31 * line indented by 2 spaces.
37 * {} // on empty rande
39 * A comma separated list enclosed in \c () would be
41 * printRange( begin, end, stream, "(", "", ", ", "", ")" );
44 template<class _Iterator>
45 std::ostream & printRange( _Iterator begin, _Iterator end,
47 const std::string & intro = "{",
48 const std::string & pfx = "\n ",
49 const std::string & sep = "\n ",
50 const std::string & sfx = "\n",
51 const std::string & extro = "}" )
57 for ( ++begin; begin != end; ++begin )
65 std::ostream & operator<<( std::ostream & str, const std::vector<_Tp> & obj )
66 { return printRange( obj.begin(), obj.end(), str ); }
69 std::ostream & operator<<( std::ostream & str, const std::set<_Tp> & obj )
70 { return printRange( obj.begin(), obj.end(), str ); }
73 std::ostream & operator<<( std::ostream & str, const std::list<_Tp> & obj )
74 { return printRange( obj.begin(), obj.end(), str ); }
76 /////////////////////////////////////////////////////////////////
78 ///////////////////////////////////////////////////////////////////
79 #endif // ZYPP_BASE_LOGTOOLS_H