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 * dumpRange( stream, begin, end, "(", "", ", ", "", ")" );
44 template<class _Iterator>
45 std::ostream & dumpRange( std::ostream & str,
46 _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 )
64 template<class _Iterator>
65 std::ostream & dumpRangeLine( std::ostream & str,
66 _Iterator begin, _Iterator end )
67 { return dumpRange( str, begin, end, "(", "", ", ", "", ")" ); }
70 std::ostream & operator<<( std::ostream & str, const std::vector<_Tp> & obj )
71 { return dumpRange( str, obj.begin(), obj.end() ); }
74 std::ostream & operator<<( std::ostream & str, const std::set<_Tp> & obj )
75 { return dumpRange( str, obj.begin(), obj.end() ); }
78 std::ostream & operator<<( std::ostream & str, const std::list<_Tp> & obj )
79 { return dumpRange( str, obj.begin(), obj.end() ); }
81 /////////////////////////////////////////////////////////////////
83 ///////////////////////////////////////////////////////////////////
84 #endif // ZYPP_BASE_LOGTOOLS_H