00001
00002
00003
00004
00005
00006
00007
00008
00012 #ifndef ZYPP_BASE_LOGTOOLS_H
00013 #define ZYPP_BASE_LOGTOOLS_H
00014
00015 #include <iostream>
00016 #include <string>
00017 #include <vector>
00018 #include <list>
00019 #include <set>
00020 #include "zypp/base/Logger.h"
00021
00023 namespace zypp
00024 {
00025
00044 template<class _Iterator>
00045 std::ostream & dumpRange( std::ostream & str,
00046 _Iterator begin, _Iterator end,
00047 const std::string & intro = "{",
00048 const std::string & pfx = "\n ",
00049 const std::string & sep = "\n ",
00050 const std::string & sfx = "\n",
00051 const std::string & extro = "}" )
00052 {
00053 str << intro;
00054 if ( begin != end )
00055 {
00056 str << pfx << *begin;
00057 for ( ++begin; begin != end; ++begin )
00058 str << sep << *begin;
00059 str << sfx;
00060 }
00061 return str << extro;
00062 }
00063
00064 template<class _Tp>
00065 std::ostream & operator<<( std::ostream & str, const std::vector<_Tp> & obj )
00066 { return dumpRange( str, obj.begin(), obj.end() ); }
00067
00068 template<class _Tp>
00069 std::ostream & operator<<( std::ostream & str, const std::set<_Tp> & obj )
00070 { return dumpRange( str, obj.begin(), obj.end() ); }
00071
00072 template<class _Tp>
00073 std::ostream & operator<<( std::ostream & str, const std::list<_Tp> & obj )
00074 { return dumpRange( str, obj.begin(), obj.end() ); }
00075
00077 }
00079 #endif // ZYPP_BASE_LOGTOOLS_H