12#ifndef ZYPP_BASE_LOGTOOLS_H
13#define ZYPP_BASE_LOGTOOLS_H
118 template<
class TIterator>
120 TIterator begin, TIterator end,
121 const std::string & intro =
"{",
122 const std::string & pfx =
"\n ",
123 const std::string & sep =
"\n ",
124 const std::string & sfx =
"\n",
125 const std::string & extro =
"}" )
130 str << pfx << *begin;
131 for ( ++begin; begin != end; ++begin )
132 str << sep << *begin;
141 template<
class TIterator>
143 TIterator begin, TIterator end )
144 {
return dumpRange(
str, begin, end,
"(",
"",
", ",
"",
")" ); }
146 template<
class TContainer>
158 template<
class TIterator>
170 template<
class TIterator>
184 template<
class TIterator>
188 template<
class TContainer>
190 {
return rangeLine( cont.begin(), cont.end() ); }
193 std::ostream &
operator<<( std::ostream &
str,
const std::vector<Tp> & obj )
196 template<
class Tp,
class TCmp,
class TAlloc>
197 std::ostream &
operator<<( std::ostream &
str,
const std::set<Tp,TCmp,TAlloc> & obj )
201 std::ostream &
operator<<( std::ostream &
str,
const std::unordered_set<Tp> & obj )
205 std::ostream &
operator<<( std::ostream &
str,
const std::multiset<Tp> & obj )
217 namespace _logtoolsdetail
229 template<
class TPair>
245 template<
class TPair>
248 return str <<
'[' << obj.
pair().first <<
"] = " << obj.
pair().second;
252 template<
class TPair>
408 template<
class TKey,
class Tp>
409 std::ostream &
operator<<( std::ostream &
str,
const std::map<TKey, Tp> & obj )
410 {
return str << dumpMap( obj ); }
412 template<
class TKey,
class Tp>
413 std::ostream &
operator<<( std::ostream &
str,
const std::unordered_map<TKey, Tp> & obj )
414 {
return str << dumpMap( obj ); }
416 template<
class TKey,
class Tp>
417 std::ostream &
operator<<( std::ostream &
str,
const std::multimap<TKey, Tp> & obj )
418 {
return str << dumpMap( obj ); }
429 inline std::ostream &
operator<<( std::ostream &
str,
const std::basic_ios<char> & obj )
431 std::string ret(
"[" );
432 ret += ( obj.good() ?
'g' :
'_' );
433 ret += ( obj.eof() ?
'e' :
'_' );
434 ret += ( obj.fail() ?
'F' :
'_' );
435 ret += ( obj.bad() ?
'B' :
'_' );
471 inline std::ostream &
hexdumpOn( std::ostream & outs,
const unsigned char *ptr,
size_t size )
474 unsigned width = 0x10;
475 outs <<
str::form(
"hexdump %10.10ld bytes (0x%8.8lx):\n", (
long)size, (
long)size );
477 for ( i = 0; i < size; i += width ) {
478 outs <<
str::form(
"%4.4lx: ", (
long)i );
480 for ( c = 0; c < width; ++c ) {
487 for ( c = 0; (c < width) && (i+c < size); ++c ) {
488 char x = (ptr[i+c] >= 0x20 && ptr[i+c] < 0x7f) ? ptr[i+c] :
'.';
496 inline std::ostream &
hexdumpOn( std::ostream & outs,
const char *ptr,
size_t size )
497 {
return hexdumpOn( outs, (
const unsigned char *)ptr, size ); }
503 inline std::ostream &
operator<<( std::ostream &
str,
const std::type_info &info )
509 std::unique_ptr<char, void(*)(
void*)> res {
510 abi::__cxa_demangle(info.name(), NULL, NULL, &status),
513 return str << std::string((status==0) ? res.get() : info.name());
515 return str << info.name();
iterator_type begin() const
iterator_type end() const
std::pair wrapper for std::map output.
MapEntry(const TPair &pair_r)
const TPair & pair() const
std::ostream & operator<<(std::ostream &str, const MapEntry< TPair > &obj)
Stream output.
MapEntry< TPair > mapEntry(const TPair &pair_r)
Convenience function to create MapEntry from std::pair.
String related utilities and Regular expression matching.
std::ostream & operator<<(std::ostream &str, const SolutionActionList &actionlist)
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpRangeLine(std::ostream &str, TIterator begin, TIterator end)
Print range defined by iterators (single line style).
MapKVIteratorTraits< TMap >::Key_const_iterator make_map_key_begin(const TMap &map_r)
Convenience to create the key iterator from container::begin()
std::ostream & dumpRange(std::ostream &str, TIterator begin, TIterator 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).
iomanip::RangeLine< TIterator > rangeLine(TIterator begin, TIterator end)
Iomanip printing dumpRangeLine style.
MapKVIteratorTraits< TMap >::Value_const_iterator make_map_value_begin(const TMap &map_r)
Convenience to create the value iterator from container::begin()
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
MapKVIteratorTraits< TMap >::Key_const_iterator make_map_key_end(const TMap &map_r)
Convenience to create the key iterator from container::end()
MapKVIteratorTraits< TMap >::Value_const_iterator make_map_value_end(const TMap &map_r)
Convenience to create the value iterator from container::end()
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
std::ostream & hexdumpOn(std::ostream &outs, const unsigned char *ptr, size_t size)
hexdump data on stream
detail::Dump< Tp > dump(const Tp &obj_r)
Helper to produce not-NL-terminated multi line output.
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.
std::ostream & operator<<(std::ostream &str, const RangeLine< TIterator > &obj)
<TIterator>
RangeLine(TIterator begin, TIterator end)