12#ifndef ZYPP_BASE_LOGTOOLS_H
13#define ZYPP_BASE_LOGTOOLS_H
50 template <
typename T>
class RefStore;
100 template <
typename T>
102 {
return str << obj.
get(); }
139 template <
typename Intro,
typename Pfx,
typename Sep,
typename Sfx,
typename Extro,
typename Pel,
typename Sel>
195 template <
typename Intro,
typename Pfx,
typename Sep,
typename Sfx,
typename Extro,
typename Pel=NoPr
int,
typename Sel=NoPr
int>
196 constexpr auto makeJoinFormat(
Intro && intro,
Pfx && pfx,
Sep && sep,
Sfx && sfx,
Extro && extro,
Pel && pel =
Pel(),
Sel && sel =
Sel() ) ->
detail::JoinFormat<Intro,Pfx,Sep,Sfx,Extro,Pel,Sel>
197 {
return detail::JoinFormat<Intro,Pfx,Sep,Sfx,Extro,Pel,Sel>( std::forward<Intro>(intro), std::forward<Pfx>(pfx), std::forward<Sep>(sep), std::forward<Sfx>(sfx), std::forward<Extro>(extro), std::forward<Pel>(pel), std::forward<Sel>(sel) ); }
218 template <
typename Ostream,
typename Format>
222 template <
typename Ostream,
typename Format,
typename First>
224 {
str << fmt._pel << std::forward<First>(first) << fmt._sel; }
226 template <
typename Ostream,
typename Format,
typename First,
typename... Args>
228 {
_joinSF(
str << fmt._pel << std::forward<First>(first) << fmt._sel << fmt._sep, fmt, std::forward<Args>(args)... ); }
233 template <
typename Ostream,
typename Format,
typename... Args>
237 if (
sizeof...(Args) ) {
249 template <
typename Ostream,
typename Format,
typename... Args>
251 {
return detail::joinSF(
str, std::forward<Format>(fmt), std::forward<Args>(args)... ); }
254 template <
typename Format,
typename... Args>
260 template <
typename Ostream,
typename... Args>
265 template <
typename... Args>
270 template <
typename Ostream,
typename... Args>
275 template <
typename... Args>
280 template <
typename Ostream,
typename... Args>
285 template <
typename... Args>
296 template <
typename Ostream,
typename Format>
303 template <
typename... Args>
313 #define pXXX zypp::str::detail::PrintFmt(XXX,zypp::str::FormatLine)
314 #define pDBG zypp::str::detail::PrintFmt(DBG,zypp::str::FormatLine)
315 #define pMIL zypp::str::detail::PrintFmt(MIL,zypp::str::FormatLine)
316 #define pWAR zypp::str::detail::PrintFmt(WAR,zypp::str::FormatLine)
317 #define pERR zypp::str::detail::PrintFmt(ERR,zypp::str::FormatLine)
318 #define pSEC zypp::str::detail::PrintFmt(SEC,zypp::str::FormatLine)
319 #define pINT zypp::str::detail::PrintFmt(INT,zypp::str::FormatLine)
320 #define pUSR zypp::str::detail::PrintFmt(USR,zypp::str::FormatLine)
322 #define wXXX zypp::str::detail::PrintFmt(XXX,zypp::str::FormatWords)
323 #define wDBG zypp::str::detail::PrintFmt(DBG,zypp::str::FormatWords)
324 #define wMIL zypp::str::detail::PrintFmt(MIL,zypp::str::FormatWords)
325 #define wWAR zypp::str::detail::PrintFmt(WAR,zypp::str::FormatWords)
326 #define wERR zypp::str::detail::PrintFmt(ERR,zypp::str::FormatWords)
327 #define wSEC zypp::str::detail::PrintFmt(SEC,zypp::str::FormatWords)
328 #define wINT zypp::str::detail::PrintFmt(INT,zypp::str::FormatWords)
329 #define wUSR zypp::str::detail::PrintFmt(USR,zypp::str::FormatWords)
332 #define pOSD zypp::str::detail::PrintFmt(OSD,zypp::str::FormatLine)
418 template<
class TIterator>
420 TIterator begin, TIterator end,
421 const std::string & intro =
"{",
422 const std::string & pfx =
"\n ",
423 const std::string & sep =
"\n ",
424 const std::string & sfx =
"\n",
425 const std::string & extro =
"}" )
430 str << pfx << *begin;
431 for ( ++begin; begin != end; ++begin )
432 str << sep << *begin;
441 template<
class TIterator>
443 TIterator begin, TIterator end )
444 {
return dumpRange(
str, begin, end,
"(",
"",
", ",
"",
")" ); }
446 template<
class TContainer>
458 template<
class TIterator>
470 template<
class TIterator>
484 template<
class TIterator>
488 template<
class TContainer>
490 {
return rangeLine( cont.begin(), cont.end() ); }
496 std::ostream &
operator<<( std::ostream &
str,
const std::vector<Tp> & obj )
499 template<
class Tp,
class TCmp,
class TAlloc>
500 std::ostream &
operator<<( std::ostream &
str,
const std::set<Tp,TCmp,TAlloc> & obj )
504 std::ostream &
operator<<( std::ostream &
str,
const std::unordered_set<Tp> & obj )
508 std::ostream &
operator<<( std::ostream &
str,
const std::multiset<Tp> & obj )
535 template<
class TPair>
551 template<
class TPair>
554 return str <<
'[' << obj.
pair().first <<
"] = " << obj.
pair().second;
558 template<
class TPair>
717 template<
class TKey,
class Tp>
718 std::ostream &
operator<<( std::ostream &
str,
const std::map<TKey, Tp> & obj )
721 template<
class TKey,
class Tp>
722 std::ostream &
operator<<( std::ostream &
str,
const std::unordered_map<TKey, Tp> & obj )
725 template<
class TKey,
class Tp>
726 std::ostream &
operator<<( std::ostream &
str,
const std::multimap<TKey, Tp> & obj )
738 inline std::ostream &
operator<<( std::ostream &
str,
const std::basic_ios<char> & obj )
740 std::string ret(
"[" );
741 ret += ( obj.good() ?
'g' :
'_' );
742 ret += ( obj.eof() ?
'e' :
'_' );
743 ret += ( obj.fail() ?
'F' :
'_' );
744 ret += ( obj.bad() ?
'B' :
'_' );
783 inline std::ostream &
hexdumpOn( std::ostream & outs,
const unsigned char *ptr,
size_t size )
786 unsigned width = 0x10;
787 outs <<
str::form(
"hexdump %10.10ld bytes (0x%8.8lx):\n", (
long)size, (
long)size );
789 for ( i = 0; i < size; i += width ) {
790 outs <<
str::form(
"%4.4lx: ", (
long)i );
792 for ( c = 0; c < width; ++c ) {
799 for ( c = 0; (c < width) && (i+c < size); ++c ) {
800 char x = (ptr[i+c] >= 0x20 && ptr[i+c] < 0x7f) ? ptr[i+c] :
'.';
808 inline std::ostream &
hexdumpOn( std::ostream & outs,
const char *ptr,
size_t size )
809 {
return hexdumpOn( outs,
reinterpret_cast<const unsigned char*
>(ptr), size ); }
816 inline std::ostream &
operator<<( std::ostream &
str,
const std::shared_ptr<D> & obj )
820 return str << std::string(
"NULL");
824 inline std::ostream &
operator<<( std::ostream &
str,
const std::shared_ptr<void> & obj )
828 return str << std::string(
"NULL");
835 inline std::ostream &
operator<<( std::ostream &
str,
const std::type_info &info )
841 std::unique_ptr<char, void(*)(
void*)> res {
842 abi::__cxa_demangle(info.name(), NULL, NULL, &status),
845 return str << std::string((status==0) ? res.get() : info.name());
847 return str << info.name();
851#ifdef __cpp_lib_optional
853 inline std::ostream &
operator<<( std::ostream &
str,
const std::optional<Tp> & obj )
856 str <<
"opt(" << *obj <<
")";
Provides API related macros.
iterator_type begin() const
iterator_type end() const
std::pair wrapper for std::map output.
MapEntry(const TPair &pair_r)
const TPair & pair() const
const PairType *const _pair
Helper to store a reference or move rvalues inside.
constexpr RefStore(RefStore &&rhs)
constexpr RefStore(T &&val_r)
RefStore(const RefStore &)=delete
ostream & operator<<(ostream &str, CCC_ &&color_r)
relates: ansi::Color Stream oputput for ColorTraits enabled types Defined in namespace 'std' because ...
String related utilities and Regular expression matching.
std::ostream & operator<<(std::ostream &str, const RangeLine< TIterator > &obj)
relates: RangeLine<TIterator>
std::ostream & operator<<(std::ostream &str, const SolutionActionList &actionlist)
Ostream & joinSF(Ostream &str, Format &&fmt, Args &&... args)
Print args on ostreamlike str using JoinFormat fmt.
constexpr auto makeRefStore(T &&t) -> RefStore< T >
relates: RefStore<T> Create a RefStore for the argument.
void _joinSF(Ostream &str, const Format &fmt)
std::ostream & operator<<(std::ostream &str, const RefStore< T > &obj)
relates: RefStore<T> Stream output
Provide print[f] and sprint[f] functions based on JoinFormat.
constexpr auto FormatLine
' '-separated and NL-terminated!
std::string sprintf(Format &&fmt, Args &&... args)
Print Format fs string.
std::string sprint(Args &&... args)
Print words as string.
std::string sprintln(Args &&... args)
Print line as string.
constexpr auto makeJoinFormat(Intro &&intro, Pfx &&pfx, Sep &&sep, Sfx &&sfx, Extro &&extro, Pel &&pel=Pel(), Sel &&sel=Sel()) -> detail::JoinFormat< Intro, Pfx, Sep, Sfx, Extro, Pel, Sel >
relates: JoinFormat<> Create a basic format description to print a collection.
Ostream & printf(Ostream &str, Format &&fmt, Args &&... args)
Print Format on stream.
constexpr auto FormatList
One item per line NL-terminated!
constexpr auto FormatWords
' '-separated.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
constexpr auto FormatTuple
Tuple: (el, .., el).
Ostream & concat(Ostream &str, Args &&... args)
Concat words on stream.
Ostream & print(Ostream &str, Args &&... args)
Print words on stream.
std::string sconcat(Args &&... args)
Concat words as string.
constexpr auto FormatDumpRangeDefault
dumpRange default format: {}-enclosed and indented one item per line.
Ostream & println(Ostream &str, Args &&... args)
Print line on stream.
constexpr auto FormatConcat
Concatenated.
constexpr NoPrint noPrint
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()
DumpMap< TMap > dumpMap(const TMap &map_r)
relates: DumpMap Convenience function to create DumpMap from std::map.
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 & hexdumpOn(std::ostream &outs, const unsigned char *ptr, size_t size)
hexdump data on stream
detail::Dump< Tp > dump(const Tp &obj_r)
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
relates: Capability Detailed stream output
std::ostream & operator<<(std::ostream &str, const Capabilities &obj)
relates: Capabilities Stream output
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.
RangeLine(TIterator begin, TIterator end)
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Store nothing print nothing.
PrintFmt(Ostream &str, const Format &fmt)
Ostream & operator()(Args &&... args)
RefStore(const RefStore &)=delete
constexpr RefStore(RefStore &&rhs)