libzypp  17.32.5
ztui::Table Class Reference

#include <zypp-tui/Table.h>

Public Types

using container = std::list< TableRow >
 

Public Member Functions

Tableadd (TableRow tr)
 
TablesetHeader (TableHeader tr)
 
std::ostream & dumpTo (std::ostream &stream) const
 
bool empty () const
 
unsigned defaultSortColumn () const
 Get the default sort column or Unsorted (default) More...
 
void defaultSortColumn (unsigned byColumn_r)
 Set a defaultSortColumn. More...
 
void sort ()
 Sort by defaultSortColumn. More...
 
void sort (unsigned byColumn_r)
 Sort by byColumn_r. More...
 
void sort (const std::list< unsigned > &byColumns_r)
 
void sort (std::list< unsigned > &&byColumns_r)
 
template<class TCompare , std::enable_if_t<!std::is_integral_v< TCompare >, int > = 0>
void sort (TCompare &&less_r)
 Custom sort. More...
 
void lineStyle (TableLineStyle st)
 
void wrap (int force_break_after=-1)
 
void allowAbbrev (unsigned column)
 
void margin (unsigned margin)
 
const TableHeaderheader () const
 
const containerrows () const
 
containerrows ()
 
 Table ()
 

Static Public Attributes

static TableLineStyle defaultStyle = Ascii
 
static constexpr unsigned Unsorted = unsigned(-1)
 Unsorted - pseudo sort column indicating not to sort. More...
 
static constexpr unsigned UserData = unsigned(-2)
 UserData - sort column using a custom sort index. More...
 

Private Member Functions

void dumpRule (std::ostream &stream) const
 
void updateColWidths (const TableRow &tr) const
 

Private Attributes

bool _has_header
 
TableHeader _header
 
container _rows
 
unsigned _max_col
 maximum column index seen in this table More...
 
std::vector< unsigned > _max_width
 maximum width of respective columns More...
 
int _width
 table width (columns) More...
 
TableLineStyle _style
 table line drawing style More...
 
int _screen_width
 amount of space we have to print this table More...
 
std::vector< bool_abbrev_col
 whether to abbreviate the respective column if needed More...
 
unsigned _margin
 left/right margin in number of spaces More...
 
int _force_break_after
 if _do_wrap is set, first break the table at this column; If negative, wrap as needed. More...
 
bool _do_wrap
 Whether to wrap the table if it exceeds _screen_width. More...
 
zypp::DefaultIntegral< unsigned, Unsorted_defaultSortColumn
 
bool _inHeader
 

Friends

class TableRow
 

Detailed Description

Todo:
nice idea but poor interface

Definition at line 398 of file Table.h.

Member Typedef Documentation

◆ container

using ztui::Table::container = std::list<TableRow>

Definition at line 401 of file Table.h.

Constructor & Destructor Documentation

◆ Table()

ztui::Table::Table ( )

Definition at line 316 of file Table.cc.

Member Function Documentation

◆ add()

Table & ztui::Table::add ( TableRow  tr)

Definition at line 329 of file Table.cc.

◆ setHeader()

Table & ztui::Table::setHeader ( TableHeader  tr)

Definition at line 335 of file Table.cc.

◆ dumpTo()

std::ostream & ztui::Table::dumpTo ( std::ostream &  stream) const
Todo:
allow abbrev of multiple columns?

Definition at line 403 of file Table.cc.

◆ empty()

bool ztui::Table::empty ( ) const
inline

Definition at line 411 of file Table.h.

◆ defaultSortColumn() [1/2]

unsigned ztui::Table::defaultSortColumn ( ) const
inline

Get the default sort column or Unsorted (default)

Definition at line 420 of file Table.h.

◆ defaultSortColumn() [2/2]

void ztui::Table::defaultSortColumn ( unsigned  byColumn_r)
inline

Set a defaultSortColumn.

Definition at line 423 of file Table.h.

◆ sort() [1/5]

void ztui::Table::sort ( )
inline

Sort by defaultSortColumn.

Definition at line 426 of file Table.h.

◆ sort() [2/5]

void ztui::Table::sort ( unsigned  byColumn_r)
inline

Sort by byColumn_r.

Definition at line 429 of file Table.h.

◆ sort() [3/5]

