12#ifndef ZYPP_BASE_LOGTOOLS_H
13#define ZYPP_BASE_LOGTOOLS_H
119 template<
class TIterator>
121 TIterator begin, TIterator end,
122 const std::string & intro =
"{",
123 const std::string & pfx =
"\n ",
124 const std::string & sep =
"\n ",
125 const std::string & sfx =
"\n",
126 const std::string & extro =
"}" )
131 str << pfx << *begin;
132 for ( ++begin; begin != end; ++begin )
133 str << sep << *begin;
142 template<
class TIterator>
144 TIterator begin, TIterator end )
145 {
return dumpRange(
str, begin, end,
"(",
"",
", ",
"",
")" ); }
147 template<
class TContainer>
159 template<
class TIterator>
171 template<
class TIterator>
185 template<
class TIterator>
189 template<
class TContainer>
191 {
return rangeLine( cont.begin(), cont.end() ); }
194 std::ostream &
operator<<( std::ostream &
str,
const std::vector<Tp> & obj )
197 template<
class Tp,
class TCmp,
class TAlloc>
198 std::ostream &
operator<<( std::ostream &
str,
const std::set<Tp,TCmp,TAlloc> & obj )
202 std::ostream &
operator<<( std::ostream &
str,
const std::unordered_set<Tp> & obj )
206 std::ostream &
operator<<( std::ostream &
str,
const std::multiset<Tp> & obj )
230 template<
class TPair>
246 template<
class TPair>
249 return str <<
'[' << obj.
pair().first <<
"] = " << obj.
pair().second;
253 template<
class TPair>
409 template<
class TKey,
class Tp>
410 std::ostream &
operator<<( std::ostream &
str,
const std::map<TKey, Tp> & obj )
413 template<
class TKey,
class Tp>
414 std::ostream &
operator<<( std::ostream &
str,
const std::unordered_map<TKey, Tp> & obj )
417 template<
class TKey,
class Tp>
418 std::ostream &
operator<<( std::ostream &
str,
const std::multimap<TKey, Tp> & obj )
430 inline std::ostream &
operator<<( std::ostream &
str,
const std::basic_ios<char> & obj )
432 std::string ret(
"[" );
433 ret += ( obj.good() ?
'g' :
'_' );
434 ret += ( obj.eof() ?
'e' :
'_' );
435 ret += ( obj.fail() ?
'F' :
'_' );
436 ret += ( obj.bad() ?
'B' :
'_' );
472 inline std::ostream &
hexdumpOn( std::ostream & outs,
const unsigned char *ptr,
size_t size )
475 unsigned width = 0x10;
476 outs <<
str::form(
"hexdump %10.10ld bytes (0x%8.8lx):\n", (
long)size, (
long)size );
478 for ( i = 0; i < size; i += width ) {
479 outs <<
str::form(
"%4.4lx: ", (
long)i );
481 for ( c = 0; c < width; ++c ) {
488 for ( c = 0; (c < width) && (i+c < size); ++c ) {
489 char x = (ptr[i+c] >= 0x20 && ptr[i+c] < 0x7f) ? ptr[i+c] :
'.';
497 inline std::ostream &
hexdumpOn( std::ostream & outs,
const char *ptr,
size_t size )
498 {
return hexdumpOn( outs,
reinterpret_cast<const unsigned char*
>(ptr), size ); }
504 inline std::ostream &
operator<<( std::ostream &
str,
const std::type_info &info )
510 std::unique_ptr<char, void(*)(
void*)> res {
511 abi::__cxa_demangle(info.name(), NULL, NULL, &status),
514 return str << std::string((status==0) ? res.get() : info.name());
516 return str << info.name();
520#ifdef __cpp_lib_optional
522 inline std::ostream &
operator<<( std::ostream &
str,
const std::optional<Tp> & obj )
525 str <<
"opt(" << *obj <<
")";
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.
const PairType *const _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)
DumpMap< TMap > dumpMap(const TMap &map_r)
Convenience function to create DumpMap from std::map.
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)
Provides API related macros.