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