libzypp 17.37.10

Out.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8----------------------------------------------------------------------/
9*
10* This file contains private API, this might break at any time between releases.
11* Strictly for internal use!
12*/
13
14#ifndef OUT_H_
15#define OUT_H_
16
17#include <string>
18#include <sstream>
19#include <optional>
20
21#include <zypp-core/base/Xml.h>
22#include <zypp-core/base/NonCopyable.h>
23#include <zypp-core/base/Exception.h>
24#include <zypp-core/base/String.h>
25#include <zypp-core/base/Flags.h>
26#include <utility>
27#include <zypp-core/base/DefaultIntegral>
28#include <zypp-core/base/DtorReset>
29#include <zypp-core/Url.h>
30#include <zypp-core/TriBool.h>
31#include <zypp-core/ui/ProgressData>
32#include <zypp-core/base/LogTools.h>
33
34#include <zypp-tui/utils/text.h>
35#include <zypp-tui/utils/colors.h>
36#include <zypp-tui/utils/richtext.h>
37#include <zypp-tui/Table.h>
38#include <zypp-tui/output/PromptOptions>
39
40 namespace ztui {
41
42 class Application;
43
45 enum class ProgressEnd { done, attention, error };
46
47 namespace text
48{
49 ColorString tagNote();
50 ColorString tagWarning();
51 ColorString tagError();
52 const char * qContinue();
53
55 template <class Tltext, class Trtext>
56 inline std::string join( const Tltext & ltext, const Trtext & rtext, const char * sep = " " )
57 { std::string ret( zypp::str::asString(ltext) ); ret += sep; ret += zypp::str::asString(rtext); return ret; }
58
60 inline bool endsOnWS( const std::string & str_r )
61 {
62 bool ret = false;
63 if ( !str_r.empty() )
64 { int l = *str_r.rbegin(); if ( ::strchr( " \n\t", l ) ) ret = true; }
65 return ret;
66 }
67
68 inline const char * optBlankAfter( const std::string & str_r )
69 { return( endsOnWS( str_r ) ? "" : " " ); }
70}
71
72 namespace out
73{
74 static constexpr unsigned termwidthUnlimited = 0u;
75 unsigned defaultTermwidth(); // Zypper::instance().out().termwidth()
76} // namespace out
77
78 namespace out
79{
85 struct ListLayout
86 {
87 template <class TFormater> struct Writer;
88
89 ListLayout( bool singleline_r, bool wrapline_r, bool gaped_r, unsigned indent_r )
90 : _singleline( singleline_r )
91 , _wrapline( wrapline_r )
92 , _gaped( gaped_r )
93 , _indent( indent_r )
94 {}
95 bool _singleline;
96 bool _wrapline;
97 bool _gaped;
98 unsigned _indent;
99 };
100
101 namespace detail
102 {
103 template <bool singleline_, bool wrapline_, bool gaped_, unsigned indent_>
104 struct ListLayoutInit : public ListLayout { ListLayoutInit() : ListLayout( singleline_, wrapline_, gaped_, indent_ ) {} };
105 }
106
107 using XmlListLayout = detail::ListLayoutInit<true, false, false, 0U>;
108 using DefaultListLayout = detail::ListLayoutInit<true, true, false, 0U>;
109 using DefaultGapedListLayout = detail::ListLayoutInit<true, true, true, 0U>;
110 using IndentedListLayout = detail::ListLayoutInit<true, true, false, 2U>;
111 using IndentedGapedListLayout = detail::ListLayoutInit<true, true, true, 2U>;
112 using CompressedListLayout = detail::ListLayoutInit<false, true, false, 2U>;
113
118 struct TableLayout
119 {
120 template <class TFormater> struct Writer;
121 };
122
123 using DefaultTableLayout = TableLayout;
124
125 // Either specialize per Type or define a custom Formater:
126
128 template <class Tp>
129 std::string asXmlListElement( const Tp & val_r );
130 inline std::string asXmlListElement( const std::string & val_r ){ return val_r; }
131 inline std::string asXmlListElement( const char * val_r ) { return val_r; }
132
134 template <class Tp>
135 std::string asListElement( const Tp & val_r );
136 inline std::string asListElement( const std::string & val_r ) { return val_r; }
137 inline std::string asListElement( const char * val_r ) { return val_r; }
138
140 template <class Tp = void>
141 TableHeader asTableHeader();
142
143 template <>
144 inline TableHeader asTableHeader<void>()
145 { return TableHeader(); }
146
148 template <class Tp>
149 TableRow asTableRow( const Tp & val_r );
150
155 struct XmlFormater
156 {
157 template <class Tp>
158 std::string xmlListElement( const Tp & val_r ) const//< XML representation of element
159 { return asXmlListElement( val_r ); }
160 };
161
166 struct ListFormater : public XmlFormater
167 {
168 using NormalLayout = DefaultListLayout; //< ListLayout for NORMAL lists
169
170 template <class Tp>
171 std::string listElement( const Tp & val_r ) const //< NORMAL representation of list element
172 { return asListElement( val_r ); }
173 };
174
179 struct TableFormater : public XmlFormater
180 {
181 using NormalLayout = DefaultTableLayout; //< NORMAL layout as Table
182
183 TableHeader header() const //< TableHeader for TableRow representation
184 { return asTableHeader<>(); }
185
186 template <class Tp> //< Representation as TableRow
187 TableRow row( const Tp & val_r ) const
188 { return asTableRow( val_r ); }
189 };
190
195
196 template <class TFormater>
197 struct XmlFormaterAdaptor
198 {
199 using NormalLayout = XmlListLayout; //< Layout as XML list
200
201 template <class Tp>
202 std::string listElement( const Tp & val_r ) const //< use TFormater::asXmlListElement
203 { return _formater.xmlListElement( val_r ); }
204
205 XmlFormaterAdaptor( const TFormater & formater_r )
206 : _formater( formater_r )
207 {}
208 private:
209 const TFormater & _formater;
210 };
211
212} // namespace out
214
216 namespace out
217{
221 // TODO: wrap singlelines; support for attributed text;
223 template <class TFormater>
224 struct ListLayout::Writer
225 {
226 NON_COPYABLE( Writer );
227
228 Writer( std::ostream & str_r, const ListLayout & layout_r, const TFormater & formater_r )
229 : _str( str_r )
230 , _layout( layout_r )
231 , _formater( formater_r )
232 , _linewidth( defaultTermwidth() )
233 , _indent( _layout._indent, ' ' )
234 {}
235
236 ~Writer()
237 { if ( !_layout._singleline && _cpos ) _str << std::endl; }
238
239 template <class Tp>
240 void operator<<( Tp && val_r ) const
241 {
242 const std::string & element( _formater.listElement( std::forward<Tp>(val_r) ) );
243
244 if ( _layout._singleline )
245 {
246 if ( _layout._gaped )
247 _str << std::endl;
248 _str << _indent << element << std::endl;
249 }
250 else
251 {
252 if ( _cpos != 0 && ! fitsOnLine( 1/*' '*/ + element.size() ) )
253 endLine();
254
255 if ( _cpos == 0 )
256 {
257 if ( !_indent.empty() )
258 printAndCount( _indent );
259 }
260 else
261 printAndCount( " " );
262
263 printAndCount( element );
264 }
265 }
266
267 private:
268 bool fitsOnLine( unsigned size_r ) const
269 { return( !_layout._wrapline || _linewidth == out::termwidthUnlimited || _cpos + size_r <= _linewidth ); }
270
271 void printAndCount( const std::string & element_r ) const
272 { _cpos += element_r.size(); _str << element_r; }
273
274 void endLine() const
275 { _str << std::endl; _cpos = 0U; }
276
277 private:
278 std::ostream & _str;
279 const ListLayout & _layout;
280 const TFormater & _formater;
281 const unsigned _linewidth;
282 const std::string _indent;
283 mutable unsigned _cpos = 0U;
284 };
285
290 template <class TFormater>
291 struct TableLayout::Writer
292 {
293 NON_COPYABLE( Writer );
294
295 Writer( std::ostream & str_r, const TableLayout & layout_r, const TFormater & formater_r )
296 : _str( str_r )
297 , _layout( layout_r )
298 , _formater( formater_r )
299 {}
300
301 ~Writer()
302 {
303 if ( !_t.empty() )
304 {
305 _t.setHeader( _formater.header() );
306 _str << _t;
307 }
308 }
309
310 template <class Tp>
311 void operator<<( Tp && val_r ) const
312 { _t.add( _formater.row( std::forward<Tp>(val_r) ) ); }
313
314 private:
315 std::ostream & _str;
316 const TableLayout & _layout;
317 const TFormater & _formater;
318 mutable Table _t;
319 };
320
321
323 template <class TContainer, class TFormater, class TLayout = typename TFormater::NormalLayout>
324 void writeContainer( std::ostream & str_r, const TContainer & container_r, const TFormater & formater_r, const TLayout & layout_r = TLayout() )
325 {
326 typedef typename TLayout::template Writer<TFormater> Writer;
327 Writer writer( str_r, layout_r, formater_r );
328 for ( auto && el : container_r )
329 writer << el;
330 }
331
333 template <class TContainer, class TFormater>
334 void xmlWriteContainer( std::ostream & str_r, const TContainer & container_r, const TFormater & formater_r )
335 { writeContainer( str_r, container_r, out::XmlFormaterAdaptor<TFormater>(formater_r) ); }
336
337} // namespace out
339
340// Too simple on small terminals as esc-sequences may get truncated.
341// A table like writer for attributed strings is desirable.
342 struct TermLine
343{
344 enum SplitFlag
345 {
346 SF_CRUSH = 1<<0, //< truncate lhs, then rhs
347 SF_SPLIT = 1<<1, //< split line across two
348 SF_EXPAND = 1<<2 //< expand short lines iff stdout is a tty
349 };
350 ZYPP_DECLARE_FLAGS( SplitFlags, SplitFlag );
351
352 TermLine( SplitFlags flags_r, char exp_r ) : flagsHint( flags_r ), expHint( exp_r ) {}
353 TermLine( SplitFlags flags_r ) : flagsHint( flags_r ) {}
354 TermLine( char exp_r ) : expHint( exp_r ) {}
355 TermLine() {}
356
357 SplitFlags flagsHint; //< flags to use if not passed to \ref get
358 zypp::DefaultIntegral<char,' '> expHint; //< expand char to use if not passed to \ref get
359 zypp::DefaultIntegral<int,-1> percentHint; //< draw progress indicator in expanded space if in [0,100]
360
361 zypp::str::Str lhs; //< left side
362 zypp::str::Str rhs; //< right side
363
364
366 std::string get() const
367 { return std::string(lhs) + std::string(rhs); }
368
372 std::string get( unsigned width_r, SplitFlags flags_r, char exp_r ) const;
374 std::string get( unsigned width_r, SplitFlags flags_r ) const
375 { return get( width_r, flags_r, expHint ); }
376
377 std::string get( unsigned width_r, char exp_r ) const
378 { return get( width_r, flagsHint, exp_r ); }
379
380 std::string get( unsigned width_r ) const
381 { return get( width_r, flagsHint, expHint ); }
382};
383 ZYPP_DECLARE_OPERATORS_FOR_FLAGS( TermLine::SplitFlags );
384
423 class Out : private zypp::base::NonCopyable
424{
425 public:
427 typedef enum
428 {
429 QUIET = 0,
430 NORMAL = 1,
432 HIGH = 2,
433 DEBUG = 3
434 } Verbosity;
435
437 enum TypeBit
438 {
439 TYPE_NORMAL = 0x01<<0,
440 TYPE_XML = 0x01<<1
441 };
442 ZYPP_DECLARE_FLAGS(Type,TypeBit);
443
444 static constexpr Type TYPE_NONE = Type(0x00);
445 static constexpr Type TYPE_ALL = Type(0xff);
446
447 using PromptId = unsigned;
448
449 protected:
450 Out(TypeBit type, Verbosity verbosity = NORMAL)
451 : _verbosity(verbosity), _type(type)
452 {}
453
454 public:
455 virtual ~Out();
456
457 protected:
461 struct ParentOut
462 {
463 ParentOut( Out & out_r ) : _out( out_r ) {}
464 Out & out() { return _out; }
465 private:
466 Out & _out;
467 };
468
469 public:
479 struct XmlNode : protected ParentOut
480 {
481 using Attr = zypp::xmlout::Node::Attr;
482
484 XmlNode( Out & out_r, const std::string & name_r, const std::initializer_list<Attr> & attrs_r = {} )
485 : ParentOut( out_r )
486 {
487 if ( out().typeXML() && ! name_r.empty() )
488 { _node.reset( new zypp::xmlout::Node( std::cout, name_r, attrs_r ) ); }
489 }
490
492 XmlNode( Out & out_r, const std::string & name_r, Attr attr_r )
493 : XmlNode( out_r, name_r, { std::move(attr_r) } )
494 {}
495
497 XmlNode( XmlNode && rhs ) noexcept : ParentOut( rhs ) { _node.swap( rhs._node ); }
498
499 private:
500 zypp::scoped_ptr<zypp::xmlout::Node> _node;
501 };
502
503
509 void xmlNode( const std::string & name_r, const std::initializer_list<XmlNode::Attr> & attrs_r = {} )
510 { if ( typeXML() ) { zypp::xmlout::node( std::cout, name_r, attrs_r ); } }
511
512 void xmlNode( const std::string & name_r, XmlNode::Attr attr_r )
513 { xmlNode( name_r, { std::move(attr_r) } ); }
514
518 struct TitleNode : public XmlNode
519 {
520 TitleNode( XmlNode && node_r, const std::string & title_r = "" )
521 : XmlNode( std::move(node_r) )
522 { if ( out().typeNORMAL() && ! title_r.empty() ) std::cout << title_r << std::endl; }
523 };
524
525 private:
528 template <class TContainer, class TFormater>
529 void container( const std::string & nodeName_r, const std::string & title_r,
530 const TContainer & container_r, const TFormater & formater_r )
531 {
532 TitleNode guard( XmlNode( *this, nodeName_r, XmlNode::Attr( "size", zypp::str::numstring( container_r.size() ) ) ),
533 zypp::str::Format( title_r ) % container_r.size() );
534 switch ( type() )
535 {
536 case TYPE_NORMAL:
537 writeContainer( std::cout, container_r, formater_r );
538 break;
539 case TYPE_XML:
540 ztui::out::xmlWriteContainer( std::cout, container_r, formater_r );
541 break;
542 }
543 }
544
545 public:
548 template <class TContainer, class TFormater = out::ListFormater>
549 void list( const std::string & nodeName_r, const std::string & title_r,
550 const TContainer & container_r, const TFormater & formater_r = TFormater() )
551 { container( nodeName_r, title_r, container_r, formater_r ); }
552
555 template <class TContainer, class TFormater = out::TableFormater>
556 void table( const std::string & nodeName_r, const std::string & title_r,
557 const TContainer & container_r, const TFormater & formater_r = TFormater() )
558 { container( nodeName_r, title_r, container_r, formater_r ); }
559
560 public:
562 void gap() { if ( type() == TYPE_NORMAL ) std::cout << std::endl; }
563
564 void printRichText( std::string text, unsigned indent_r = 0U )
565 { ztui::printRichText( std::cout, std::move(text), indent_r, termwidth() ); }
566
567
569 struct ParFormat // placeholder until we need it
570 {};
571
573 template <class Text>
574 void par( size_t indent_r, const Text & text_r, ParFormat format_r = ParFormat() )
575 {
576 gap(); // if needed make it optional via ParFormat
577 zypp::str::Str formated;
578 mbs_write_wrapped( formated.stream(), zypp::str::asString(text_r), indent_r, defaultFormatWidth( 100 ) );
579 info( formated );
580 }
581
582 template <class Text>
583 void par( const Text & text_r, ParFormat format_r = ParFormat() )
584 { par( 0, text_r, format_r ); }
585
586
588 template <class TText, class Text>
589 void taggedPar( size_t indent_r, const TText & tag_r, const Text & text_r, ParFormat format_r = ParFormat() )
590 { par( indent_r, text::join( tag_r, text_r ), format_r ); }
591
592 template <class TText, class Text>
593 void taggedPar( const TText & tag_r, const Text & text_r, ParFormat format_r = ParFormat() )
594 { taggedPar( 0, tag_r, text_r, format_r ); }
595
596
598 template <class Text>
599 void notePar( size_t indent_r, const Text & text_r, ParFormat format_r = ParFormat() )
600 { taggedPar( indent_r, text::tagNote(), text_r, format_r ); }
601
602 template <class Text>
603 void notePar( const Text & text_r, ParFormat format_r = ParFormat() )
604 { notePar( 0, text_r, format_r ); }
605
607 template <class Text>
608 void warningPar( size_t indent_r, const Text & text_r, ParFormat format_r = ParFormat() )
609 { taggedPar( indent_r, text::tagWarning(), text_r, format_r ); }
610
611 template <class Text>
612 void warningPar( const Text & text_r, ParFormat format_r = ParFormat() )
613 { warningPar( 0, text_r, format_r ); }
614
616 template <class Text>
617 void errorPar( size_t indent_r, const Text & text_r, ParFormat format_r = ParFormat() )
618 { taggedPar( indent_r, text::tagError(), text_r, format_r ); }
619
620 template <class Text>
621 void errorPar( const Text & text_r, ParFormat format_r = ParFormat() )
622 { errorPar( 0, text_r, format_r ); }
623
624 public:
638 virtual void info(const std::string & msg, Verbosity verbosity = NORMAL, Type mask = TYPE_ALL) = 0;
640 void info( std::string msg, const std::string & msg2, Verbosity verbosity = NORMAL, Type mask = TYPE_ALL )
641 { info( (msg+=msg2), verbosity, mask ); }
642
644 virtual void infoLine(const TermLine & msg_r, Verbosity verbosity_r = NORMAL, Type mask_r = TYPE_ALL)
645 { info( msg_r.get(), verbosity_r, mask_r ); }
646
647 struct Info : protected ParentOut
648 {
649 NON_COPYABLE( Info );
650
651 Info( Out & out_r )
652 : ParentOut( out_r )
653 , _str( new std::ostringstream )
654 {}
655
656 Info( Out::Info && rhs ) noexcept
657 : ParentOut( rhs )
658 , _str( std::move(rhs._str) )
659 {}
660
661 ~Info()
662 { out().info( _str->str() ); }
663
664 template<class Tp>
665 std::ostream & operator<<( const Tp & val )
666 { return (*_str) << val; /*return *this;*/ }
667
668 operator std::ostream &()
669 { return *_str; }
670
671 std::ostream & stream()
672 { return *_str; }
673
674 private:
675 std::unique_ptr<std::ostringstream> _str; // work around missing move ctor
676 };
677
678 Info info() { return Info( *this ); }
679
680
682 void infoLR( const std::string & lmsg, const std::string & rmsg, Verbosity verbosity = NORMAL, Type mask = TYPE_ALL )
683 {
684 TermLine outstr( TermLine::SF_SPLIT | TermLine::SF_EXPAND );
685 outstr.lhs << lmsg;
686 outstr.rhs << ' ' << rmsg;
687 infoLine( outstr, verbosity, mask );
688 }
689
691 void infoLRHint( const std::string & lmsg, const std::string & hint, Verbosity verbosity = NORMAL, Type mask = TYPE_ALL )
692 {
693 TermLine outstr( TermLine::SF_SPLIT | TermLine::SF_EXPAND );
694 outstr.lhs << lmsg;
695 outstr.rhs << " (" << hint << ')';
696 infoLine( outstr, verbosity, mask );
697 }
698
699
713 virtual void warning(const std::string & msg, Verbosity verbosity = NORMAL, Type mask = TYPE_ALL) = 0;
714
716 struct Error;
717
726 virtual void error(const std::string & problem_desc, const std::string & hint = "") = 0;
727
736 virtual void error(const zypp::Exception & e,
737 const std::string & problem_desc,
738 const std::string & hint = "") = 0;
739
741
744
746 class ProgressBar;
747
758 virtual void progressStart(const std::string & id,
759 const std::string & label,
760 bool is_tick = false) = 0;
761
771 virtual void progress(const std::string & id,
772 const std::string & label,
773 int value = -1) = 0;
774
785 virtual void progressEnd(const std::string & id,
786 const std::string & label,
787 const std::string & donetag,
788 bool error = false) = 0;
790 void progressEnd( const std::string & id, const std::string & label, ProgressEnd donetag );
792 void progressEnd( const std::string & id, const std::string & label, bool error = false )
793 { progressEnd( id, label, error ? ProgressEnd::error : ProgressEnd::done ); }
794
795
798
803 virtual void dwnldProgressStart(const zypp::Url & uri) = 0;
804
812 virtual void dwnldProgress(const zypp::Url & uri,
813 int value = -1,
814 long rate = -1) = 0;
822 virtual void dwnldProgressEnd(const zypp::Url & uri,
823 long rate = -1,
824 zypp::TriBool error = false) = 0;
826
836 virtual void searchResult( const Table & table_r );
837
851 virtual void prompt(PromptId id,
852 const std::string & prompt,
853 const PromptOptions & poptions,
854 const std::string & startdesc = "") = 0;
855
860 virtual void promptHelp(const PromptOptions & poptions) = 0;
861
862 public:
864 Verbosity verbosity() const { return _verbosity; }
865
867 void setVerbosity(Verbosity verbosity) { _verbosity = verbosity; }
868
881#define SCOPED_VERBOSITY( OUT, LEVEL ) const auto & raii __attribute__ ((__unused__))( (OUT).scopedVerbosity( LEVEL ))
882
884 zypp::DtorReset scopedVerbosity( Verbosity verbosity_r )
885 {
886 std::swap( _verbosity, verbosity_r );
887 return zypp::DtorReset( _verbosity, verbosity_r );
888 }
889
891 virtual void setUseColors( bool yesno ) {}
892
893 public:
895 TypeBit type() const { return _type; }
896
898 bool type( TypeBit type_r ) const { return type() == type_r; }
900 bool typeNORMAL() const { return type( TYPE_NORMAL ); }
902 bool typeXML() const { return type( TYPE_XML ); }
903
908 unsigned defaultFormatWidth( unsigned desired_r = 0 ) const
909 {
910 unsigned ret = termwidth();
911 if ( ret == out::termwidthUnlimited )
912 ret = desired_r ? desired_r : 150U;
913 else if ( desired_r < ret )
914 ret = desired_r;
915 return ret;
916 }
917
919 virtual unsigned termwidth() const { return out::termwidthUnlimited; }
920
921 protected:
922
926 virtual bool mine(Type type) = 0;
927
934 virtual bool progressFilter();
935
939 virtual std::string zyppExceptionReport(const zypp::Exception & e);
940
941 private:
942 Verbosity _verbosity;
943 const TypeBit _type;
944};
945
946 ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Out::Type);
947
982 class Out::ProgressBar : private zypp::base::NonCopyable
983{
984 public:
986 struct NoStartBar {};
988 static constexpr NoStartBar noStartBar = NoStartBar();
989
990 public:
995 ProgressBar( Out & out_r, NoStartBar, std::string progressId_r, const std::string & label_r, unsigned current_r = 0, unsigned total_r = 0 )
996 : _out( out_r )
997 , _progressId(std::move( progressId_r ))
998 {
999 if ( total_r )
1000 _labelPrefix = zypp::str::form( "(%*u/%u) ", numDigits( total_r ), current_r, total_r );
1001 else if ( current_r )
1002 _labelPrefix = zypp::str::form( "(%u) ", current_r );
1003 _progress.name( label_r );
1004 _progress.sendTo( Print( *this ) );
1005 }
1006
1007 ProgressBar( Out & out_r,NoStartBar, const std::string & label_r, unsigned current_r = 0, unsigned total_r = 0 )
1008 : ProgressBar( out_r, noStartBar, "", label_r, current_r, total_r )
1009 {}
1010
1015 ProgressBar( Out & out_r, const std::string & progressId_r, const std::string & label_r, unsigned current_r = 0, unsigned total_r = 0 )
1016 : ProgressBar( out_r, noStartBar, progressId_r, label_r, current_r, total_r )
1017 {
1018 // print the initial progress bar
1019 _out.progressStart( _progressId, outLabel( _progress.name() ) );
1020 }
1021
1022 ProgressBar( Out & out_r, const std::string & label_r, unsigned current_r = 0, unsigned total_r = 0 )
1023 : ProgressBar( out_r, "", label_r, current_r, total_r )
1024 {}
1025
1030 ~ProgressBar()
1031 {
1032 _progress.noSend(); // suppress ~ProgressData final report
1033 if ( not _donetag )
1034 error( _progress.reportValue() != 100 && _progress.reportPercent() );
1035 _out.progressEnd( _progressId, outLabel( _progress.name() ), *_donetag );
1036 }
1037
1039 void print()
1040 { _out.progress( _progressId, outLabel( _progress.name() ), _progress.reportValue() ); }
1041
1043 void print( const std::string & label_r )
1044 { _progress.name( label_r ); print(); }
1045
1047 void error( ProgressEnd donetag_r = ProgressEnd::error )
1048 { _donetag = donetag_r; }
1049
1051 void error( bool error_r )
1052 { _donetag = error_r ? ProgressEnd::error : ProgressEnd::done; }
1053
1055 void errorreset()
1056 { _donetag.reset(); }
1057
1059 void error( const std::string & label_r )
1060 { _progress.name( label_r ); error( true ); }
1061
1063 void error( const char * label_r )
1064 { _progress.name( label_r ); error( true ); }
1065
1066 public:
1069 zypp::ProgressData * operator->()
1070 { return &_progress; }
1071
1072 const zypp::ProgressData * operator->() const
1073 { return &_progress; }
1074
1075 zypp::ProgressData & operator*()
1076 { return _progress; }
1077
1078 const zypp::ProgressData & operator*() const
1079 { return _progress; }
1080
1081
1082 private:
1089 struct Print
1090 {
1091 Print( ProgressBar & bar_r ) : _bar( &bar_r ) {}
1092 bool operator()( const zypp::ProgressData & progress_r )
1093 { _bar->_out.progress( _bar->_progressId, _bar->outLabel( progress_r.name() ), progress_r.reportValue() ); return true; }
1094 private:
1095 ProgressBar * _bar;
1096 };
1097
1098 std::string outLabel( const std::string & msg_r ) const
1099 { return _labelPrefix.empty() ? msg_r : _labelPrefix + msg_r; }
1100
1101 int numDigits( unsigned num_r ) const
1102 { int ret = 1; while ( num_r /= 10 ) ++ret; return ret; }
1103
1104 private:
1105 Out & _out;
1106 std::optional<ProgressEnd> _donetag;
1107 zypp::ProgressData _progress;
1108 std::string _progressId;
1109 std::string _labelPrefix;
1110};
1111
1112
1145 struct Out::Error
1146{
1147 Error( int exitcode_r )
1148 : _exitcode( exitcode_r ) {}
1149
1150 // basic: code msg hint
1151 Error( int exitcode_r, std::string msg_r, std::string hint_r = std::string() )
1152 : _exitcode( exitcode_r ), _msg( std::move(msg_r) ), _hint( std::move(hint_r) ) {}
1153
1154 // code exception hint
1155 Error( int exitcode_r, const zypp::Exception & ex_r, std::string hint_r = std::string() )
1156 : _exitcode( exitcode_r ), _msg( combine( ex_r ) ), _hint( std::move(hint_r) ) {}
1157
1158 // code (msg exception) hint
1159 Error( int exitcode_r, std::string msg_r, const zypp::Exception & ex_r, std::string hint_r = std::string() )
1160 : _exitcode( exitcode_r ), _msg( combine( std::move(msg_r), ex_r ) ), _hint( std::move(hint_r) ) {}
1161
1167 int report( Application & app_r ) const;
1168
1169 int _exitcode; //< ZYPPER_EXIT_OK indicates exitcode is already set.
1170 std::string _msg;
1171 std::string _hint;
1172
1173 private:
1174 static std::string combine( std::string && msg_r, const zypp::Exception & ex_r );
1175 static std::string combine( const zypp::Exception & ex_r );
1176};
1177
1178}
1179
1180#endif /*OUT_H_*/
Table.h
ztui::Out::ProgressBar
Convenience class for progress output.
Definition Out.h:983
ztui::Out::ProgressBar::ProgressBar
ProgressBar(Out &out_r, const std::string &label_r, unsigned current_r=0, unsigned total_r=0)
Definition Out.h:1022
ztui::Out::ProgressBar::ProgressBar
ProgressBar(Out &out_r, const std::string &progressId_r, const std::string &label_r, unsigned current_r=0, unsigned total_r=0)
Ctor displays initial progress bar.
Definition Out.h:1015
ztui::Out::ProgressBar::operator->
zypp::ProgressData * operator->()
Definition Out.h:1069
ztui::Out::ProgressBar::_progressId
std::string _progressId
Definition Out.h:1108
ztui::Out::ProgressBar::operator*
zypp::ProgressData & operator*()
Definition Out.h:1075
ztui::Out::ProgressBar::print
void print()
Immediately print the progress bar not waiting for a new trigger.
Definition Out.h:1039
ztui::Out::ProgressBar::errorreset
void errorreset()
Reset any error condition.
Definition Out.h:1055
ztui::Out::ProgressBar::_out
Out & _out
Definition Out.h:1105
ztui::Out::ProgressBar::operator->
const zypp::ProgressData * operator->() const
Definition Out.h:1072
ztui::Out::ProgressBar::_progress
zypp::ProgressData _progress
Definition Out.h:1107
ztui::Out::ProgressBar::outLabel
std::string outLabel(const std::string &msg_r) const
Definition Out.h:1098
ztui::Out::ProgressBar::~ProgressBar
~ProgressBar()
Dtor displays final progress bar.
Definition Out.h:1030
ztui::Out::ProgressBar::_labelPrefix
std::string _labelPrefix
Definition Out.h:1109
ztui::Out::ProgressBar::print
void print(const std::string &label_r)
Definition Out.h:1043
ztui::Out::ProgressBar::error
void error(bool error_r)
Definition Out.h:1051
ztui::Out::ProgressBar::error
void error(ProgressEnd donetag_r=ProgressEnd::error)
Explicitly indicate the error condition for the final progress bar.
Definition Out.h:1047
ztui::Out::ProgressBar::ProgressBar
ProgressBar(Out &out_r, NoStartBar, const std::string &label_r, unsigned current_r=0, unsigned total_r=0)
Definition Out.h:1007
ztui::Out::ProgressBar::_donetag
std::optional< ProgressEnd > _donetag
Definition Out.h:1106
ztui::Out::ProgressBar::error
void error(const char *label_r)
Definition Out.h:1063
ztui::Out::ProgressBar::noStartBar
static constexpr NoStartBar noStartBar
Indicator argument for ctor not drawing an initial start bar.
Definition Out.h:988
ztui::Out::ProgressBar::numDigits
int numDigits(unsigned num_r) const
Definition Out.h:1101
ztui::Out::ProgressBar::operator*
const zypp::ProgressData & operator*() const
Definition Out.h:1078
ztui::Out::ProgressBar::ProgressBar
ProgressBar(Out &out_r, NoStartBar, std::string progressId_r, const std::string &label_r, unsigned current_r=0, unsigned total_r=0)
Ctor not displaying an initial progress bar.
Definition Out.h:995
ztui::Out::ProgressBar::error
void error(const std::string &label_r)
Definition Out.h:1059
ztui::Out::table
void table(const std::string &nodeName_r, const std::string &title_r, const TContainer &container_r, const TFormater &formater_r=TFormater())
Write table from container creating a TitleNode with size="nnn" attribute and replacing optional %1% ...
Definition Out.h:556
ztui::Out::warningPar
void warningPar(size_t indent_r, const Text &text_r, ParFormat format_r=ParFormat())
Paragraph tagged with 'Warning: '.
Definition Out.h:608
ztui::Out::mine
virtual bool mine(Type type)=0
Determine whether the output is intended for the particular type.
ztui::Out::infoLR
void infoLR(const std::string &lmsg, const std::string &rmsg, Verbosity verbosity=NORMAL, Type mask=TYPE_ALL)
Info message, 2 strings L/R-adjusted.
Definition Out.h:682
ztui::Out::verbosity
Verbosity verbosity() const
Get current verbosity.
Definition Out.h:864
ztui::Out::scopedVerbosity
zypp::DtorReset scopedVerbosity(Verbosity verbosity_r)
Return RAII class for exception safe scoped verbosity change.
Definition Out.h:884
ztui::Out::Out
Out(TypeBit type, Verbosity verbosity=NORMAL)
Definition Out.h:450
ztui::Out::par
void par(const Text &text_r, ParFormat format_r=ParFormat())
Definition Out.h:583
ztui::Out::defaultFormatWidth
unsigned defaultFormatWidth(unsigned desired_r=0) const
Terminal width or 150 if unlimited.
Definition Out.h:908
ztui::Out::setVerbosity
void setVerbosity(Verbosity verbosity)
Set current verbosity.
Definition Out.h:867
ztui::Out::infoLRHint
void infoLRHint(const std::string &lmsg, const std::string &hint, Verbosity verbosity=NORMAL, Type mask=TYPE_ALL)
Info message with R-adjusted "(hint)".
Definition Out.h:691
ztui::Out::notePar
void notePar(const Text &text_r, ParFormat format_r=ParFormat())
Definition Out.h:603
ztui::Out::info
Info info()
Definition Out.h:678
ztui::Out::warningPar
void warningPar(const Text &text_r, ParFormat format_r=ParFormat())
Definition Out.h:612
ztui::Out::typeNORMAL
bool typeNORMAL() const
Definition Out.h:900
ztui::Out::progressEnd
void progressEnd(const std::string &id, const std::string &label, bool error=false)
Definition Out.h:792
ztui::Out::gap
void gap()
NORMAL: An empty line.
Definition Out.h:562
ztui::Out::taggedPar
void taggedPar(size_t indent_r, const TText &tag_r, const Text &text_r, ParFormat format_r=ParFormat())
Paragraph of text preceded by 'tag_r' and a ' '.
Definition Out.h:589
ztui::Out::dwnldProgress
virtual void dwnldProgress(const zypp::Url &uri, int value=-1, long rate=-1)=0
Reports download progress.
ztui::Out::error
virtual void error(const zypp::Exception &e, const std::string &problem_desc, const std::string &hint="")=0
Prints the problem description caused by an exception, its cause and, optionally, a hint for the user...
ztui::Out::TYPE_ALL
static constexpr Type TYPE_ALL
Definition Out.h:445
ztui::Out::prompt
virtual void prompt(PromptId id, const std::string &prompt, const PromptOptions &poptions, const std::string &startdesc="")=0
Prompt the user for a decision.
ztui::Out::info
void info(std::string msg, const std::string &msg2, Verbosity verbosity=NORMAL, Type mask=TYPE_ALL)
Definition Out.h:640
ztui::Out::notePar
void notePar(size_t indent_r, const Text &text_r, ParFormat format_r=ParFormat())
Paragraph tagged with 'Note: '.
Definition Out.h:599
ztui::Out::warning
virtual void warning(const std::string &msg, Verbosity verbosity=NORMAL, Type mask=TYPE_ALL)=0
Show a warning.
ztui::Out::container
void container(const std::string &nodeName_r, const std::string &title_r, const TContainer &container_r, const TFormater &formater_r)
Write container creating a TitleNode with size="nnn" attribute and replacing optional %1% in title_r ...
Definition Out.h:529
ztui::Out::termwidth
virtual unsigned termwidth() const
Width for formatted output [0==unlimited].
Definition Out.h:919
ztui::Out::errorPar
void errorPar(const Text &text_r, ParFormat format_r=ParFormat())
Definition Out.h:621
ztui::Out::list
void list(const std::string &nodeName_r, const std::string &title_r, const TContainer &container_r, const TFormater &formater_r=TFormater())
Write list from container creating a TitleNode with size="nnn" attribute and replacing optional %1% i...
Definition Out.h:549
ztui::Out::Verbosity
Verbosity
Verbosity levels.
Definition Out.h:428
ztui::Out::QUIET
@ QUIET
Only important messages (no progress or status, only the result).
Definition Out.h:429
ztui::Out::NORMAL
@ NORMAL
Default output verbosity level.
Definition Out.h:430
ztui::Out::HIGH
@ HIGH
More detailed description of the operations.
Definition Out.h:432
ztui::Out::DEBUG
@ DEBUG
Definition Out.h:433
ztui::Out::printRichText
void printRichText(std::string text, unsigned indent_r=0U)
Definition Out.h:564
ztui::Out::setUseColors
virtual void setUseColors(bool yesno)
Hint for a handler whether config would allow to use colors.
Definition Out.h:891
ztui::Out::_verbosity
Verbosity _verbosity
Definition Out.h:942
ztui::Out::TYPE_NONE
static constexpr Type TYPE_NONE
Definition Out.h:444
ztui::Out::promptHelp
virtual void promptHelp(const PromptOptions &poptions)=0
Print help for prompt, if available.
ztui::Out::xmlNode
void xmlNode(const std::string &name_r, const std::initializer_list< XmlNode::Attr > &attrs_r={})
XML only: Write a leaf node without PCDATA.
Definition Out.h:509
ztui::Out::progressFilter
virtual bool progressFilter()
Determine whether to show progress.
Definition Out.cc:123
ztui::Out::type
TypeBit type() const
Return the type of the instance.
Definition Out.h:895
ztui::Out::error
virtual void error(const std::string &problem_desc, const std::string &hint="")=0
Show an error message and an optional hint.
ztui::Out::searchResult
virtual void searchResult(const Table &table_r)
Print out a search result.
Definition Out.cc:133
ztui::Out::info
virtual void info(const std::string &msg, Verbosity verbosity=NORMAL, Type mask=TYPE_ALL)=0
Show an info message.
ztui::Out::zyppExceptionReport
virtual std::string zyppExceptionReport(const zypp::Exception &e)
Return a Exception as a string suitable for output.
Definition Out.cc:128
ztui::Out::PromptId
unsigned PromptId
Definition Out.h:447
ztui::Out::dwnldProgressEnd
virtual void dwnldProgressEnd(const zypp::Url &uri, long rate=-1, zypp::TriBool error=false)=0
Reports end of a download.
ztui::Out::xmlNode
void xmlNode(const std::string &name_r, XmlNode::Attr attr_r)
Definition Out.h:512
ztui::Out::infoLine
virtual void infoLine(const TermLine &msg_r, Verbosity verbosity_r=NORMAL, Type mask_r=TYPE_ALL)
info taking a TermLine
Definition Out.h:644
ztui::Out::progress
virtual void progress(const std::string &id, const std::string &label, int value=-1)=0
Progress report for an on-going operation.
ztui::Out::~Out
virtual ~Out()
Definition Out.cc:120
ztui::Out::typeXML
bool typeXML() const
Definition Out.h:902
ztui::Out::par
void par(size_t indent_r, const Text &text_r, ParFormat format_r=ParFormat())
Paragraph of text, optionally indented, or without leading gap.
Definition Out.h:574
ztui::Out::TypeBit
TypeBit
Known output types implemented by derived classes.
Definition Out.h:438
ztui::Out::TYPE_XML
@ TYPE_XML
xml output
Definition Out.h:440
ztui::Out::TYPE_NORMAL
@ TYPE_NORMAL
plain text output
Definition Out.h:439
ztui::Out::taggedPar
void taggedPar(const TText &tag_r, const Text &text_r, ParFormat format_r=ParFormat())
Definition Out.h:593
ztui::Out::progressEnd
virtual void progressEnd(const std::string &id, const std::string &label, const std::string &donetag, bool error=false)=0
End of an operation with reported progress.
ztui::Out::progressStart
virtual void progressStart(const std::string &id, const std::string &label, bool is_tick=false)=0
Start of an operation with reported progress.
ztui::Out::_type
const TypeBit _type
Definition Out.h:943
ztui::Out::errorPar
void errorPar(size_t indent_r, const Text &text_r, ParFormat format_r=ParFormat())
Paragraph tagged with 'Error: '.
Definition Out.h:617
ztui::Out::dwnldProgressStart
virtual void dwnldProgressStart(const zypp::Url &uri)=0
Reoprt start of a download.
ztui::Out::type
bool type(TypeBit type_r) const
Test for a specific type.
Definition Out.h:898
ztui::Out::ZYPP_DECLARE_FLAGS
ZYPP_DECLARE_FLAGS(Type, TypeBit)
ztui::PromptOptions
Example: PromptOptions popts; popts.setOptions(_("y/n/p"), 0 / * default reply * /); popts....
Definition promptoptions.h:39
ztui::TableHeader
Definition Table.h:282
ztui::TableRow
Definition Table.h:167
ztui::Table
Definition Table.h:398
zypp::Application
Class representing an application (appdata.xml)
Definition Application.h:28
zypp::DefaultIntegral
Integral type with defined initial value when default constructed.
Definition defaultintegral.h:42
zypp::DtorReset
Assign a vaiable a certain value when going out of scope.
Definition dtorreset.h:50
zypp::Exception
Base class for Exception.
Definition Exception.h:153
zypp::ProgressData
Maintain [min,max] and counter (value) for progress counting.
Definition progressdata.h:132
zypp::ProgressData::reportValue
value_type reportValue() const
Definition progressdata.h:322
zypp::ProgressData::name
void name(const std::string &name_r)
Set counter name.
Definition progressdata.h:225
zypp::Url
Url manipulation class.
Definition Url.h:93
colors.h
std
Definition Arch.h:364
ztui::out::detail
Definition Out.h:102
ztui::out
Definition Out.cc:37
ztui::out::asTableHeader< void >
TableHeader asTableHeader< void >()
Definition Out.h:144
ztui::out::DefaultGapedListLayout
detail::ListLayoutInit< true, true, true, 0U > DefaultGapedListLayout
one element per line, no indent, gaped
Definition Out.h:109
ztui::out::xmlWriteContainer
void xmlWriteContainer(std::ostream &str_r, const TContainer &container_r, const TFormater &formater_r)
Write XML formatted container to stream.
Definition Out.h:334
ztui::out::DefaultTableLayout
TableLayout DefaultTableLayout
Simple Table.
Definition Out.h:123
ztui::out::IndentedGapedListLayout
detail::ListLayoutInit< true, true, true, 2U > IndentedGapedListLayout
one element per line, indented, gaped
Definition Out.h:111
ztui::out::writeContainer
void writeContainer(std::ostream &str_r, const TContainer &container_r, const TFormater &formater_r, const TLayout &layout_r=TLayout())
Write formatted container to stream.
Definition Out.h:324
ztui::out::CompressedListLayout
detail::ListLayoutInit< false, true, false, 2U > CompressedListLayout
multiple elements per line, indented
Definition Out.h:112
ztui::out::DefaultListLayout
detail::ListLayoutInit< true, true, false, 0U > DefaultListLayout
one element per line, no indent
Definition Out.h:108
ztui::out::termwidthUnlimited
static constexpr unsigned termwidthUnlimited
Definition Out.h:74
ztui::out::IndentedListLayout
detail::ListLayoutInit< true, true, false, 2U > IndentedListLayout
one element per line, indented
Definition Out.h:110
ztui::out::XmlListLayout
detail::ListLayoutInit< true, false, false, 0U > XmlListLayout
Definition Out.h:107
ztui::out::asListElement
std::string asListElement(const std::string &val_r)
Definition Out.h:136
ztui::out::defaultTermwidth
unsigned defaultTermwidth()
Definition Out.cc:38
ztui::out::asXmlListElement
std::string asXmlListElement(const std::string &val_r)
Definition Out.h:130
ztui::text
Definition Out.cc:24
ztui::text::tagWarning
ColorString tagWarning()
translated "Warning:" warning color
Definition Out.cc:28
ztui::text::tagNote
ColorString tagNote()
translated "Note:" highlighted
Definition Out.cc:26
ztui::text::qContinue
const char * qContinue()
translated "Continue?"
Definition Out.cc:32
ztui::text::endsOnWS
bool endsOnWS(const std::string &str_r)
Whether the str_r ends with a WS.
Definition Out.h:60
ztui::text::tagError
ColorString tagError()
translated "Error:" error color
Definition Out.cc:30
ztui::text::join
std::string join(const Tltext &ltext, const Trtext &rtext, const char *sep=" ")
Simple join of two string types.
Definition Out.h:56
ztui::text::optBlankAfter
const char * optBlankAfter(const std::string &str_r)
Definition Out.h:68
ztui
Definition application.cc:13
ztui::printRichText
std::ostream & printRichText(std::ostream &str, std::string text, unsigned indent_r=0U, unsigned width_r=0U)
Print [Rich]Text optionally indented.
Definition richtext.h:26
ztui::mbs_write_wrapped
void mbs_write_wrapped(std::ostream &out, boost::string_ref text_r, size_t indent_r, size_t wrap_r, int indentFix_r=0)
Wrap and indent given text and write it to the output stream out.
Definition text.h:631
ztui::ProgressEnd
ProgressEnd
ProgressBars default end tags.
Definition Out.h:45
ztui::ProgressEnd::attention
@ attention
Definition Out.h:45
ztui::ProgressEnd::done
@ done
Definition Out.h:45
ztui::ProgressEnd::error
@ error
Definition Out.h:45
zypp::base::NonCopyable
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition NonCopyable.h:26
zypp::str::numstring
std::string numstring(char n, int w=0)
Definition String.h:290
zypp::str::asString
const std::string & asString(const std::string &t)
Global asString() that works with std::string too.
Definition String.h:140
zypp::str::form
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:39
zypp::xmlout::node
std::ostream & node(std::ostream &out_r, const std::string &name_r, Node::Attr attr_r)
Definition Xml.h:204
zypp::TriBool
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition String.h:31
richtext.h
ztui::Out::Error
Convenience class Error reporting.
Definition Out.h:1146
ztui::Out::Error::_exitcode
int _exitcode
Definition Out.h:1169
ztui::Out::Error::_hint
std::string _hint
Definition Out.h:1171
ztui::Out::Error::Error
Error(int exitcode_r, const zypp::Exception &ex_r, std::string hint_r=std::string())
Definition Out.h:1155
ztui::Out::Error::combine
static std::string combine(std::string &&msg_r, const zypp::Exception &ex_r)
Definition Out.cc:164
ztui::Out::Error::_msg
std::string _msg
Definition Out.h:1170
ztui::Out::Error::Error
Error(int exitcode_r, std::string msg_r, std::string hint_r=std::string())
Definition Out.h:1151
ztui::Out::Error::report
int report(Application &app_r) const
Default way of processing a caught Error exception.
Definition Out.cc:155
ztui::Out::Error::Error
Error(int exitcode_r, std::string msg_r, const zypp::Exception &ex_r, std::string hint_r=std::string())
Definition Out.h:1159
ztui::Out::Error::Error
Error(int exitcode_r)
Definition Out.h:1147
ztui::Out::Info
Definition Out.h:648
ztui::Out::Info::NON_COPYABLE
NON_COPYABLE(Info)
ztui::Out::Info::stream
std::ostream & stream()
Definition Out.h:671
ztui::Out::Info::_str
std::unique_ptr< std::ostringstream > _str
Definition Out.h:675
ztui::Out::Info::Info
Info(Out::Info &&rhs) noexcept
Definition Out.h:656
ztui::Out::Info::operator<<
std::ostream & operator<<(const Tp &val)
Definition Out.h:665
ztui::Out::Info::~Info
~Info()
Definition Out.h:661
ztui::Out::Info::Info
Info(Out &out_r)
Definition Out.h:651
ztui::Out::ParFormat
Less common Paragraph formats.
Definition Out.h:570
ztui::Out::ParentOut
Convenience base class storing the back reference to Out.
Definition Out.h:462
ztui::Out::ParentOut::ParentOut
ParentOut(Out &out_r)
Definition Out.h:463
ztui::Out::ParentOut::_out
Out & _out
Definition Out.h:466
ztui::Out::ParentOut::out
Out & out()
Definition Out.h:464
ztui::Out::ProgressBar::NoStartBar
Indicator type for ctor not drawing an initial start bar.
Definition Out.h:986
ztui::Out::ProgressBar::Print
ProgressData::ReceiverFnc printing to a ProgressBar.
Definition Out.h:1090
ztui::Out::ProgressBar::Print::_bar
ProgressBar * _bar
Definition Out.h:1095
ztui::Out::ProgressBar::Print::Print
Print(ProgressBar &bar_r)
Definition Out.h:1091
ztui::Out::ProgressBar::Print::operator()
bool operator()(const zypp::ProgressData &progress_r)
Definition Out.h:1092
ztui::Out::TitleNode
XmlNode with optional normal text headline (NL appended)
Definition Out.h:519
ztui::Out::TitleNode::TitleNode
TitleNode(XmlNode &&node_r, const std::string &title_r="")
Definition Out.h:520
ztui::Out::XmlNode
XML only: RAII writing a XML nodes start/end tag.
Definition Out.h:480
ztui::Out::XmlNode::_node
zypp::scoped_ptr< zypp::xmlout::Node > _node
Definition Out.h:500
ztui::Out::XmlNode::Attr
zypp::xmlout::Node::Attr Attr
Definition Out.h:481
ztui::Out::XmlNode::XmlNode
XmlNode(XmlNode &&rhs) noexcept
Move ctor.
Definition Out.h:497
ztui::Out::XmlNode::XmlNode
XmlNode(Out &out_r, const std::string &name_r, const std::initializer_list< Attr > &attrs_r={})
Ctor taking nodename and attribute list.
Definition Out.h:484
ztui::Out::XmlNode::XmlNode
XmlNode(Out &out_r, const std::string &name_r, Attr attr_r)
Convenience ctor for one attribute pair.
Definition Out.h:492
ztui::TermLine
Definition Out.h:343
ztui::TermLine::TermLine
TermLine(char exp_r)
Definition Out.h:354
ztui::TermLine::TermLine
TermLine(SplitFlags flags_r, char exp_r)
Definition Out.h:352
ztui::TermLine::TermLine
TermLine()
Definition Out.h:355
ztui::TermLine::get
std::string get(unsigned width_r, char exp_r) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition Out.h:377
ztui::TermLine::TermLine
TermLine(SplitFlags flags_r)
Definition Out.h:353
ztui::TermLine::expHint
zypp::DefaultIntegral< char,' '> expHint
Definition Out.h:358
ztui::TermLine::SplitFlag
SplitFlag
Definition Out.h:345
ztui::TermLine::SF_CRUSH
@ SF_CRUSH
Definition Out.h:346
ztui::TermLine::SF_SPLIT
@ SF_SPLIT
Definition Out.h:347
ztui::TermLine::SF_EXPAND
@ SF_EXPAND
Definition Out.h:348
ztui::TermLine::percentHint
zypp::DefaultIntegral< int,-1 > percentHint
Definition Out.h:359
ztui::TermLine::get
std::string get() const
Return plain line made of lhs + rhs.
Definition Out.h:366
ztui::TermLine::rhs
zypp::str::Str rhs
Definition Out.h:362
ztui::TermLine::get
std::string get(unsigned width_r, SplitFlags flags_r) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition Out.h:374
ztui::TermLine::ZYPP_DECLARE_FLAGS
ZYPP_DECLARE_FLAGS(SplitFlags, SplitFlag)
ztui::TermLine::get
std::string get(unsigned width_r) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition Out.h:380
ztui::TermLine::flagsHint
SplitFlags flagsHint
Definition Out.h:357
ztui::TermLine::lhs
zypp::str::Str lhs
Definition Out.h:361
ztui::out::ListFormater
Default representation of types in Lists [asListElement].
Definition Out.h:167
ztui::out::ListFormater::NormalLayout
DefaultListLayout NormalLayout
Definition Out.h:168
ztui::out::ListFormater::listElement
std::string listElement(const Tp &val_r) const
Definition Out.h:171
ztui::out::ListFormater::asListElement
std::string asListElement(const Tp &val_r)
NORMAL representation of types in lists [no default].
ztui::out::ListLayout::Writer
Write out a List according to the layout.
Definition Out.h:225
ztui::out::ListLayout::Writer::endLine
void endLine() const
Definition Out.h:274
ztui::out::ListLayout::Writer::_cpos
unsigned _cpos
Definition Out.h:283
ztui::out::ListLayout::Writer::NON_COPYABLE
NON_COPYABLE(Writer)
ztui::out::ListLayout::Writer::printAndCount
void printAndCount(const std::string &element_r) const
Definition Out.h:271
ztui::out::ListLayout::Writer::_layout
const ListLayout & _layout
Definition Out.h:279
ztui::out::ListLayout::Writer::~Writer
~Writer()
Definition Out.h:236
ztui::out::ListLayout::Writer::_linewidth
const unsigned _linewidth
desired line width
Definition Out.h:281
ztui::out::ListLayout::Writer::_indent
const std::string _indent
Definition Out.h:282
ztui::out::ListLayout::Writer::fitsOnLine
bool fitsOnLine(unsigned size_r) const
Definition Out.h:268
ztui::out::ListLayout::Writer::operator<<
void operator<<(Tp &&val_r) const
Definition Out.h:240
ztui::out::ListLayout::Writer::Writer
Writer(std::ostream &str_r, const ListLayout &layout_r, const TFormater &formater_r)
Definition Out.h:228
ztui::out::ListLayout::Writer::_str
std::ostream & _str
Definition Out.h:278
ztui::out::ListLayout::Writer::_formater
const TFormater & _formater
Definition Out.h:280
ztui::out::ListLayout::_singleline
bool _singleline
one list element per line
Definition Out.h:95
ztui::out::ListLayout::_indent
unsigned _indent
amount of indent
Definition Out.h:98
ztui::out::ListLayout::_gaped
bool _gaped
add extra NL before element (if singleline)
Definition Out.h:97
ztui::out::ListLayout::_wrapline
bool _wrapline
fold lines longer than _linewidth
Definition Out.h:96
ztui::out::ListLayout::ListLayout
ListLayout(bool singleline_r, bool wrapline_r, bool gaped_r, unsigned indent_r)
Definition Out.h:89
ztui::out::TableFormater
Special list formater writing a Table [asTableHeader|asTableRow].
Definition Out.h:180
ztui::out::TableFormater::header
TableHeader header() const
Definition Out.h:183
ztui::out::TableFormater::asTableRow
TableRow asTableRow(const Tp &val_r)
NORMAL representation of types as TableRow [no default].
ztui::out::TableFormater::asTableHeader
TableHeader asTableHeader()
NORMAL representation of types as TableHeader [no default].
ztui::out::TableFormater::row
TableRow row(const Tp &val_r) const
Definition Out.h:187
ztui::out::TableFormater::NormalLayout
DefaultTableLayout NormalLayout
Definition Out.h:181
ztui::out::TableLayout::Writer
Write out a Table according to the layout.
Definition Out.h:292
ztui::out::TableLayout::Writer::_layout
const TableLayout & _layout
Definition Out.h:316
ztui::out::TableLayout::Writer::_str
std::ostream & _str
Definition Out.h:315
ztui::out::TableLayout::Writer::operator<<
void operator<<(Tp &&val_r) const
Definition Out.h:311
ztui::out::TableLayout::Writer::_t
Table _t
Definition Out.h:318
ztui::out::TableLayout::Writer::Writer
Writer(std::ostream &str_r, const TableLayout &layout_r, const TFormater &formater_r)
Definition Out.h:295
ztui::out::TableLayout::Writer::NON_COPYABLE
NON_COPYABLE(Writer)
ztui::out::TableLayout::Writer::_formater
const TFormater & _formater
Definition Out.h:317
ztui::out::TableLayout::Writer::~Writer
~Writer()
Definition Out.h:301
ztui::out::TableLayout
Basic table layout.
Definition Out.h:119
ztui::out::XmlFormaterAdaptor
Adaptor.
Definition Out.h:198
ztui::out::XmlFormaterAdaptor::XmlFormaterAdaptor
XmlFormaterAdaptor(const TFormater &formater_r)
Definition Out.h:205
ztui::out::XmlFormaterAdaptor::listElement
std::string listElement(const Tp &val_r) const
Definition Out.h:202
ztui::out::XmlFormaterAdaptor::_formater
const TFormater & _formater
Definition Out.h:209
ztui::out::XmlFormaterAdaptor::NormalLayout
XmlListLayout NormalLayout
Definition Out.h:199
ztui::out::XmlFormater
XML representation of types in container [asXmlListElement].
Definition Out.h:156
ztui::out::XmlFormater::xmlListElement
std::string xmlListElement(const Tp &val_r) const
Definition Out.h:158
ztui::out::XmlFormater::asXmlListElement
std::string asXmlListElement(const Tp &val_r)
XML representation of types [no default].
ztui::out::detail::ListLayoutInit
Definition Out.h:104
ztui::out::detail::ListLayoutInit::ListLayoutInit
ListLayoutInit()
Definition Out.h:104
zypp::str::Format
Convenient building of std::string with boost::format.
Definition String.h:254
zypp::str::Str
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition String.h:213
zypp::str::Str::stream
const std::ostream & stream() const
Definition String.h:225
zypp::xmlout::Node::Attr
NodeAttr Attr
Definition Xml.h:87
text.h
TriBool.h
Url.h
Exception.h
Flags.h
ZYPP_DECLARE_OPERATORS_FOR_FLAGS
#define ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name)
Definition Flags.h:177
LogTools.h
NonCopyable.h
String.h
Xml.h