libzypp 17.38.7
LogTools.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_BASE_LOGTOOLS_H
13#define ZYPP_BASE_LOGTOOLS_H
14
15#include <iostream>
16#include <optional>
17#include <string>
18#include <vector>
19#include <list>
20#include <set>
21#include <map>
22
23#include <zypp-core/base/Hash.h>
27#include <zypp-core/Globals.h>
28
29#ifdef __GNUG__
30#include <cstdlib>
31#include <memory>
32#include <cxxabi.h>
33#endif
34
36namespace zypp
37{
38
45 namespace str {
46
47 namespace detail {
48
50 template <typename T> class RefStore;
51
53 template <typename T>
54 struct RefStore
55 {
56 constexpr RefStore( T && val_r )
57 : _val { std::move(val_r) }
58 {}
59
60 RefStore( const RefStore & ) = delete;
61
62 constexpr RefStore( RefStore && rhs )
63 : _val { std::move(rhs._val) }
64 {}
65
66 T & get() { return _val; }
67 const T & get() const { return _val; }
68
69 private:
71 };
72
74 template <typename T>
75 struct RefStore<T&>
76 {
77 constexpr RefStore( T & t )
78 : _val { t }
79 {}
80
81 RefStore( const RefStore & ) = delete;
82
83 constexpr RefStore( RefStore && rhs )
84 : _val { rhs._val }
85 {}
86
87 T & get() { return _val; }
88 const T & get() const { return _val; }
89
90 private:
91 T & _val;
92 };
93
95 template <typename T>
96 constexpr auto makeRefStore( T && t ) ->/* c++-11 can not deduce return value! */ RefStore<T>
97 { return RefStore<T>( std::forward<T>(t) ); }
98
100 template <typename T>
101 std::ostream & operator<<( std::ostream & str, const RefStore<T> & obj )
102 { return str << obj.get(); }
103
104
106 struct NoPrint {};
107
108 inline std::ostream & operator<<( std::ostream & str, const NoPrint & obj )
109 { return str; }
110
111 template <>
113 { constexpr RefStore() {} constexpr RefStore( NoPrint && ) {} };
114
115 template <>
116 inline std::ostream & operator<<( std::ostream & str, const RefStore<NoPrint> & obj )
117 { return str; }
118
119 template <>
121 { constexpr RefStore() {} constexpr RefStore( const NoPrint & ) {} };
122
123 template <>
124 inline std::ostream & operator<<( std::ostream & str, const RefStore<NoPrint&> & obj )
125 { return str; }
126
127
139 template <typename Intro, typename Pfx, typename Sep, typename Sfx, typename Extro, typename Pel, typename Sel>
141 {
142 constexpr JoinFormat( Intro && intro, Pfx && pfx, Sep && sep, Sfx && sfx, Extro && extro, Pel && pel, Sel && sel )
143 : _intro { std::forward<Intro>(intro) }
144 , _pfx { std::forward<Pfx>(pfx) }
145 , _sep { std::forward<Sep>(sep) }
146 , _sfx { std::forward<Sfx>(sfx) }
147 , _extro { std::forward<Extro>(extro) }
148 , _pel { std::forward<Pel>(pel) }
149 , _sel { std::forward<Sel>(sel) }
150 {}
151
159 };
160
161 } //namespace detail
162
163 // Drag it into str:: namespace
165 inline constexpr NoPrint noPrint;
166
195 template <typename Intro, typename Pfx, typename Sep, typename Sfx, typename Extro, typename Pel=NoPrint, typename Sel=NoPrint>
196 constexpr auto makeJoinFormat( Intro && intro, Pfx && pfx, Sep && sep, Sfx && sfx, Extro && extro, Pel && pel = Pel(), Sel && sel = Sel() ) ->/* c++-11 can not deduce return value! */ 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) ); }
198
199
200 // A few default formats:
204 inline constexpr auto FormatWords = makeJoinFormat( noPrint, noPrint, " ", noPrint, noPrint );
206 inline constexpr auto FormatLine = makeJoinFormat( noPrint, noPrint, " ", noPrint, "\n" );
208 inline constexpr auto FormatList = makeJoinFormat( noPrint, noPrint, "\n", "\n", noPrint );
210 inline constexpr auto FormatTuple = makeJoinFormat( "(", noPrint, ", ", noPrint, ")" );
211
213 inline constexpr auto FormatDumpRangeDefault
214 = makeJoinFormat( "{", "\n ", "\n ", "\n", "}" );
215
216 namespace detail {
217
218 template <typename Ostream, typename Format>
219 void _joinSF( Ostream & str, const Format & fmt )
220 { ; }
221
222 template <typename Ostream, typename Format, typename First>
223 void _joinSF( Ostream & str, const Format & fmt, First && first )
224 { str << fmt._pel << std::forward<First>(first) << fmt._sel; }
225
226 template <typename Ostream, typename Format, typename First, typename... Args>
227 void _joinSF( Ostream & str, const Format & fmt, First && first, Args &&... args )
228 { _joinSF( str << fmt._pel << std::forward<First>(first) << fmt._sel << fmt._sep, fmt, std::forward<Args>(args)... ); }
229
233 template <typename Ostream, typename Format, typename... Args>
234 Ostream & joinSF( Ostream & str, Format && fmt, Args &&... args )
235 {
236 str << fmt._intro;
237 if ( sizeof...(Args) ) {
238 str << fmt._pfx;
239 detail::_joinSF( str, fmt, std::forward<Args>(args)... );
240 str << fmt._sfx;
241 }
242 str << fmt._extro;
243 return str;
244 }
245
246 } //namespace detail
247
249 template <typename Ostream, typename Format, typename... Args>
250 Ostream & printf( Ostream & str, Format && fmt, Args&&... args )
251 { return detail::joinSF( str, std::forward<Format>(fmt), std::forward<Args>(args)... ); }
252
254 template <typename Format, typename... Args>
255 std::string sprintf( Format && fmt, Args&&... args )
256 { str::Str str; return detail::joinSF( str, std::forward<Format>(fmt), std::forward<Args>(args)... ); }
257
258
260 template <typename Ostream, typename... Args>
261 Ostream & print( Ostream & str, Args&&... args )
262 { return detail::joinSF( str, FormatWords, std::forward<Args>(args)... ); }
263
265 template <typename... Args>
266 std::string sprint( Args&&... args )
267 { str::Str str; return detail::joinSF( str, FormatWords, std::forward<Args>(args)... ); }
268
270 template <typename Ostream, typename... Args>
271 Ostream & concat( Ostream & str, Args&&... args )
272 { return detail::joinSF( str, FormatConcat, std::forward<Args>(args)... ); }
273
275 template <typename... Args>
276 std::string sconcat( Args&&... args )
277 { str::Str str; return detail::joinSF( str, FormatConcat, std::forward<Args>(args)... ); }
278
279 namespace detail {
286 template <typename Ostream, typename Format>
287 struct PrintFmt {
288 PrintFmt( Ostream & str, const Format & fmt )
289 : _str { str }
290 , _fmt { fmt }
291 {}
292
293 template <typename... Args>
294 Ostream & operator()( Args&&... args )
295 { return str::printf( _str, _fmt, std::forward<Args>(args)... ); }
296
297 private:
298 Ostream & _str;
299 const Format & _fmt;
300 };
301 } //namespace detail
302
303 #define pXXX zypp::str::detail::PrintFmt(XXX,zypp::str::FormatLine)
304 #define pDBG zypp::str::detail::PrintFmt(DBG,zypp::str::FormatLine)
305 #define pMIL zypp::str::detail::PrintFmt(MIL,zypp::str::FormatLine)
306 #define pWAR zypp::str::detail::PrintFmt(WAR,zypp::str::FormatLine)
307 #define pERR zypp::str::detail::PrintFmt(ERR,zypp::str::FormatLine)
308 #define pSEC zypp::str::detail::PrintFmt(SEC,zypp::str::FormatLine)
309 #define pINT zypp::str::detail::PrintFmt(INT,zypp::str::FormatLine)
310 #define pUSR zypp::str::detail::PrintFmt(USR,zypp::str::FormatLine)
311
312 #define wXXX zypp::str::detail::PrintFmt(XXX,zypp::str::FormatWords)
313 #define wDBG zypp::str::detail::PrintFmt(DBG,zypp::str::FormatWords)
314 #define wMIL zypp::str::detail::PrintFmt(MIL,zypp::str::FormatWords)
315 #define wWAR zypp::str::detail::PrintFmt(WAR,zypp::str::FormatWords)
316 #define wERR zypp::str::detail::PrintFmt(ERR,zypp::str::FormatWords)
317 #define wSEC zypp::str::detail::PrintFmt(SEC,zypp::str::FormatWords)
318 #define wINT zypp::str::detail::PrintFmt(INT,zypp::str::FormatWords)
319 #define wUSR zypp::str::detail::PrintFmt(USR,zypp::str::FormatWords)
320
321#ifndef ZYPP_NDEBUG
322 #define pOSD zypp::str::detail::PrintFmt(OSD,zypp::str::FormatLine)
323#endif // ZYPP_NDEBUG
324
325 } // namespace str
327
328 using std::endl;
329
341 struct MLSep
342 {
343 MLSep() {}
344 MLSep( char sep_r ) : _sep { sep_r } {}
345 bool _first = true;
346 char _sep = '\n';
347 };
348 inline std::ostream & operator<<( std::ostream & str, MLSep & obj )
349 { if ( obj._first ) obj._first = false; else str << obj._sep; return str; }
350
408 template<class TIterator>
409 std::ostream & dumpRange( std::ostream & str,
410 TIterator begin, TIterator end,
411 const std::string & intro = "{",
412 const std::string & pfx = "\n ",
413 const std::string & sep = "\n ",
414 const std::string & sfx = "\n",
415 const std::string & extro = "}" )
416 {
417 str << intro;
418 if ( begin != end )
419 {
420 str << pfx << *begin;
421 for ( ++begin; begin != end; ++begin )
422 str << sep << *begin;
423 str << sfx;
424 }
425 return str << extro;
426 }
427
431 template<class TIterator>
432 std::ostream & dumpRangeLine( std::ostream & str,
433 TIterator begin, TIterator end )
434 { return dumpRange( str, begin, end, "(", "", ", ", "", ")" ); }
435
436 template<class TContainer>
437 std::ostream & dumpRangeLine( std::ostream & str, const TContainer & cont )
438 { return dumpRangeLine( str, cont.begin(), cont.end() ); }
439
440
442 namespace iomanip
443 {
448 template<class TIterator>
450 {
451 RangeLine( TIterator begin, TIterator end )
452 : _begin( begin )
453 , _end( end )
454 {}
455 TIterator _begin;
456 TIterator _end;
457 };
458
460 template<class TIterator>
461 std::ostream & operator<<( std::ostream & str, const RangeLine<TIterator> & obj )
462 { return dumpRangeLine( str, obj._begin, obj._end ); }
463
464 } // namespce iomanip
465
466
474 template<class TIterator>
475 iomanip::RangeLine<TIterator> rangeLine( TIterator begin, TIterator end )
476 { return iomanip::RangeLine<TIterator>( begin, end ); }
477
478 template<class TContainer>
479 auto rangeLine( const TContainer & cont ) -> decltype( rangeLine( cont.begin(), cont.end() ) )
480 { return rangeLine( cont.begin(), cont.end() ); }
481
482} // namespace zypp
484namespace std {
485 template<class Tp>
486 std::ostream & operator<<( std::ostream & str, const std::vector<Tp> & obj )
487 { return zypp::dumpRange( str, obj.begin(), obj.end() ); }
488
489 template<class Tp, class TCmp, class TAlloc>
490 std::ostream & operator<<( std::ostream & str, const std::set<Tp,TCmp,TAlloc> & obj )
491 { return zypp::dumpRange( str, obj.begin(), obj.end() ); }
492
493 template<class Tp>
494 std::ostream & operator<<( std::ostream & str, const std::unordered_set<Tp> & obj )
495 { return zypp::dumpRange( str, obj.begin(), obj.end() ); }
496
497 template<class Tp>
498 std::ostream & operator<<( std::ostream & str, const std::multiset<Tp> & obj )
499 { return zypp::dumpRange( str, obj.begin(), obj.end() ); }
500
501 template<class Tp>
502 std::ostream & operator<<( std::ostream & str, const std::list<Tp> & obj )
503 { return zypp::dumpRange( str, obj.begin(), obj.end() ); }
504} // namespace std
506namespace zypp {
507
508 template<class Tp>
509 std::ostream & operator<<( std::ostream & str, const Iterable<Tp> & obj )
510 { return dumpRange( str, obj.begin(), obj.end() ); }
511
514 {
515
517 // mapEntry
519
525 template<class TPair>
527 {
528 public:
529 MapEntry( const TPair & pair_r )
530 : _pair( &pair_r )
531 {}
532
533 const TPair & pair() const
534 { return *_pair; }
535
536 private:
537 const TPair *const _pair;
538 };
539
541 template<class TPair>
542 std::ostream & operator<<( std::ostream & str, const MapEntry<TPair> & obj )
543 {
544 return str << '[' << obj.pair().first << "] = " << obj.pair().second;
545 }
546
548 template<class TPair>
549 MapEntry<TPair> mapEntry( const TPair & pair_r )
550 { return MapEntry<TPair>( pair_r ); }
551
553 // dumpMap
555
560 template<class TMap>
562 {
563 public:
564 using MapType = TMap;
565 using PairType = typename TMap::value_type;
567
569 {
570 MapEntryType operator()( const PairType & pair_r ) const
571 { return mapEntry( pair_r ); }
572 };
573
575
576 public:
577 DumpMap( const TMap & map_r )
578 : _map( &map_r )
579 {}
580
581 const TMap & map() const
582 { return *_map; }
583
585 { return make_transform_iterator( map().begin(), Transformer() ); }
586
588 { return make_transform_iterator( map().end(), Transformer() );}
589
590 private:
591 const TMap *const _map;
592 };
593
595 template<class TMap>
596 std::ostream & operator<<( std::ostream & str, const DumpMap<TMap> & obj )
597 { return dumpRange( str, obj.begin(), obj.end() ); }
598
600 template<class TMap>
601 DumpMap<TMap> dumpMap( const TMap & map_r )
602 { return DumpMap<TMap>( map_r ); }
603
605 // dumpKeys
607
615 template<class TMap>
617 {
618 public:
620
621 public:
622 DumpKeys( const TMap & map_r )
623 : _map( &map_r )
624 {}
625
626 const TMap & map() const
627 { return *_map; }
628
630 { return make_map_key_begin( map() ); }
631
633 { return make_map_key_end( map() ); }
634
635 private:
636 const TMap *const _map;
637 };
638
640 template<class TMap>
641 std::ostream & operator<<( std::ostream & str, const DumpKeys<TMap> & obj )
642 { return dumpRange( str, obj.begin(), obj.end() ); }
643
645 template<class TMap>
646 DumpKeys<TMap> dumpKeys( const TMap & map_r )
647 { return DumpKeys<TMap>( map_r ); }
648
650 // dumpValues
652
660 template<class TMap>
662 {
663 public:
665
666 public:
667 DumpValues( const TMap & map_r )
668 : _map( &map_r )
669 {}
670
671 const TMap & map() const
672 { return *_map; }
673
676
678 { return make_map_value_end( map() ); }
679
680 private:
681 const TMap *const _map;
682 };
683
685 template<class TMap>
686 std::ostream & operator<<( std::ostream & str, const DumpValues<TMap> & obj )
687 { return dumpRange( str, obj.begin(), obj.end() ); }
688
690 template<class TMap>
691 DumpValues<TMap> dumpValues( const TMap & map_r )
692 { return DumpValues<TMap>( map_r ); }
693
695 } // namespace _logtoolsdetail
696
697
698 // iomanipulator
699 using _logtoolsdetail::mapEntry; // std::pair as '[key] = value'
700 using _logtoolsdetail::dumpMap; // dumpRange '[key] = value'
701 using _logtoolsdetail::dumpKeys; // dumpRange keys
702 using _logtoolsdetail::dumpValues; // dumpRange values
703
704} // namespace zypp
706namespace std {
707 template<class TKey, class Tp>
708 std::ostream & operator<<( std::ostream & str, const std::map<TKey, Tp> & obj )
709 { return str << zypp::dumpMap( obj ); }
710
711 template<class TKey, class Tp>
712 std::ostream & operator<<( std::ostream & str, const std::unordered_map<TKey, Tp> & obj )
713 { return str << zypp::dumpMap( obj ); }
714
715 template<class TKey, class Tp>
716 std::ostream & operator<<( std::ostream & str, const std::multimap<TKey, Tp> & obj )
717 { return str << zypp::dumpMap( obj ); }
718
728 inline std::ostream & operator<<( std::ostream & str, const std::basic_ios<char> & obj )
729 {
730 std::string ret( "[" );
731 ret += ( obj.good() ? 'g' : '_' );
732 ret += ( obj.eof() ? 'e' : '_' );
733 ret += ( obj.fail() ? 'F' : '_' );
734 ret += ( obj.bad() ? 'B' : '_' );
735 ret += "]";
736 return str << ret;
737 }
738} // namespace std
740namespace zypp {
741
743 // iomanipulator: str << dump(val) << ...
744 // calls: std::ostream & dumpOn( std::ostream & str, const Type & obj )
746
747 namespace detail
748 {
749 template<class Tp>
750 struct Dump
751 {
752 Dump( const Tp & obj_r ) : _obj( obj_r ) {}
753 const Tp & _obj;
754 };
755
756 template<class Tp>
757 std::ostream & operator<<( std::ostream & str, const Dump<Tp> & obj )
758 { return dumpOn( str, obj._obj ); }
759 }
760
761 template<class Tp>
762 detail::Dump<Tp> dump( const Tp & obj_r )
763 { return detail::Dump<Tp>(obj_r); }
764
773 inline std::ostream & hexdumpOn( std::ostream & outs, const unsigned char *ptr, size_t size )
774 {
775 size_t i = 0,c = 0;
776 unsigned width = 0x10;
777 outs << str::form( "hexdump %10.10ld bytes (0x%8.8lx):\n", (long)size, (long)size );
778
779 for ( i = 0; i < size; i += width ) {
780 outs << str::form( "%4.4lx: ", (long)i );
781 /* show hex to the left */
782 for ( c = 0; c < width; ++c ) {
783 if ( i+c < size )
784 outs << str::form( "%02x ", ptr[i+c] );
785 else
786 outs << (" ");
787 }
788 /* show data on the right */
789 for ( c = 0; (c < width) && (i+c < size); ++c ) {
790 char x = (ptr[i+c] >= 0x20 && ptr[i+c] < 0x7f) ? ptr[i+c] : '.';
791 outs << x;
792 }
793 outs << std::endl;
794 }
795 return outs;
796 }
797
798 inline std::ostream & hexdumpOn( std::ostream & outs, const char *ptr, size_t size )
799 { return hexdumpOn( outs, reinterpret_cast<const unsigned char*>(ptr), size ); }
800
801} // namespace zypp
803namespace std {
805 template<class D>
806 inline std::ostream & operator<<( std::ostream & str, const std::shared_ptr<D> & obj )
807 {
808 if ( obj )
809 return str << *obj;
810 return str << std::string("NULL");
811 }
812
813 template<>
814 inline std::ostream & operator<<( std::ostream & str, const std::shared_ptr<void> & obj )
815 {
816 if ( obj )
817 return str << zypp::str::form( "%p", static_cast<void*>(obj.get()) );
818 return str << std::string("NULL");
819 }
820
825 inline std::ostream & operator<<( std::ostream & str, const std::type_info &info )
826 {
827#ifdef __GNUG__
828 int status = -4; // some arbitrary value to eliminate the compiler warning
829
830 // enable c++11 by passing the flag -std=c++11 to g++
831 std::unique_ptr<char, void(*)(void*)> res {
832 abi::__cxa_demangle(info.name(), NULL, NULL, &status),
833 std::free
834 };
835 return str << std::string((status==0) ? res.get() : info.name());
836#else
837 return str << info.name();
838#endif
839 }
840
841#ifdef __cpp_lib_optional // YAST/PK explicitly use c++11 until 15-SP3
842 template<class Tp>
843 inline std::ostream & operator<<( std::ostream & str, const std::optional<Tp> & obj )
844 {
845 if ( obj )
846 str << "opt(" << *obj << ")";
847 else
848 str << "nullopt";
849 return str;
850 }
851#endif
852} // namespace std
854#endif // ZYPP_BASE_LOGTOOLS_H
Provides API related macros.
An iterator over elements which are the result of applying some functional transformation to the elem...
iterator_type begin() const
Definition Iterable.h:63
iterator_type end() const
Definition Iterable.h:66
std::map wrapper for stream output of keys.
Definition LogTools.h:617
const TMap & map() const
Definition LogTools.h:626
MapKey_const_iterator end() const
Definition LogTools.h:632
typename MapKVIteratorTraits< TMap >::Key_const_iterator MapKey_const_iterator
Definition LogTools.h:619
DumpKeys(const TMap &map_r)
Definition LogTools.h:622
MapKey_const_iterator begin() const
Definition LogTools.h:629
std::map wrapper for stream output.
Definition LogTools.h:562
transform_iterator< Transformer, typename MapType::const_iterator > MapEntry_const_iterator
Definition LogTools.h:574
MapEntry_const_iterator begin() const
Definition LogTools.h:584
MapEntry< PairType > MapEntryType
Definition LogTools.h:566
typename TMap::value_type PairType
Definition LogTools.h:565
MapEntry_const_iterator end() const
Definition LogTools.h:587
const TMap & map() const
Definition LogTools.h:581
DumpMap(const TMap &map_r)
Definition LogTools.h:577
std::map wrapper for stream output of values.
Definition LogTools.h:662
const TMap & map() const
Definition LogTools.h:671
DumpValues(const TMap &map_r)
Definition LogTools.h:667
typename MapKVIteratorTraits< TMap >::Value_const_iterator MapValue_const_iterator
Definition LogTools.h:664
MapValue_const_iterator end() const
Definition LogTools.h:677
MapValue_const_iterator begin() const
Definition LogTools.h:674
std::pair wrapper for std::map output.
Definition LogTools.h:527
MapEntry(const TPair &pair_r)
Definition LogTools.h:529
const TPair & pair() const
Definition LogTools.h:533
Helper to store a reference or move rvalues inside.
Definition LogTools.h:55
constexpr RefStore(RefStore &&rhs)
Definition LogTools.h:62
const T & get() const
Definition LogTools.h:67
constexpr RefStore(T &&val_r)
Definition LogTools.h:56
RefStore(const RefStore &)=delete
Definition ansi.h:855
ostream & operator<<(ostream &str, CCC_ &&color_r)
relates: ansi::Color Stream oputput for ColorTraits enabled types Defined in namespace 'std' because ...
Definition ansi.h:860
String related utilities and Regular expression matching.
DumpValues< TMap > dumpValues(const TMap &map_r)
relates: DumpValues Convenience function to create DumpValues from std::map.
Definition LogTools.h:691
MapEntry< TPair > mapEntry(const TPair &pair_r)
relates: MapEntry Convenience function to create MapEntry from std::pair.
Definition LogTools.h:549
DumpMap< TMap > dumpMap(const TMap &map_r)
relates: DumpMap Convenience function to create DumpMap from std::map.
Definition LogTools.h:601
std::ostream & operator<<(std::ostream &str, const MapEntry< TPair > &obj)
relates: MapEntry Stream output.
Definition LogTools.h:542
DumpKeys< TMap > dumpKeys(const TMap &map_r)
relates: DumpKeys Convenience function to create DumpKeys from std::map.
Definition LogTools.h:646
std::ostream & operator<<(std::ostream &str, const RangeLine< TIterator > &obj)
relates: RangeLine<TIterator>
Definition LogTools.h:461
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.
Definition LogTools.h:234
constexpr auto makeRefStore(T &&t) -> RefStore< T >
relates: RefStore<T> Create a RefStore for the argument.
Definition LogTools.h:96
void _joinSF(Ostream &str, const Format &fmt)
Definition LogTools.h:219
std::ostream & operator<<(std::ostream &str, const RefStore< T > &obj)
relates: RefStore<T> Stream output
Definition LogTools.h:101
Provide print[f] and sprint[f] functions based on JoinFormat.
constexpr auto FormatLine
' '-separated and NL-terminated!
Definition LogTools.h:206
std::string sprintf(Format &&fmt, Args &&... args)
Print Format fs string.
Definition LogTools.h:255
std::string sprint(Args &&... args)
Print words as string.
Definition LogTools.h:266
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.
Definition LogTools.h:196
Ostream & printf(Ostream &str, Format &&fmt, Args &&... args)
Print Format on stream.
Definition LogTools.h:250
constexpr auto FormatList
One item per line NL-terminated!
Definition LogTools.h:208
constexpr auto FormatWords
' '-separated.
Definition LogTools.h:204
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:39
constexpr auto FormatTuple
Tuple: (el, .., el).
Definition LogTools.h:210
Ostream & concat(Ostream &str, Args &&... args)
Concat words on stream.
Definition LogTools.h:271
Ostream & print(Ostream &str, Args &&... args)
Print words on stream.
Definition LogTools.h:261
std::string sconcat(Args &&... args)
Concat words as string.
Definition LogTools.h:276
constexpr auto FormatDumpRangeDefault
dumpRange default format: {}-enclosed and indented one item per line.
Definition LogTools.h:214
constexpr auto FormatConcat
Concatenated.
Definition LogTools.h:202
detail::NoPrint NoPrint
Definition LogTools.h:164
constexpr NoPrint noPrint
Definition LogTools.h:165
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).
Definition LogTools.h:432
MapKVIteratorTraits< TMap >::Key_const_iterator make_map_key_begin(const TMap &map_r)
Convenience to create the key iterator from container::begin().
Definition Iterator.h:226
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).
Definition LogTools.h:409
iomanip::RangeLine< TIterator > rangeLine(TIterator begin, TIterator end)
Iomanip printing dumpRangeLine style.
Definition LogTools.h:475
MapKVIteratorTraits< TMap >::Value_const_iterator make_map_value_begin(const TMap &map_r)
Convenience to create the value iterator from container::begin().
Definition Iterator.h:236
DumpMap< TMap > dumpMap(const TMap &map_r)
relates: DumpMap Convenience function to create DumpMap from std::map.
Definition LogTools.h:601
MapKVIteratorTraits< TMap >::Key_const_iterator make_map_key_end(const TMap &map_r)
Convenience to create the key iterator from container::end().
Definition Iterator.h:231
MapKVIteratorTraits< TMap >::Value_const_iterator make_map_value_end(const TMap &map_r)
Convenience to create the value iterator from container::end().
Definition Iterator.h:241
std::ostream & hexdumpOn(std::ostream &outs, const unsigned char *ptr, size_t size)
hexdump data on stream
Definition LogTools.h:773
detail::Dump< Tp > dump(const Tp &obj_r)
Definition LogTools.h:762
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.
Definition LogTools.h:342
MLSep(char sep_r)
Definition LogTools.h:344
bool _first
Definition LogTools.h:345
transform_iterator< GetPairFirst< typename MapType::value_type >, typename MapType::const_iterator > Key_const_iterator
The key iterator type.
Definition Iterator.h:217
transform_iterator< GetPairSecond< typename MapType::value_type >, typename MapType::const_iterator > Value_const_iterator
The value iterator type.
Definition Iterator.h:221
MapEntryType operator()(const PairType &pair_r) const
Definition LogTools.h:570
const Tp & _obj
Definition LogTools.h:753
Dump(const Tp &obj_r)
Definition LogTools.h:752
RangeLine(TIterator begin, TIterator end)
Definition LogTools.h:451
Convenient building of std::string with boost::format.
Definition String.h:254
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition String.h:213
A basic format description to print a collection.
Definition LogTools.h:141
RefStore< Extro > _extro
Definition LogTools.h:156
RefStore< Intro > _intro
Definition LogTools.h:152
constexpr JoinFormat(Intro &&intro, Pfx &&pfx, Sep &&sep, Sfx &&sfx, Extro &&extro, Pel &&pel, Sel &&sel)
Definition LogTools.h:142
Store nothing print nothing.
Definition LogTools.h:106
PrintFmt(Ostream &str, const Format &fmt)
Definition LogTools.h:288
Ostream & operator()(Args &&... args)
Definition LogTools.h:294
RefStore(const RefStore &)=delete
constexpr RefStore(RefStore &&rhs)
Definition LogTools.h:83