12 #ifndef ZYPP_BASE_LOGTOOLS_H
13 #define ZYPP_BASE_LOGTOOLS_H
90 template<
class _Iterator>
92 _Iterator begin, _Iterator end,
93 const std::string & intro =
"{",
94 const std::string & pfx =
"\n ",
95 const std::string & sep =
"\n ",
96 const std::string & sfx =
"\n",
97 const std::string & extro =
"}" )
102 str << pfx << *begin;
103 for ( ++begin; begin != end; ++begin )
104 str << sep << *begin;
113 template<
class _Iterator>
115 _Iterator begin, _Iterator end )
116 {
return dumpRange( str, begin, end,
"(",
"",
", ",
"",
")" ); }
120 std::ostream & operator<<( std::ostream & str, const std::vector<_Tp> & obj )
121 {
return dumpRange( str, obj.begin(), obj.end() ); }
124 std::ostream & operator<<( std::ostream & str, const std::set<_Tp> & obj )
125 {
return dumpRange( str, obj.begin(), obj.end() ); }
128 std::ostream & operator<<( std::ostream & str, const std::tr1::unordered_set<_Tp> & obj )
129 {
return dumpRange( str, obj.begin(), obj.end() ); }
132 std::ostream & operator<<( std::ostream & str, const std::multiset<_Tp> & obj )
133 {
return dumpRange( str, obj.begin(), obj.end() ); }
136 std::ostream & operator<<( std::ostream & str, const std::list<_Tp> & obj )
137 {
return dumpRange( str, obj.begin(), obj.end() ); }
140 namespace _logtoolsdetail
152 template<
class _Pair>
168 template<
class _Pair>
169 std::ostream & operator<<( std::ostream & str, const MapEntry<_Pair> & obj )
171 return str <<
'[' << obj.pair().first <<
"] = " << obj.pair().second;
175 template<
class _Pair>
195 struct Transformer :
public std::unary_function<PairType, MapEntryType>
198 {
return mapEntry( pair_r ); }
201 typedef transform_iterator<Transformer, typename MapType::const_iterator>
224 std::ostream & operator<<( std::ostream & str, const DumpMap<_Map> & obj )
225 {
return dumpRange( str, obj.begin(), obj.end() ); }
269 std::ostream & operator<<( std::ostream & str, const DumpKeys<_Map> & obj )
270 {
return dumpRange( str, obj.begin(), obj.end() ); }
314 std::ostream & operator<<( std::ostream & str, const DumpValues<_Map> & obj )
315 {
return dumpRange( str, obj.begin(), obj.end() ); }
327 using _logtoolsdetail::mapEntry;
328 using _logtoolsdetail::dumpMap;
329 using _logtoolsdetail::dumpKeys;
330 using _logtoolsdetail::dumpValues;
332 template<
class _Key,
class _Tp>
333 std::ostream & operator<<( std::ostream & str, const std::map<_Key, _Tp> & obj )
334 {
return str << dumpMap( obj ); }
336 template<
class _Key,
class _Tp>
337 std::ostream & operator<<( std::ostream & str, const std::tr1::unordered_map<_Key, _Tp> & obj )
338 {
return str << dumpMap( obj ); }
340 template<
class _Key,
class _Tp>
341 std::ostream & operator<<( std::ostream & str, const std::multimap<_Key, _Tp> & obj )
342 {
return str << dumpMap( obj ); }
353 inline std::ostream & operator<<( std::ostream & str, const std::basic_ios<char> & obj )
355 std::string ret(
"[" );
356 ret += ( obj.good() ?
'g' :
'_' );
357 ret += ( obj.eof() ?
'e' :
'_' );
358 ret += ( obj.fail() ?
'F' :
'_' );
359 ret += ( obj.bad() ?
'B' :
'_' );
379 std::ostream & operator<<( std::ostream & str, const Dump<_Tp> & obj )
380 {
return dumpOn( str, obj._obj ); }
391 #endif // ZYPP_BASE_LOGTOOLS_H
MapKVIteratorTraits< _Map >::Value_const_iterator make_map_value_end(const _Map &map_r)
Convenience to create the value iterator from container::end()
std::ostream & dumpOn(std::ostream &str, const PoolQueryIterator &obj)
transform_iterator< GetPairFirst< typename MapType::value_type >, typename MapType::const_iterator > Key_const_iterator
The key iterator type.
transform_iterator< GetPairSecond< typename MapType::value_type >, typename MapType::const_iterator > Value_const_iterator
The value iterator type.
MapKVIteratorTraits< _Map >::Value_const_iterator make_map_value_begin(const _Map &map_r)
Convenience to create the value iterator from container::begin()
std::ostream & dumpRange(std::ostream &str, _Iterator begin, _Iterator end, const std::string &intro="{", const std::string &pfx="\n ", const std::string &sep="\n ", const std::string &sfx="\n", const std::string &extro="}")
Print range defined by iterators (multiline style).
std::pair wrapper for std::map output.
Provides API related macros.
MapEntry< _Pair > mapEntry(const _Pair &pair_r)
std::ostream & dumpRangeLine(std::ostream &str, _Iterator begin, _Iterator end)
Print range defined by iterators (single line style).
MapKVIteratorTraits< _Map >::Key_const_iterator make_map_key_begin(const _Map &map_r)
Convenience to create the key iterator from container::begin()
detail::Dump< _Tp > dump(const _Tp &obj_r)
MapKVIteratorTraits< _Map >::Key_const_iterator make_map_key_end(const _Map &map_r)
Convenience to create the key iterator from container::end()
const _Pair & pair() const
MapEntry(const _Pair &pair_r)