void ztui::Table::sort ( const std::list< unsigned > &  byColumns_r)
inline

Definition at line 430 of file Table.h.

◆ sort() [4/5]

void ztui::Table::sort ( std::list< unsigned > &&  byColumns_r)
inline

Definition at line 431 of file Table.h.

◆ sort() [5/5]

template<class TCompare , std::enable_if_t<!std::is_integral_v< TCompare >, int > = 0>
void ztui::Table::sort ( TCompare &&  less_r)
inline

Custom sort.

Definition at line 435 of file Table.h.

◆ lineStyle()

void ztui::Table::lineStyle ( TableLineStyle  st)

Definition at line 448 of file Table.cc.

◆ wrap()

void ztui::Table::wrap ( int  force_break_after = -1)

Definition at line 441 of file Table.cc.

◆ allowAbbrev()

void ztui::Table::allowAbbrev ( unsigned  column)

Definition at line 342 of file Table.cc.

◆ margin()

void ztui::Table::margin ( unsigned  margin)

Definition at line 454 of file Table.cc.

◆ header()

const TableHeader& ztui::Table::header ( ) const
inline

Definition at line 442 of file Table.h.

◆ rows() [1/2]

const container& ztui::Table::rows ( ) const
inline

Definition at line 444 of file Table.h.

◆ rows() [2/2]

container& ztui::Table::rows ( )
inline

Definition at line 446 of file Table.h.

◆ dumpRule()

void ztui::Table::dumpRule ( std::ostream &  stream) const
private

Definition at line 382 of file Table.cc.

◆ updateColWidths()

void ztui::Table::updateColWidths ( const TableRow tr) const
private

Definition at line 352 of file Table.cc.

Friends And Related Function Documentation

◆ TableRow

friend class TableRow
friend

Definition at line 483 of file Table.h.

Member Data Documentation

◆ defaultStyle

TableLineStyle ztui::Table::defaultStyle = Ascii
static

Definition at line 403 of file Table.h.

◆ Unsorted

constexpr unsigned ztui::Table::Unsorted = unsigned(-1)
static

Unsorted - pseudo sort column indicating not to sort.

Definition at line 415 of file Table.h.

◆ UserData

constexpr unsigned ztui::Table::UserData = unsigned(-2)
static

UserData - sort column using a custom sort index.

Definition at line 417 of file Table.h.

◆ _has_header

bool ztui::Table::_has_header
private

Definition at line 455 of file Table.h.

◆ _header

TableHeader ztui::Table::_header
private

Definition at line 456 of file Table.h.

◆ _rows

container ztui::Table::_rows
private

Definition at line 457 of file Table.h.

◆ _max_col

unsigned ztui::Table::_max_col
mutableprivate

maximum column index seen in this table

Definition at line 460 of file Table.h.

◆ _max_width

std::vector<unsigned> ztui::Table::_max_width
mutableprivate

maximum width of respective columns

Definition at line 462 of file Table.h.

◆ _width

int ztui::Table::_width
mutableprivate

table width (columns)

Definition at line 464 of file Table.h.

◆ _style

TableLineStyle ztui::Table::_style
private

table line drawing style

Definition at line 466 of file Table.h.

◆ _screen_width

int ztui::Table::_screen_width
private

amount of space we have to print this table

Definition at line 468 of file Table.h.

◆ _abbrev_col

std::vector<bool> ztui::Table::_abbrev_col
private

whether to abbreviate the respective column if needed

Definition at line 470 of file Table.h.

◆ _margin

unsigned ztui::Table::_margin
private

left/right margin in number of spaces

Definition at line 472 of file Table.h.

◆ _force_break_after

int ztui::Table::_force_break_after
private

if _do_wrap is set, first break the table at this column; If negative, wrap as needed.

Definition at line 475 of file Table.h.

◆ _do_wrap

bool ztui::Table::_do_wrap
private

Whether to wrap the table if it exceeds _screen_width.

Definition at line 477 of file Table.h.

◆ _defaultSortColumn

zypp::DefaultIntegral<unsigned,Unsorted> ztui::Table::_defaultSortColumn
private

Definition at line 479 of file Table.h.

◆ _inHeader

bool ztui::Table::_inHeader
mutableprivate

Definition at line 481 of file Table.h.


The documentation for this class was generated from the following files: