libzypp  17.38.9
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>
24 #include <zypp-core/base/Logger.h>
25 #include <zypp-core/base/String.h>
27 #include <zypp-core/Globals.h>
28 
29 #ifdef __GNUG__
30 #include <cstdlib>
31 #include <memory>
32 #include <cxxabi.h>
33 #endif
34 
36 namespace 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:
70  T _val;
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 <>
120  struct RefStore<NoPrint&>
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>
140  struct JoinFormat
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 
280  template <typename Ostream, typename... Args>
281  Ostream & println( Ostream & str, Args&&... args )
282  { return detail::joinSF( str, FormatLine, std::forward<Args>(args)... ); }
283 
285  template <typename... Args>
286  std::string sprintln( Args&&... args )
287  { str::Str str; return detail::joinSF( str, FormatLine, std::forward<Args>(args)... ); }
288 
289  namespace detail {
296  template <typename Ostream, typename Format>
297  struct PrintFmt {
298  PrintFmt( Ostream & str, const Format & fmt )
299  : _str { str }
300  , _fmt { fmt }
301  {}
302 
303  template <typename... Args>
304  Ostream & operator()( Args&&... args )
305  { return str::printf( _str, _fmt, std::forward<Args>(args)... ); }
306 
307  private:
308  Ostream & _str;
309  const Format & _fmt;
310  };
311  } //namespace detail
312 
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)
321 
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)
330 
331 #ifndef ZYPP_NDEBUG
332  #define pOSD zypp::str::detail::PrintFmt(OSD,zypp::str::FormatLine)
333 #endif // ZYPP_NDEBUG
334 
335  } // namespace str
337 
338  using std::endl;
339 
351  struct MLSep
352  {
353  MLSep() {}
354  MLSep( char sep_r ) : _sep { sep_r } {}
355  bool _first = true;
356  char _sep = '\n';
357  };
358  inline std::ostream & operator<<( std::ostream & str, MLSep & obj )
359  { if ( obj._first ) obj._first = false; else str << obj._sep; return str; }
360 
418  template<class TIterator>
419  std::ostream & dumpRange( std::ostream & str,
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 = "}" )
426  {
427  str << intro;
428  if ( begin != end )
429  {
430  str << pfx << *begin;
431  for ( ++begin; begin != end; ++begin )
432  str << sep << *begin;
433  str << sfx;
434  }
435  return str << extro;
436  }
437 
441  template<class TIterator>
442  std::ostream & dumpRangeLine( std::ostream & str,
443  TIterator begin, TIterator end )
444  { return dumpRange( str, begin, end, "(", "", ", ", "", ")" ); }
446  template<class TContainer>
447  std::ostream & dumpRangeLine( std::ostream & str, const TContainer & cont )
448  { return dumpRangeLine( str, cont.begin(), cont.end() ); }
449 
450 
452  namespace iomanip
453  {
458  template<class TIterator>
459  struct RangeLine
460  {
461  RangeLine( TIterator begin, TIterator end )
462  : _begin( begin )
463  , _end( end )
464  {}
465  TIterator _begin;
466  TIterator _end;
467  };
468 
470  template<class TIterator>
471  std::ostream & operator<<( std::ostream & str, const RangeLine<TIterator> & obj )
472  { return dumpRangeLine( str, obj._begin, obj._end ); }
473 
474  } // namespce iomanip
476 
484  template<class TIterator>
485  iomanip::RangeLine<TIterator> rangeLine( TIterator begin, TIterator end )
486  { return iomanip::RangeLine<TIterator>( begin, end ); }
488  template<class TContainer>
489  auto rangeLine( const TContainer & cont ) -> decltype( rangeLine( cont.begin(), cont.end() ) )
490  { return rangeLine( cont.begin(), cont.end() ); }
491 
492 } // namespace zypp
494 namespace std {
495  template<class Tp>
496  std::ostream & operator<<( std::ostream & str, const std::vector<Tp> & obj )
497  { return zypp::dumpRange( str, obj.begin(), obj.end() ); }
498 
499  template<class Tp, class TCmp, class TAlloc>
500  std::ostream & operator<<( std::ostream & str, const std::set<Tp,TCmp,TAlloc> & obj )
501  { return zypp::dumpRange( str, obj.begin(), obj.end() ); }
502 
503  template<class Tp>
504  std::ostream & operator<<( std::ostream & str, const std::unordered_set<Tp> & obj )
505  { return zypp::dumpRange( str, obj.begin(), obj.end() ); }
506 
507  template<class Tp>
508  std::ostream & operator<<( std::ostream & str, const std::multiset<Tp> & obj )
509  { return zypp::dumpRange( str, obj.begin(), obj.end() ); }
510 
511  template<class Tp>
512  std::ostream & operator<<( std::ostream & str, const std::list<Tp> & obj )
513  { return zypp::dumpRange( str, obj.begin(), obj.end() ); }
514 } // namespace std
516 namespace zypp {
517 
518  template<class Tp>
519  std::ostream & operator<<( std::ostream & str, const Iterable<Tp> & obj )
520  { return dumpRange( str, obj.begin(), obj.end() ); }
521 
523  namespace _logtoolsdetail
524  {
525 
527  // mapEntry
529 
535  template<class TPair>
536  class MapEntry
537  {
538  public:
539  MapEntry( const TPair & pair_r )
540  : _pair( &pair_r )
541  {}
542 
543  const TPair & pair() const
544  { return *_pair; }
545 
546  private:
547  const TPair *const _pair;
548  };
549 
551  template<class TPair>
552  std::ostream & operator<<( std::ostream & str, const MapEntry<TPair> & obj )
553  {
554  return str << '[' << obj.pair().first << "] = " << obj.pair().second;
555  }
556 
558  template<class TPair>
559  MapEntry<TPair> mapEntry( const TPair & pair_r )
560  { return MapEntry<TPair>( pair_r ); }
561 
563  // dumpMap
565 
570  template<class TMap>
571  class DumpMap
572  {
573  public:
574  using MapType = TMap;
575  using PairType = typename TMap::value_type;
577 
578  struct Transformer
579  {
580  MapEntryType operator()( const PairType & pair_r ) const
581  { return mapEntry( pair_r ); }
582  };
583 
584  using MapEntry_const_iterator = transform_iterator<Transformer, typename MapType::const_iterator>;
585 
586  public:
587  DumpMap( const TMap & map_r )
588  : _map( &map_r )
589  {}
590 
591  const TMap & map() const
592  { return *_map; }
593 
595  { return make_transform_iterator( map().begin(), Transformer() ); }
596 
598  { return make_transform_iterator( map().end(), Transformer() );}
599 
600  private:
601  const TMap *const _map;
602  };
603 
605  template<class TMap>
606  std::ostream & operator<<( std::ostream & str, const DumpMap<TMap> & obj )
607  { return dumpRange( str, obj.begin(), obj.end() ); }
608 
610  template<class TMap>
611  DumpMap<TMap> dumpMap( const TMap & map_r )
612  { return DumpMap<TMap>( map_r ); }
613 
615  // dumpKeys
617 
625  template<class TMap>
626  class DumpKeys
627  {
628  public:
630 
631  public:
632  DumpKeys( const TMap & map_r )
633  : _map( &map_r )
634  {}
635 
636  const TMap & map() const
637  { return *_map; }
638 
640  { return make_map_key_begin( map() ); }
641 
643  { return make_map_key_end( map() ); }
644 
645  private:
646  const TMap *const _map;
647  };
648 
650  template<class TMap>
651  std::ostream & operator<<( std::ostream & str, const DumpKeys<TMap> & obj )
652  { return dumpRange( str, obj.begin(), obj.end() ); }
653 
655  template<class TMap>
656  DumpKeys<TMap> dumpKeys( const TMap & map_r )
657  { return DumpKeys<TMap>( map_r ); }
658 
660  // dumpValues
662 
670  template<class TMap>
672  {
673  public:
675 
676  public:
677  DumpValues( const TMap & map_r )
678  : _map( &map_r )
679  {}
680 
681  const TMap & map() const
682  { return *_map; }
683 
685  { return make_map_value_begin( map() ); }
686 
688  { return make_map_value_end( map() ); }
689 
690  private:
691  const TMap *const _map;
692  };
693 
695  template<class TMap>
696  std::ostream & operator<<( std::ostream & str, const DumpValues<TMap> & obj )
697  { return dumpRange( str, obj.begin(), obj.end() ); }
698 
700  template<class TMap>
701  DumpValues<TMap> dumpValues( const TMap & map_r )
702  { return DumpValues<TMap>( map_r ); }
703 
705  } // namespace _logtoolsdetail
707 
708  // iomanipulator
709  using _logtoolsdetail::mapEntry; // std::pair as '[key] = value'
710  using _logtoolsdetail::dumpMap; // dumpRange '[key] = value'
711  using _logtoolsdetail::dumpKeys; // dumpRange keys
712  using _logtoolsdetail::dumpValues; // dumpRange values
713 
714 } // namespace zypp
716 namespace std {
717  template<class TKey, class Tp>
718  std::ostream & operator<<( std::ostream & str, const std::map<TKey, Tp> & obj )
719  { return str << zypp::dumpMap( obj ); }
720 
721  template<class TKey, class Tp>
722  std::ostream & operator<<( std::ostream & str, const std::unordered_map<TKey, Tp> & obj )
723  { return str << zypp::dumpMap( obj ); }
724 
725  template<class TKey, class Tp>
726  std::ostream & operator<<( std::ostream & str, const std::multimap<TKey, Tp> & obj )
727  { return str << zypp::dumpMap( obj ); }
728 
738  inline std::ostream & operator<<( std::ostream & str, const std::basic_ios<char> & obj )
739  {
740  std::string ret( "[" );
741  ret += ( obj.good() ? 'g' : '_' );
742  ret += ( obj.eof() ? 'e' : '_' );
743  ret += ( obj.fail() ? 'F' : '_' );
744  ret += ( obj.bad() ? 'B' : '_' );
745  ret += "]";
746  return str << ret;
747  }
748 } // namespace std
750 namespace zypp {
751 
753  // iomanipulator: str << dump(val) << ...
754  // calls: std::ostream & dumpOn( std::ostream & str, const Type & obj )
756 
757  namespace detail
758  {
759  template<class Tp>
760  struct Dump
761  {
762  Dump( const Tp & obj_r ) : _obj( obj_r ) {}
763  const Tp & _obj;
764  };
765 
766  template<class Tp>
767  std::ostream & operator<<( std::ostream & str, const Dump<Tp> & obj )
768  { return dumpOn( str, obj._obj ); }
769  }
770 
771  template<class Tp>
772  detail::Dump<Tp> dump( const Tp & obj_r )
773  { return detail::Dump<Tp>(obj_r); }
774 
783  inline std::ostream & hexdumpOn( std::ostream & outs, const unsigned char *ptr, size_t size )
784  {
785  size_t i = 0,c = 0;
786  unsigned width = 0x10;
787  outs << str::form( "hexdump %10.10ld bytes (0x%8.8lx):\n", (long)size, (long)size );
788 
789  for ( i = 0; i < size; i += width ) {
790  outs << str::form( "%4.4lx: ", (long)i );
791  /* show hex to the left */
792  for ( c = 0; c < width; ++c ) {
793  if ( i+c < size )
794  outs << str::form( "%02x ", ptr[i+c] );
795  else
796  outs << (" ");
797  }
798  /* show data on the right */
799  for ( c = 0; (c < width) && (i+c < size); ++c ) {
800  char x = (ptr[i+c] >= 0x20 && ptr[i+c] < 0x7f) ? ptr[i+c] : '.';
801  outs << x;
802  }
803  outs << std::endl;
804  }
805  return outs;
806  }
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 ); }
810 
811 } // namespace zypp
813 namespace std {
815  template<class D>
816  inline std::ostream & operator<<( std::ostream & str, const std::shared_ptr<D> & obj )
817  {
818  if ( obj )
819  return str << *obj;
820  return str << std::string("NULL");
821  }
823  template<>
824  inline std::ostream & operator<<( std::ostream & str, const std::shared_ptr<void> & obj )
825  {
826  if ( obj )
827  return str << zypp::str::form( "%p", static_cast<void*>(obj.get()) );
828  return str << std::string("NULL");
829  }
830 
835  inline std::ostream & operator<<( std::ostream & str, const std::type_info &info )
836  {
837 #ifdef __GNUG__
838  int status = -4; // some arbitrary value to eliminate the compiler warning
839 
840  // enable c++11 by passing the flag -std=c++11 to g++
841  std::unique_ptr<char, void(*)(void*)> res {
842  abi::__cxa_demangle(info.name(), NULL, NULL, &status),
843  std::free
844  };
845  return str << std::string((status==0) ? res.get() : info.name());
846 #else
847  return str << info.name();
848 #endif
849  }
850 
851 #ifdef __cpp_lib_optional // YAST/PK explicitly use c++11 until 15-SP3
852  template<class Tp>
853  inline std::ostream & operator<<( std::ostream & str, const std::optional<Tp> & obj )
854  {
855  if ( obj )
856  str << "opt(" << *obj << ")";
857  else
858  str << "nullopt";
859  return str;
860  }
861 #endif
862 } // namespace std
864 #endif // ZYPP_BASE_LOGTOOLS_H
RefStore< Extro > _extro
Definition: LogTools.h:156
Ostream & concat(Ostream &str, Args &&... args)
Concat words on stream.
Definition: LogTools.h:271
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
Store nothing print nothing.
Definition: LogTools.h:106
constexpr auto FormatConcat
Concatenated.
Definition: LogTools.h:202
constexpr auto FormatWords
&#39; &#39;-separated.
Definition: LogTools.h:204
constexpr RefStore(RefStore &&rhs)
Definition: LogTools.h:62
const TMap & map() const
Definition: LogTools.h:681
constexpr JoinFormat(Intro &&intro, Pfx &&pfx, Sep &&sep, Sfx &&sfx, Extro &&extro, Pel &&pel, Sel &&sel)
Definition: LogTools.h:142
std::string sprintf(Format &&fmt, Args &&... args)
Print Format fs string.
Definition: LogTools.h:255
const Tp & _obj
Definition: LogTools.h:763
Ostream & operator()(Args &&... args)
Definition: LogTools.h:304
Dump(const Tp &obj_r)
Definition: LogTools.h:762
MapKey_const_iterator end() const
Definition: LogTools.h:642
std::ostream & dumpRange(std::ostream &str, TIterator begin, TIterator end, const std::string &intro="{", const std::string &pfx="\ ", const std::string &sep="\ ", const std::string &sfx="\, const std::string &extro="}")
Print range defined by iterators (multiline style).
Definition: LogTools.h:419
MapValue_const_iterator end() const
Definition: LogTools.h:687
Ostream & print(Ostream &str, Args &&... args)
Print words on stream.
Definition: LogTools.h:261
String related utilities and Regular expression matching.
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
Definition: ansi.h:854
A basic format description to print a collection.
Definition: LogTools.h:140
std::string sprintln(Args &&... args)
Print line as string.
Definition: LogTools.h:286
std::map wrapper for stream output.
Definition: LogTools.h:571
Convenient building of std::string with boost::format.
Definition: String.h:253
constexpr RefStore(T &&val_r)
Definition: LogTools.h:56
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:39
Helper to store a reference or move rvalues inside.
Definition: LogTools.h:50
constexpr auto FormatTuple
Tuple: (el, .., el).
Definition: LogTools.h:210
Ostream & printf(Ostream &str, Format &&fmt, Args &&... args)
Print Format on stream.
Definition: LogTools.h:250
constexpr RefStore(RefStore &&rhs)
Definition: LogTools.h:83
DumpValues< TMap > dumpValues(const TMap &map_r)
relates: DumpValues Convenience function to create DumpValues from std::map.
Definition: LogTools.h:701
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
MapEntry(const TPair &pair_r)
Definition: LogTools.h:539
typename TMap::value_type PairType
Definition: LogTools.h:575
MapEntry< TPair > mapEntry(const TPair &pair_r)
relates: MapEntry Convenience function to create MapEntry from std::pair.
Definition: LogTools.h:559
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition: String.h:212
std::pair wrapper for std::map output.
Definition: LogTools.h:536
transform_iterator< Transformer, typename MapType::const_iterator > MapEntry_const_iterator
Definition: LogTools.h:584
DumpValues(const TMap &map_r)
Definition: LogTools.h:677
const TMap *const _map
Definition: LogTools.h:601
iomanip::RangeLine< TIterator > rangeLine(TIterator begin, TIterator end)
Iomanip printing dumpRangeLine style.
Definition: LogTools.h:485
const TPair *const _pair
Definition: LogTools.h:547
Ostream & println(Ostream &str, Args &&... args)
Print line on stream.
Definition: LogTools.h:281
Provides API related macros.
constexpr auto FormatLine
&#39; &#39;-separated and NL-terminated!
Definition: LogTools.h:206
PrintFmt(Ostream &str, const Format &fmt)
Definition: LogTools.h:298
std::ostream & operator<<(std::ostream &str, const RefStore< T > &obj)
relates: RefStore<T> Stream output
Definition: LogTools.h:101
constexpr auto FormatList
One item per line NL-terminated!
Definition: LogTools.h:208
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
std::string sconcat(Args &&... args)
Concat words as string.
Definition: LogTools.h:276
constexpr NoPrint noPrint
Definition: LogTools.h:165
std::map wrapper for stream output of keys.
Definition: LogTools.h:626
MapValue_const_iterator begin() const
Definition: LogTools.h:684
transform_iterator< GetPairFirst< typename MapType::value_type >, typename MapType::const_iterator > Key_const_iterator
The key iterator type.
Definition: Iterator.h:217
std::ostream & dumpOn(std::ostream &str, const PoolQueryIterator &obj)
relates: PoolQueryIterator Detailed stream output.
Definition: PoolQuery.cc:1838
MapEntryType operator()(const PairType &pair_r) const
Definition: LogTools.h:580
std::ostream & hexdumpOn(std::ostream &outs, const unsigned char *ptr, size_t size)
hexdump data on stream
Definition: LogTools.h:783
MapKey_const_iterator begin() const
Definition: LogTools.h:639
bool _first
Definition: LogTools.h:355
MapEntry_const_iterator end() const
Definition: LogTools.h:597
constexpr auto makeRefStore(T &&t) -> RefStore< T >
relates: RefStore<T> Create a RefStore for the argument.
Definition: LogTools.h:96
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
Helper to produce not-NL-terminated multi line output.
Definition: LogTools.h:351
void _joinSF(Ostream &str, const Format &fmt)
Definition: LogTools.h:219
typename MapKVIteratorTraits< TMap >::Key_const_iterator MapKey_const_iterator
Definition: LogTools.h:629
transform_iterator< GetPairSecond< typename MapType::value_type >, typename MapType::const_iterator > Value_const_iterator
The value iterator type.
Definition: Iterator.h:221
MLSep(char sep_r)
Definition: LogTools.h:354
constexpr RefStore(const NoPrint &)
Definition: LogTools.h:121
DumpKeys(const TMap &map_r)
Definition: LogTools.h:632
constexpr RefStore(NoPrint &&)
Definition: LogTools.h:113
const TMap & map() const
Definition: LogTools.h:591
const TPair & pair() const
Definition: LogTools.h:543
const TMap & map() const
Definition: LogTools.h:636
DumpMap< TMap > dumpMap(const TMap &map_r)
relates: DumpMap Convenience function to create DumpMap from std::map.
Definition: LogTools.h:611
Log helper wrapping the Ostream and Format.
Definition: LogTools.h:297
const TMap *const _map
Definition: LogTools.h:646
std::ostream & dumpRangeLine(std::ostream &str, TIterator begin, TIterator end)
Print range defined by iterators (single line style).
Definition: LogTools.h:442
RangeLine(TIterator begin, TIterator end)
Definition: LogTools.h:461
detail::NoPrint NoPrint
Definition: LogTools.h:164
RefStore< Intro > _intro
Definition: LogTools.h:152
std::map wrapper for stream output of values.
Definition: LogTools.h:671
std::ostream & operator<<(std::ostream &str, const Capabilities &obj)
relates: Capabilities Stream output
Definition: Capabilities.cc:65
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
DumpMap(const TMap &map_r)
Definition: LogTools.h:587
std::string sprint(Args &&... args)
Print words as string.
Definition: LogTools.h:266
detail::Dump< Tp > dump(const Tp &obj_r)
Definition: LogTools.h:772
char _sep
Definition: LogTools.h:356
MapEntry_const_iterator begin() const
Definition: LogTools.h:594
DumpKeys< TMap > dumpKeys(const TMap &map_r)
relates: DumpKeys Convenience function to create DumpKeys from std::map.
Definition: LogTools.h:656
Ostream & joinSF(Ostream &str, Format &&fmt, Args &&... args)
Print args on ostreamlike str using JoinFormat fmt.
Definition: LogTools.h:234
ostream & operator<<(ostream &str, CCC_ &&color_r)
relates: ansi::Color Stream oputput for ColorTraits enabled types Defined in namespace &#39;std&#39; because ...
Definition: ansi.h:860
typename MapKVIteratorTraits< TMap >::Value_const_iterator MapValue_const_iterator
Definition: LogTools.h:674
constexpr auto FormatDumpRangeDefault
dumpRange default format: {}-enclosed and indented one item per line.
Definition: LogTools.h:214