27#include <zypp-core/base/DefaultIntegral>
28#include <zypp-core/base/DtorReset>
31#include <zypp-core/ui/ProgressData>
38#include <zypp-tui/output/PromptOptions>
55 template <
class Tltext,
class Trtext>
64 {
int l = *
str_r.rbegin();
if ( ::strchr(
" \n\t",
l ) )
ret =
true; }
87 template <
class TFormater>
struct Writer;
103 template <
bool singleline_,
bool wrapline_,
bool gaped_,
unsigned indent_>
120 template <
class TFormater>
struct Writer;
140 template <
class Tp =
void>
196 template <
class TFormater>
223 template <
class TFormater>
290 template <
class TFormater>
323 template <
class TContainer,
class TFormater,
class TLayout =
typename TFormater::NormalLayout>
333 template <
class TContainer,
class TFormater>
367 {
return std::string(
lhs) + std::string(
rhs); }
528 template <
class TContainer,
class TFormater>
548 template <
class TContainer,
class TFormater = out::ListFormater>
555 template <
class TContainer,
class TFormater = out::TableFormater>
573 template <
class Text>
582 template <
class Text>
588 template <
class TText,
class Text>
592 template <
class TText,
class Text>
598 template <
class Text>
602 template <
class Text>
607 template <
class Text>
611 template <
class Text>
616 template <
class Text>
620 template <
class Text>
658 ,
_str( std::move(rhs._str) )
666 {
return (*
_str) << val; }
668 operator std::ostream &()
675 std::unique_ptr<std::ostringstream>
_str;
695 outstr.rhs <<
" (" << hint <<
')';
738 const std::string & hint =
"") = 0;
759 const std::string & label,
772 const std::string & label,
786 const std::string & label,
788 bool error =
false) = 0;
852 const std::string &
prompt,
881#define SCOPED_VERBOSITY( OUT, LEVEL ) const auto & raii __attribute__ ((__unused__))( (OUT).scopedVerbosity( LEVEL ))
Convenience class for progress output.
ProgressBar(Out &out_r, const std::string &label_r, unsigned current_r=0, unsigned total_r=0)
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.
zypp::ProgressData * operator->()
zypp::ProgressData & operator*()
void print()
Immediately print the progress bar not waiting for a new trigger.
void errorreset()
Reset any error condition.
const zypp::ProgressData * operator->() const
zypp::ProgressData _progress
std::string outLabel(const std::string &msg_r) const
~ProgressBar()
Dtor displays final progress bar.
void print(const std::string &label_r)
void error(ProgressEnd donetag_r=ProgressEnd::error)
Explicitly indicate the error condition for the final progress bar.
ProgressBar(Out &out_r, NoStartBar, const std::string &label_r, unsigned current_r=0, unsigned total_r=0)
std::optional< ProgressEnd > _donetag
void error(const char *label_r)
static constexpr NoStartBar noStartBar
Indicator argument for ctor not drawing an initial start bar.
int numDigits(unsigned num_r) const
const zypp::ProgressData & operator*() const
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.
void error(const std::string &label_r)
Base class for producing common (for now) zypper output.
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% ...
void warningPar(size_t indent_r, const Text &text_r, ParFormat format_r=ParFormat())
Paragraph tagged with 'Warning: '.
virtual bool mine(Type type)=0
Determine whether the output is intended for the particular type.
void infoLR(const std::string &lmsg, const std::string &rmsg, Verbosity verbosity=NORMAL, Type mask=TYPE_ALL)
Info message, 2 strings L/R-adjusted.
Verbosity verbosity() const
Get current verbosity.
zypp::DtorReset scopedVerbosity(Verbosity verbosity_r)
Return RAII class for exception safe scoped verbosity change.
Out(TypeBit type, Verbosity verbosity=NORMAL)
void par(const Text &text_r, ParFormat format_r=ParFormat())
unsigned defaultFormatWidth(unsigned desired_r=0) const
Terminal width or 150 if unlimited.
void setVerbosity(Verbosity verbosity)
Set current verbosity.
void infoLRHint(const std::string &lmsg, const std::string &hint, Verbosity verbosity=NORMAL, Type mask=TYPE_ALL)
Info message with R-adjusted "(hint)".
void notePar(const Text &text_r, ParFormat format_r=ParFormat())
void warningPar(const Text &text_r, ParFormat format_r=ParFormat())
void progressEnd(const std::string &id, const std::string &label, bool error=false)
void gap()
NORMAL: An empty line.
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 ' '.
virtual void dwnldProgress(const zypp::Url &uri, int value=-1, long rate=-1)=0
Reports download progress.
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...
static constexpr Type TYPE_ALL
virtual void prompt(PromptId id, const std::string &prompt, const PromptOptions &poptions, const std::string &startdesc="")=0
Prompt the user for a decision.
void info(std::string msg, const std::string &msg2, Verbosity verbosity=NORMAL, Type mask=TYPE_ALL)
void notePar(size_t indent_r, const Text &text_r, ParFormat format_r=ParFormat())
Paragraph tagged with 'Note: '.
virtual void warning(const std::string &msg, Verbosity verbosity=NORMAL, Type mask=TYPE_ALL)=0
Show a warning.
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 ...
virtual unsigned termwidth() const
Width for formatted output [0==unlimited].
void errorPar(const Text &text_r, ParFormat format_r=ParFormat())
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...
Verbosity
Verbosity levels.
@ QUIET
Only important messages (no progress or status, only the result).
@ NORMAL
Default output verbosity level.
@ HIGH
More detailed description of the operations.
void printRichText(std::string text, unsigned indent_r=0U)
virtual void setUseColors(bool yesno)
Hint for a handler whether config would allow to use colors.
static constexpr Type TYPE_NONE
virtual void promptHelp(const PromptOptions &poptions)=0
Print help for prompt, if available.
void xmlNode(const std::string &name_r, const std::initializer_list< XmlNode::Attr > &attrs_r={})
XML only: Write a leaf node without PCDATA.
virtual bool progressFilter()
Determine whether to show progress.
TypeBit type() const
Return the type of the instance.
virtual void error(const std::string &problem_desc, const std::string &hint="")=0
Show an error message and an optional hint.
virtual void searchResult(const Table &table_r)
Print out a search result.
virtual void info(const std::string &msg, Verbosity verbosity=NORMAL, Type mask=TYPE_ALL)=0
Show an info message.
virtual std::string zyppExceptionReport(const zypp::Exception &e)
Return a Exception as a string suitable for output.
virtual void dwnldProgressEnd(const zypp::Url &uri, long rate=-1, zypp::TriBool error=false)=0
Reports end of a download.
void xmlNode(const std::string &name_r, XmlNode::Attr attr_r)
virtual void infoLine(const TermLine &msg_r, Verbosity verbosity_r=NORMAL, Type mask_r=TYPE_ALL)
info taking a TermLine
virtual void progress(const std::string &id, const std::string &label, int value=-1)=0
Progress report for an on-going operation.
void par(size_t indent_r, const Text &text_r, ParFormat format_r=ParFormat())
Paragraph of text, optionally indented, or without leading gap.
TypeBit
Known output types implemented by derived classes.
@ TYPE_NORMAL
plain text output
void taggedPar(const TText &tag_r, const Text &text_r, ParFormat format_r=ParFormat())
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.
virtual void progressStart(const std::string &id, const std::string &label, bool is_tick=false)=0
Start of an operation with reported progress.
void errorPar(size_t indent_r, const Text &text_r, ParFormat format_r=ParFormat())
Paragraph tagged with 'Error: '.
virtual void dwnldProgressStart(const zypp::Url &uri)=0
Reoprt start of a download.
bool type(TypeBit type_r) const
Test for a specific type.
ZYPP_DECLARE_FLAGS(Type, TypeBit)
Example: PromptOptions popts; popts.setOptions(_("y/n/p"), 0 / * default reply * /); popts....
Table & setHeader(TableHeader tr)
Class representing an application (appdata.xml)
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
void swap(AutoDispose &rhs) noexcept
Exchange the contents of two AutoDispose objects.
void reset()
Reset to default Ctor values.
Integral type with defined initial value when default constructed.
Assign a vaiable a certain value when going out of scope.
Base class for Exception.
Maintain [min,max] and counter (value) for progress counting.
bool reportPercent() const
value_type reportValue() const
void sendTo(const ReceiverFnc &fnc_r)
Set ReceiverFnc.
void name(const std::string &name_r)
Set counter name.
void noSend()
Set no ReceiverFnc.
TableHeader asTableHeader< void >()
void xmlWriteContainer(std::ostream &str_r, const TContainer &container_r, const TFormater &formater_r)
Write XML formatted container to stream.
TableLayout DefaultTableLayout
Simple Table.
void writeContainer(std::ostream &str_r, const TContainer &container_r, const TFormater &formater_r, const TLayout &layout_r=TLayout())
Write formatted container to stream.
detail::ListLayoutInit< true, true, false, 0U > DefaultListLayout
one element per line, no indent
static constexpr unsigned termwidthUnlimited
detail::ListLayoutInit< true, false, false, 0U > XmlListLayout
std::string asListElement(const std::string &val_r)
unsigned defaultTermwidth()
std::string asXmlListElement(const std::string &val_r)
ColorString tagWarning()
translated "Warning:" warning color
ColorString tagNote()
translated "Note:" highlighted
const char * qContinue()
translated "Continue?"
bool endsOnWS(const std::string &str_r)
Whether the str_r ends with a WS.
ColorString tagError()
translated "Error:" error color
std::string join(const Tltext <ext, const Trtext &rtext, const char *sep=" ")
Simple join of two string types.
const char * optBlankAfter(const std::string &str_r)
std::ostream & printRichText(std::ostream &str, std::string text, unsigned indent_r=0U, unsigned width_r=0U)
Print [Rich]Text optionally indented.
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.
ProgressEnd
ProgressBars default end tags.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
std::string numstring(char n, int w=0)
const std::string & asString(const std::string &t)
Global asString() that works with std::string too.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
std::ostream & node(std::ostream &out_r, const std::string &name_r, Node::Attr attr_r)
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Convenience class Error reporting.
Error(int exitcode_r, const zypp::Exception &ex_r, std::string hint_r=std::string())
static std::string combine(std::string &&msg_r, const zypp::Exception &ex_r)
Error(int exitcode_r, std::string msg_r, std::string hint_r=std::string())
int report(Application &app_r) const
Default way of processing a caught Error exception.
Error(int exitcode_r, std::string msg_r, const zypp::Exception &ex_r, std::string hint_r=std::string())
std::unique_ptr< std::ostringstream > _str
Info(Out::Info &&rhs) noexcept
std::ostream & operator<<(const Tp &val)
Convenience base class storing the back reference to Out.
Indicator type for ctor not drawing an initial start bar.
ProgressData::ReceiverFnc printing to a ProgressBar.
Print(ProgressBar &bar_r)
bool operator()(const zypp::ProgressData &progress_r)
XmlNode with optional normal text headline (NL appended)
TitleNode(XmlNode &&node_r, const std::string &title_r="")
XML only: RAII writing a XML nodes start/end tag.
zypp::scoped_ptr< zypp::xmlout::Node > _node
XmlNode(XmlNode &&rhs) noexcept
Move ctor.
XmlNode(Out &out_r, const std::string &name_r, const std::initializer_list< Attr > &attrs_r={})
Ctor taking nodename and attribute list.
XmlNode(Out &out_r, const std::string &name_r, Attr attr_r)
Convenience ctor for one attribute pair.
TermLine(SplitFlags flags_r, char exp_r)
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...
TermLine(SplitFlags flags_r)
zypp::DefaultIntegral< char,' '> expHint
zypp::DefaultIntegral< int,-1 > percentHint
std::string get() const
Return plain line made of lhs + rhs.
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...
ZYPP_DECLARE_FLAGS(SplitFlags, SplitFlag)
std::string get(unsigned width_r) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Write out a List according to the layout.
void printAndCount(const std::string &element_r) const
const ListLayout & _layout
const unsigned _linewidth
desired line width
const std::string _indent
bool fitsOnLine(unsigned size_r) const
void operator<<(Tp &&val_r) const
Writer(std::ostream &str_r, const ListLayout &layout_r, const TFormater &formater_r)
const TFormater & _formater
bool _singleline
one list element per line
unsigned _indent
amount of indent
bool _gaped
add extra NL before element (if singleline)
bool _wrapline
fold lines longer than _linewidth
ListLayout(bool singleline_r, bool wrapline_r, bool gaped_r, unsigned indent_r)
Write out a Table according to the layout.
const TableLayout & _layout
void operator<<(Tp &&val_r) const
Writer(std::ostream &str_r, const TableLayout &layout_r, const TFormater &formater_r)
const TFormater & _formater
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
(Key, Value) string pair of XML node attributes
RAII writing a nodes start/end tag.
#define ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name)