libzypp 17.37.17
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)
void defaultSortColumn (unsigned byColumn_r)
 Set a defaultSortColumn.
void sort ()
 Sort by defaultSortColumn.
void sort (unsigned byColumn_r)
 Sort by byColumn_r.
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.
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.
static constexpr unsigned UserData = unsigned(-2)
 UserData - sort column using a custom sort index.

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
std::vector< unsigned > _max_width
 maximum width of respective columns
int _width
 table width (columns)
TableLineStyle _style
 table line drawing style
int _screen_width
 amount of space we have to print this table
std::vector< bool_abbrev_col
 whether to abbreviate the respective column if needed
unsigned _margin
 left/right margin in number of spaces
int _force_break_after
bool _do_wrap
 Whether to wrap the table if it exceeds _screen_width.
zypp::DefaultIntegral< unsigned, Unsorted_defaultSortColumn
bool _inHeader

Friends

class TableRow

Detailed Description

Todo
nice idea but poor interface

Definition at line 397 of file Table.h.

Member Typedef Documentation

◆ container

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

Definition at line 400 of file Table.h.

Constructor & Destructor Documentation

◆ Table()

ztui::Table::Table ( )

Definition at line 319 of file Table.cc.

Member Function Documentation

◆ add()

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

Definition at line 332 of file Table.cc.

◆ setHeader()

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

Definition at line 338 of file Table.cc.

◆ dumpTo()

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

Definition at line 406 of file Table.cc.

◆ empty()

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

Definition at line 410 of file Table.h.

◆ defaultSortColumn() [1/2]

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

Get the default sort column or Unsorted (default)

Definition at line 419 of file Table.h.

◆ defaultSortColumn() [2/2]

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

Set a defaultSortColumn.

Definition at line 422 of file Table.h.

◆ sort() [1/5]

void ztui::Table::sort ( )
inline

Sort by defaultSortColumn.

Definition at line 425 of file Table.h.

◆ sort() [2/5]

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

Sort by byColumn_r.

Definition at line 428 of file Table.h.

◆ sort() [3/5]

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

Definition at line 429 of file Table.h.

◆ sort() [4/5]

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

Definition at line 430 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 434 of file Table.h.

◆ lineStyle()

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

Definition at line 451 of file Table.cc.

◆ wrap()

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

Definition at line 444 of file Table.cc.

◆ allowAbbrev()

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

Definition at line 345 of file Table.cc.

◆ margin()

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

Definition at line 457 of file Table.cc.

◆ header()

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

Definition at line 441 of file Table.h.

◆ rows() [1/2]

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

Definition at line 443 of file Table.h.

◆ rows() [2/2]

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

Definition at line 445 of file Table.h.

◆ dumpRule()

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

Definition at line 385 of file Table.cc.

◆ updateColWidths()

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

Definition at line 355 of file Table.cc.

◆ TableRow

friend class TableRow
friend

Definition at line 482 of file Table.h.

Member Data Documentation

◆ defaultStyle

TableLineStyle ztui::Table::defaultStyle = Ascii
static

Definition at line 402 of file Table.h.

◆ Unsorted

unsigned ztui::Table::Unsorted = unsigned(-1)
staticconstexpr

Unsorted - pseudo sort column indicating not to sort.

Definition at line 414 of file Table.h.

◆ UserData

unsigned ztui::Table::UserData = unsigned(-2)
staticconstexpr

UserData - sort column using a custom sort index.

Definition at line 416 of file Table.h.

◆ _has_header

bool ztui::Table::_has_header
private

Definition at line 454 of file Table.h.

◆ _header

TableHeader ztui::Table::_header
private

Definition at line 455 of file Table.h.

◆ _rows

container ztui::Table::_rows
private

Definition at line 456 of file Table.h.

◆ _max_col

unsigned ztui::Table::_max_col
mutableprivate

maximum column index seen in this table

Definition at line 459 of file Table.h.

◆ _max_width

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

maximum width of respective columns

Definition at line 461 of file Table.h.

◆ _width

int ztui::Table::_width
mutableprivate

table width (columns)

Definition at line 463 of file Table.h.

◆ _style

TableLineStyle ztui::Table::_style
private

table line drawing style

Definition at line 465 of file Table.h.

◆ _screen_width

int ztui::Table::_screen_width
private

amount of space we have to print this table

Definition at line 467 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 469 of file Table.h.

◆ _margin

unsigned ztui::Table::_margin
private

left/right margin in number of spaces

Definition at line 471 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 474 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 476 of file Table.h.

◆ _defaultSortColumn

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

Definition at line 478 of file Table.h.

◆ _inHeader

bool ztui::Table::_inHeader
mutableprivate

Definition at line 480 of file Table.h.


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