libzypp 17.32.5
Table.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 ZYPP_TUI_TABULE_H
15#define ZYPP_TUI_TABULE_H
16
17#include <iostream>
18#include <sstream>
19#include <string>
20#include <iosfwd>
21#include <set>
22#include <list>
23#include <vector>
24
25#include <boost/any.hpp>
26
27#include <zypp/base/String.h>
28#include <zypp/base/Exception.h>
30#include <zypp/sat/Solvable.h>
31#include <zypp/ui/Selectable.h>
32
33#include <zypp-tui/utils/ansi.h>
35
36namespace ztui {
37
38inline const char * asYesNo( bool val_r ) { return val_r ? _("Yes") : _("No"); }
39
41using SolvableCSI = std::pair<zypp::sat::Solvable, zypp::ui::Selectable::picklist_size_type>;
42
44// Custom sort index helpers
45namespace csidetail
46{
48 template <typename T>
49 inline int simpleAnyTypeComp ( const boost::any &l_r, const boost::any &r_r )
50 {
51 T l = boost::any_cast<T>(l_r);
52 T r = boost::any_cast<T>(r_r);
53 return ( l < r ? -1 : l > r ? 1 : 0 );
54 }
55
56 template <>
57 inline int simpleAnyTypeComp<SolvableCSI> ( const boost::any &l_r, const boost::any &r_r )
58 {
59 SolvableCSI l = boost::any_cast<SolvableCSI>(l_r);
60 SolvableCSI r = boost::any_cast<SolvableCSI>(r_r);
61
62 if ( l.first == r.first )
63 return 0; // quick check Solvable Id
64
65 int cmp = l.first.name().compare( r.first.name() );
66 if ( cmp )
67 return cmp;
68
69 cmp = l.first.kind().compare( r.first.kind() );
70 if ( cmp )
71 return cmp;
72
73 if ( l.second == r.second )
74 return 0;
75 return ( l.second < r.second ? -1 : 1 ); // `>`! best version up
76 }
77} // namespace csidetail
79
96
97class Table;
98
100// Conditional Table column helpers.
101namespace ctcdetail
102{
104 template<class Tif_,class Telse_>
105 struct ColumnIf
106 {
107 ColumnIf( bool condition_r, std::function<Tif_()> if_r, std::function<Telse_()> else_r )
108 { if ( condition_r ) _if = std::move(if_r); else _else = std::move(else_r); }
109 std::function<Tif_()> _if;
110 std::function<Telse_()> _else;
111 };
113 template<class Tif_>
115 {
116 ColumnIf( bool condition_r, std::function<Tif_()> if_r, std::function<Tif_()> else_r )
117 : _ifelse { condition_r ? std::move(if_r) : std::move(else_r) }
118 {}
119 ColumnIf( bool condition_r, std::function<Tif_()> && if_r )
120 { if ( condition_r ) _ifelse = std::move(if_r); }
121 std::function<Tif_()> _ifelse;
122 };
123}
141template<class Tif_, class Telse_>
142auto ColumnIf( bool condition_r, Tif_ && if_r, Telse_ && else_r ) -> ctcdetail::ColumnIf<decltype(if_r()),decltype(else_r())>
143{ return { condition_r, std::forward<Tif_>(if_r), std::forward<Telse_>(else_r) }; }
145template<class Tif_>
146auto ColumnIf( bool condition_r, Tif_ && if_r ) -> ctcdetail::ColumnIf<decltype(if_r()),decltype(if_r())>
147{ return { condition_r, std::forward<Tif_>(if_r) }; }
148
149
150namespace table
151{
158 enum class CStyle
159 {
160 Default = 0,
161 Edition,
162 SortCi,
163 };
164}
165
166
168{
169private:
170 std::ostream & dumpDetails( std::ostream & stream, const Table & parent ) const;
171
172public:
173 struct Less;
174
177 {}
178
179 explicit TableRow( unsigned c )
181 { _columns.reserve(c); }
182
184 : _ctxt( ctxt_r )
185 {}
186
188 : _ctxt( ctxt_r )
189 { _columns.reserve(c); }
190
191 TableRow & add( std::string s );
192
193 template<class Tp_>
194 TableRow & add( const Tp_ & val_r )
195 { return add( zypp::str::asString( val_r ) ); }
196
197
198 TableRow & addDetail( std::string s );
199
200 template<class Tp_>
202 { return addDetail( zypp::str::asString( val_r ) ); }
203
204
205 bool empty() const
206 { return _columns.empty(); }
207
208 // return number of columns
209 unsigned size() const
210 { return _columns.size(); }
211
212 unsigned cols() const
213 { return size(); }
214
216 std::ostream & dumbDumpTo( std::ostream & stream ) const;
218 std::ostream & dumpTo( std::ostream & stream, const Table & parent ) const;
219
220 using container = std::vector<std::string>;
221
222 const boost::any &userData() const
223 { return _userData; }
224
225 void userData( const boost::any &n_r )
226 { _userData = n_r; }
227
228 // BinaryPredicate
229
230 const container & columns() const
232
235
236 const container & columnsNoTr() const
237 { return _columns; }
238
240 { return _columns; }
241
242protected:
243 bool _translateColumns = false;
244private:
249 boost::any _userData;
250};
251
253template<class Tp_>
255{ return tr.add( zypp::asString( std::forward<Tp_>(val) ) ); }
257template<class Tp_>
259{ return std::move( tr << std::forward<Tp_>(val) ); }
260
262template<class Tif_, class Telse_> TableRow & operator<<( TableRow & tr, const ctcdetail::ColumnIf<Tif_,Telse_> & val )
263{ if ( val._if ) tr.add( val._if() ); else if ( val._else ) tr.add( val._else() ); return tr; }
265template<class Tif_, class Telse_> TableRow & operator<<( TableRow & tr, ctcdetail::ColumnIf<Tif_,Telse_> & val )
266{ if ( val._if ) tr.add( val._if() ); else if ( val._else ) tr.add( val._else() ); return tr; }
268template<class Tif_, class Telse_> TableRow & operator<<( TableRow & tr, ctcdetail::ColumnIf<Tif_,Telse_> && val )
269{ if ( val._if ) tr.add( val._if() ); else if ( val._else ) tr.add( val._else() ); return tr; }
270
272template<class Tif_> TableRow & operator<<( TableRow & tr, const ctcdetail::ColumnIf<Tif_,Tif_> & val )
273{ if ( val._ifelse ) tr.add( val._ifelse() ); return tr; }
276{ if ( val._ifelse ) tr.add( val._ifelse() ); return tr; }
279{ if ( val._ifelse ) tr.add( val._ifelse() ); return tr; }
280
281
282class TableHeader : public TableRow
283{
284public:
287 TableHeader (unsigned c = 0): TableRow (c) { _translateColumns = true; }
288
289 bool hasStyle( unsigned c, CStyle s ) const
290 { return _cstyle.count(c) && _cstyle.at(c) == s; }
291
292 CStyle style( unsigned c ) const
293 { return _cstyle.count(c) ? _cstyle.at(c) : CStyle::Default; }
294
295 void style( unsigned c, CStyle s )
296 { _cstyle[c] = s; }
297
298
299 std::set<unsigned> editionColumns() const
300 {
301 std::set<unsigned> ret;
302 for ( const auto & [c,s] : _cstyle ) {
303 if ( s == CStyle::Edition )
304 ret.insert( c );
305 }
306 return ret;
307 }
308
309private:
310 std::map<unsigned,CStyle> _cstyle;
311};
312
314template<class Tp_>
316{ static_cast<TableRow&>(th) << std::forward<Tp_>(val); return th; }
318template<class Tp_>
320{ return std::move( th << std::forward<Tp_>(val) ); }
321
322
324{
325 using SortParam = std::tuple<unsigned,bool>;
326
327 Less( const TableHeader & header_r, const std::list<unsigned>& by_columns_r )
328 {
329 for ( unsigned curr_column : by_columns_r ) {
331 }
332 }
333
334 bool operator()( const TableRow & a_r, const TableRow & b_r ) const
335 {
336 int c = 0;
337 for ( const SortParam &sortParam : _by_columns ) {
338 if ( (c = compCol( sortParam, a_r, b_r )) )
339 return c < 0;
340 }
341 return false;
342 }
343
344private:
345 int compCol( const SortParam & sortParam_r, const TableRow & a_r, const TableRow & b_r ) const
346 {
347 const auto & [ byColumn, sortCI ] { sortParam_r };
348 bool noL = byColumn >= a_r._columns.size();
349 bool noR = byColumn >= b_r._columns.size();
350
351 if ( noL || noR ) {
352 if ( noL && noR ) {
354
355 const boost::any &lUserData = a_r.userData();
356 const boost::any &rUserData = b_r.userData();
357
358 if ( lUserData.empty() && !rUserData.empty() )
359 return -1;
360
361 else if ( !lUserData.empty() && rUserData.empty() )
362 return 1;
363
364 else if ( lUserData.empty() && rUserData.empty() )
365 return 0;
366
367 else if ( lUserData.type() != rUserData.type() ) {
368 ZYPP_THROW( zypp::Exception( zypp::str::form("Incompatible user types") ) );
369
370 } else if ( lUserData.type() == typeid(SolvableCSI) ) {
372
373 } else if ( lUserData.type() == typeid(std::string) ) {
375
376 } else if ( lUserData.type() == typeid(unsigned) ) {
378
379 } else if ( lUserData.type() == typeid(int) ) {
381
382 }
383 ZYPP_THROW( zypp::Exception( zypp::str::form("Unsupported user types") ) );
384 } else
385 return ( noL && ! noR ? -1 : ! noL && noR ? 1 : 0);
386 }
387 return defaultStrComp( sortCI, a_r._columns[byColumn], b_r._columns[byColumn] );
388 }
389
391 static int defaultStrComp( bool ci_r, const std::string & lhs, const std::string & rhs );
392
393private:
394 std::list<SortParam> _by_columns;
395};
396
398class Table
399{
400public:
401 using container = std::list<TableRow>;
402
404
405 Table & add( TableRow tr );
406
408
409
410 std::ostream & dumpTo( std::ostream & stream ) const;
411 bool empty() const { return _rows.empty(); }
412
413
415 static constexpr unsigned Unsorted = unsigned(-1);
417 static constexpr unsigned UserData = unsigned(-2);
418
420 unsigned defaultSortColumn() const { return _defaultSortColumn; }
421
424
426 void sort() { sort( unsigned(_defaultSortColumn ) ); }
427
429 void sort( unsigned byColumn_r ) { if ( byColumn_r != Unsorted ) _rows.sort( TableRow::Less( header(), { byColumn_r } ) ); }
430 void sort( const std::list<unsigned> & byColumns_r ) { if ( byColumns_r.size() ) _rows.sort( TableRow::Less( header(), byColumns_r ) ); }
431 void sort( std::list<unsigned> && byColumns_r ) { if ( byColumns_r.size() ) _rows.sort( TableRow::Less( header(), std::move(byColumns_r) ) ); }
432
434 template<class TCompare, std::enable_if_t<!std::is_integral_v<TCompare>, int> = 0>
435 void sort( TCompare && less_r ) { _rows.sort( std::forward<TCompare>(less_r) ); }
436
438 void wrap( int force_break_after = -1 );
439 void allowAbbrev( unsigned column );
440 void margin( unsigned margin );
441
442 const TableHeader & header() const
443 { return _header; }
444 const container & rows() const
445 { return _rows; }
447 { return _rows; }
448
449 Table();
450
451private:
452 void dumpRule( std::ostream & stream ) const;
453 void updateColWidths( const TableRow & tr ) const;
454
458
460 mutable unsigned _max_col;
462 mutable std::vector<unsigned> _max_width;
464 mutable int _width;
470 std::vector<bool> _abbrev_col;
472 unsigned _margin;
478
480
481 mutable bool _inHeader;
482
483 friend class TableRow;
484};
485
486namespace table
487{
494 struct Column
495 {
497 : _header( std::move(header_r) )
498 , _style( style_r )
499 {}
500 std::string _header;
502 };
505 { th.style( th.cols(), obj._style ); return th << std::move(obj._header); }
508 { return std::move( th << std::move(obj) ); }
509}
510
511
512inline Table & operator<<( Table & table, TableRow tr )
513{ return table.add( std::move(tr) ); }
514
515inline Table & operator<<( Table & table, TableHeader tr )
516{ return table.setHeader( std::move(tr) ); }
517
518
519inline std::ostream & operator<<( std::ostream & stream, const Table & table )
520{ return table.dumpTo( stream ); }
521
522
535{
536public:
539
540 static const char * emptyListTag() { return "---"; }
541
542public:
544 // Key / Value
545 template <class KeyType>
546 PropertyTable & add( const KeyType & key_r )
547 { _table << ( TableRow() << key_r << "" ); return *this; }
548
549 template <class KeyType, class ValueType>
550 PropertyTable & add( const KeyType & key_r, const ValueType & val_r )
551 { _table << ( TableRow() << key_r << val_r ); return *this; }
552
553 template <class KeyType>
554 PropertyTable & add( const KeyType & key_r, bool val_r )
555 { _table << ( TableRow() << key_r << asYesNo( val_r ) ); return *this; }
556
558 // Key / Value in details (e.g. Description:)
559 template <class ValueType>
560 PropertyTable & addDetail( const ValueType & val_r )
561 { last().addDetail( val_r ); return *this; }
562
563 template <class KeyType, class ValueType>
564 PropertyTable & addDetail( const KeyType & key_r, const ValueType & val_r )
565 { _table << ( TableRow() << key_r << "" ).addDetail( val_r ); return *this; }
566
568 // Key / Container<Value>
569 template <class KeyType, class Iterator_ >
571 {
572 TableRow r;
573 r << key_r;
574 if ( begin_r != end_r )
575 {
576 unsigned cnt = 1;
577 Iterator_ first = begin_r++;
578 if ( begin_r == end_r && ! forceDetails_r )
579 r << *first; // only one value
580 else
581 {
582 r.addDetail( *first ); // list all in details
583 while ( begin_r != end_r )
584 {
585 ++cnt;
586 r.addDetail( *(begin_r++) );
587 }
588 r << "["+zypp::str::numstring(cnt)+"]"; // size as value
589 }
590 }
591 else
592 { r << emptyListTag(); } // dummy to get the ":" if empty
593 _table << r;
594 return *this;
595 }
596
597 template <class KeyType, class ContainerType>
598 PropertyTable & lst( const KeyType & key_r, const ContainerType & lst_r, bool forceDetails_r = false )
599 { return add( key_r, lst_r.begin(), lst_r.end(), forceDetails_r ); }
600
601 template <class KeyType, class ValueType>
602 PropertyTable & add( const KeyType & key_r, const std::set<ValueType> & lst_r, bool forceDetails_r = false )
603 { return lst( key_r, lst_r, forceDetails_r ); }
604 template <class KeyType, class ValueType>
605 PropertyTable & add( const KeyType & key_r, const std::list<ValueType> & lst_r, bool forceDetails_r = false )
606 { return lst( key_r, lst_r, forceDetails_r ); }
607 template <class KeyType, class ValueType>
608 PropertyTable & add( const KeyType & key_r, const std::vector<ValueType> & lst_r, bool forceDetails_r = false )
609 { return lst( key_r, lst_r, forceDetails_r ); }
610
612 // misc
614 {
615 if ( cond_r )
616 {
617 // FIXME re-coloring like this works only once
618 std::string & lastval( _table.rows().back().columns().back() );
620 }
621 return *this;
622 }
623
625 { return _table.rows().back(); }
626
627 std::string & lastKey()
628 { return last().columns()[0]; }
629
630 std::string & lastValue()
631 { return last().columns()[1]; }
632
633public:
634 friend std::ostream & operator << ( std::ostream & str, const PropertyTable & obj )
635 { return str << obj._table; }
636
637private:
639};
640
641}
642
643// Local Variables:
644// c-basic-offset: 2
645// End:
646#endif
Aligned key/value with multiline support Key : value 1 LongKey : value 2 Multiline : line 1 line 2 Ne...
Definition Table.h:535
PropertyTable & add(const KeyType &key_r, const std::set< ValueType > &lst_r, bool forceDetails_r=false)
Definition Table.h:602
std::string & lastValue()
Definition Table.h:630
TableRow & last()
Definition Table.h:624
std::string & lastKey()
Definition Table.h:627
PropertyTable & add(const KeyType &key_r, const ValueType &val_r)
Definition Table.h:550
PropertyTable & add(const KeyType &key_r, const std::vector< ValueType > &lst_r, bool forceDetails_r=false)
Definition Table.h:608
PropertyTable & addDetail(const KeyType &key_r, const ValueType &val_r)
Definition Table.h:564
PropertyTable & add(const KeyType &key_r, Iterator_ begin_r, Iterator_ end_r, bool forceDetails_r=false)
Definition Table.h:570
PropertyTable & lst(const KeyType &key_r, const ContainerType &lst_r, bool forceDetails_r=false)
Definition Table.h:598
PropertyTable & addDetail(const ValueType &val_r)
Definition Table.h:560
static const char * emptyListTag()
Definition Table.h:540
friend std::ostream & operator<<(std::ostream &str, const PropertyTable &obj)
Definition Table.h:634
PropertyTable & add(const KeyType &key_r)
Definition Table.h:546
PropertyTable & add(const KeyType &key_r, bool val_r)
Definition Table.h:554
PropertyTable & paint(ansi::Color color_r, bool cond_r=true)
Definition Table.h:613
PropertyTable & add(const KeyType &key_r, const std::list< ValueType > &lst_r, bool forceDetails_r=false)
Definition Table.h:605
TableHeader(unsigned c=0)
Constructor. Reserve place for c columns.
Definition Table.h:287
std::map< unsigned, CStyle > _cstyle
Column style and sort hints are remembered here.
Definition Table.h:310
std::set< unsigned > editionColumns() const
Definition Table.h:299
bool hasStyle(unsigned c, CStyle s) const
Definition Table.h:289
void style(unsigned c, CStyle s)
Definition Table.h:295
TableHeader & operator<<(TableHeader &th, Tp_ &&val)
Add column.
Definition Table.h:315
CStyle style(unsigned c) const
Definition Table.h:292
TableRow & add(const Tp_ &val_r)
Definition Table.h:194
bool empty() const
Definition Table.h:205
TableRow(ColorContext ctxt_r)
Definition Table.h:183
container _columns
Definition Table.h:245
TableRow & add(std::string s)
Definition Table.cc:163
container & columnsNoTr()
Definition Table.h:239
ColorContext _ctxt
Definition Table.h:248
container _translatedColumns
Definition Table.h:246
unsigned cols() const
Definition Table.h:212
std::vector< std::string > container
Definition Table.h:220
container & columns()
Definition Table.h:233
std::ostream & dumpDetails(std::ostream &stream, const Table &parent) const
Definition Table.cc:192
TableRow & addDetail(std::string s)
Definition Table.cc:171
const container & columnsNoTr() const
Definition Table.h:236
TableRow(unsigned c)
Definition Table.h:179
TableRow & addDetail(const Tp_ &val_r)
Definition Table.h:201
boost::any _userData
user defined sort index, e.g. if string values don't work due to coloring
Definition Table.h:249
TableRow(unsigned c, ColorContext ctxt_r)
Definition Table.h:187
TableRow & operator<<(TableRow &tr, Tp_ &&val)
Add colummn.
Definition Table.h:254
container _details
Definition Table.h:247
bool _translateColumns
Definition Table.h:243
std::ostream & dumpTo(std::ostream &stream, const Table &parent) const
output with parent table attributes
Definition Table.cc:203
std::ostream & dumbDumpTo(std::ostream &stream) const
tab separated output
Definition Table.cc:178
unsigned size() const
Definition Table.h:209
void userData(const boost::any &n_r)
Definition Table.h:225
const boost::any & userData() const
Definition Table.h:222
TableRow()
Binary predicate for sorting.
Definition Table.h:175
const container & columns() const
Definition Table.h:230
void sort(std::list< unsigned > &&byColumns_r)
Definition Table.h:431
void dumpRule(std::ostream &stream) const
Definition Table.cc:382
bool empty() const
Definition Table.h:411
Table & setHeader(TableHeader tr)
Definition Table.cc:335
void updateColWidths(const TableRow &tr) const
Definition Table.cc:352
void sort(TCompare &&less_r)
Custom sort.
Definition Table.h:435
bool _has_header
Definition Table.h:455
std::list< TableRow > container
Definition Table.h:401
const container & rows() const
Definition Table.h:444
std::ostream & dumpTo(std::ostream &stream) const
Definition Table.cc:403
int _width
table width (columns)
Definition Table.h:464
void lineStyle(TableLineStyle st)
Definition Table.cc:448
void wrap(int force_break_after=-1)
Definition Table.cc:441
const TableHeader & header() const
Definition Table.h:442
unsigned defaultSortColumn() const
Get the default sort column or Unsorted (default)
Definition Table.h:420
std::vector< bool > _abbrev_col
whether to abbreviate the respective column if needed
Definition Table.h:470
std::vector< unsigned > _max_width
maximum width of respective columns
Definition Table.h:462
void sort(const std::list< unsigned > &byColumns_r)
Definition Table.h:430
TableLineStyle _style
table line drawing style
Definition Table.h:466
Table & add(TableRow tr)
Definition Table.cc:329
void margin(unsigned margin)
Definition Table.cc:454
TableHeader _header
Definition Table.h:456
static constexpr unsigned Unsorted
Unsorted - pseudo sort column indicating not to sort.
Definition Table.h:415
void defaultSortColumn(unsigned byColumn_r)
Set a defaultSortColumn.
Definition Table.h:423
void sort(unsigned byColumn_r)
Sort by byColumn_r.
Definition Table.h:429
bool _inHeader
Definition Table.h:481
int _screen_width
amount of space we have to print this table
Definition Table.h:468
unsigned _max_col
maximum column index seen in this table
Definition Table.h:460
container & rows()
Definition Table.h:446
int _force_break_after
if _do_wrap is set, first break the table at this column; If negative, wrap as needed.
Definition Table.h:475
static constexpr unsigned UserData
UserData - sort column using a custom sort index.
Definition Table.h:417
zypp::DefaultIntegral< unsigned, Unsorted > _defaultSortColumn
Definition Table.h:479
unsigned _margin
left/right margin in number of spaces
Definition Table.h:472
bool _do_wrap
Whether to wrap the table if it exceeds _screen_width.
Definition Table.h:477
void allowAbbrev(unsigned column)
Definition Table.cc:342
static TableLineStyle defaultStyle
Definition Table.h:403
container _rows
Definition Table.h:457
void sort()
Sort by defaultSortColumn.
Definition Table.h:426
Colored string if do_colors.
Definition ansi.h:497
std::string str() const
Return the colored string if do_colors.
Definition ansi.h:598
Various ways to define ansi SGR sequences.
Definition ansi.h:173
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
Base class for Exception.
Definition Exception.h:147
Definition Arch.h:364
String related utilities and Regular expression matching.
int simpleAnyTypeComp< SolvableCSI >(const boost::any &l_r, const boost::any &r_r)
Definition Table.h:57
int simpleAnyTypeComp(const boost::any &l_r, const boost::any &r_r)
Default comparator for custom sort indices (std::compare semantic).
Definition Table.h:49
CStyle
Table column styles.
Definition Table.h:159
@ Edition
Editions with v-r setparator highlighted.
@ SortCi
String values to be sorted case insensitive.
const char * asYesNo(bool val_r)
Definition Table.h:38
auto ColumnIf(bool condition_r, Tif_ &&if_r, Telse_ &&else_r) -> ctcdetail::ColumnIf< decltype(if_r()), decltype(else_r())>
Conditional Table column factory.
Definition Table.h:142
TableLineStyle
table drawing style
Definition Table.h:81
@ LightDouble
Definition Table.h:89
@ none
Definition Table.h:93
@ Light
Definition Table.h:83
@ DoubleLight
Definition Table.h:91
@ Ascii
| - +
Definition Table.h:82
@ Heavy3
Definition Table.h:87
@ Light3
Definition Table.h:86
@ Heavy
Definition Table.h:84
@ Double
Definition Table.h:85
@ HeavyLight
Definition Table.h:90
@ LightHeavy
Definition Table.h:88
@ TLS_End
sentinel
Definition Table.h:94
@ Colon
Definition Table.h:92
std::pair< zypp::sat::Solvable, zypp::ui::Selectable::picklist_size_type > SolvableCSI
Custom sort index type for table rows representing solvables (like detailed search results).
Definition Table.h:41
ColorContext
Definition colors.h:35
std::string numstring(char n, int w=0)
Definition String.h:289
const std::string & asString(const std::string &t)
Global asString() that works with std::string too.
Definition String.h:139
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:37
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
std::list< SortParam > _by_columns
Definition Table.h:394
std::tuple< unsigned, bool > SortParam
column and sortCI
Definition Table.h:325
int compCol(const SortParam &sortParam_r, const TableRow &a_r, const TableRow &b_r) const
Definition Table.h:345
static int defaultStrComp(bool ci_r, const std::string &lhs, const std::string &rhs)
Natural('sort -V' like) [case insensitive] compare ignoring ANSI SGR chars.
Definition Table.cc:113
bool operator()(const TableRow &a_r, const TableRow &b_r) const
Definition Table.h:334
Less(const TableHeader &header_r, const std::list< unsigned > &by_columns_r)
Definition Table.h:327
ColumnIf(bool condition_r, std::function< Tif_()> if_r, std::function< Tif_()> else_r)
Definition Table.h:116
ColumnIf(bool condition_r, std::function< Tif_()> &&if_r)
Definition Table.h:119
std::function< Tif_()> _ifelse
Definition Table.h:121
Remember either _if or _else function.
Definition Table.h:106
ColumnIf(bool condition_r, std::function< Tif_()> if_r, std::function< Telse_()> else_r)
Definition Table.h:107
std::function< Telse_()> _else
Definition Table.h:110
std::function< Tif_()> _if
Definition Table.h:109
Table column style setter.
Definition Table.h:495
TableHeader & operator<<(TableHeader &th, Column &&obj)
set TableHeader style.
Definition Table.h:504
Column(std::string header_r, CStyle style_r=CStyle::Default)
Definition Table.h:496
TableHeader && operator<<(TableHeader &&th, Column &&obj)
set TableHeader style.
Definition Table.h:507
std::string _header
Definition Table.h:500
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:429
#define _(MSG)
Definition Gettext.h:37