TSDuck v3.38-3710
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::Grid Class Reference

This class produces a report in a grid format with tables and sections. More...

#include <tsGrid.h>

Classes

class  ColumnLayout
 Define the layout of one column. More...
 
class  ColumnText
 The type is used to pass text to putLayout(). More...
 

Public Member Functions

 Grid (std::ostream &output)
 Constructor.
 
 ~Grid ()
 Destructor.
 
ColumnLayout border () const
 Build a ColumnLayout creating a vertical border between the two adjacent columns.
 
ColumnLayout both (size_t width=0, UChar pad=SPACE) const
 Build a ColumnLayout with two text field, left-justified and right-justified.
 
ColumnLayout bothTruncateLeft (size_t width=0, UChar pad=SPACE) const
 Build a ColumnLayout with two text field, left-justified and right-justified, truncate left one on overflow.
 
ColumnLayout bothTruncateRight (size_t width=0, UChar pad=SPACE) const
 Build a ColumnLayout with two text field, left-justified and right-justified, truncate right one on overflow.
 
void closeTable ()
 Close a table, if not already done.
 
ColumnLayout left (size_t width=0, UChar pad=SPACE) const
 Build a ColumnLayout with one text field, left-justified.
 
size_t lineCount () const
 Get the number of displayed lines.
 
size_t lineWidth () const
 Get the report display line width.
 
size_t marginWidth () const
 Get the report display margin width.
 
void openTable ()
 Open a table, if not already done.
 
void putLayout (const std::initializer_list< ColumnText > text)
 Write one line of text in the columns layout.
 
void putLine (const UString &left, const UString &right, bool oneLine=true)
 Write a line with two fields, possibly on two lines.
 
void putLine (const UString &line=UString())
 Write a line with one field, truncated.
 
void putMultiLine (const UString &text=UString())
 Write a text, wrap on multiple lines when necessary.
 
ColumnLayout right (size_t width=0, UChar pad=SPACE) const
 Build a ColumnLayout with one text field, right-justified.
 
void section ()
 Draw section delimiter.
 
void setLayout (const std::initializer_list< ColumnLayout > layout)
 Define the current column layout.
 
void setLineWidth (size_t lineWidth=DEFAULT_LINE_WIDTH, size_t marginWidth=DEFAULT_MARGIN_WIDTH)
 Set the report display line width.
 
std::ostream & stream () const
 Get a reference to the output stream.
 
void subSection ()
 Draw sub-section delimiter.
 
bool tableIsOpen () const
 Check if a table is open.
 

Static Public Attributes

static constexpr size_t DEFAULT_LINE_WIDTH = 80
 Default report line width.
 
static constexpr size_t DEFAULT_MARGIN_WIDTH = 2
 Default margin width.
 

Detailed Description

This class produces a report in a grid format with tables and sections.

Constructor & Destructor Documentation

◆ Grid()

ts::Grid::Grid ( std::ostream &  output)

Constructor.

Parameters
[in,out]outputReference to the output text device.

Member Function Documentation

◆ stream()

std::ostream & ts::Grid::stream ( ) const
inline

Get a reference to the output stream.

Returns
A reference to the output stream.

◆ setLineWidth()

void ts::Grid::setLineWidth ( size_t  lineWidth = DEFAULT_LINE_WIDTH,
size_t  marginWidth = DEFAULT_MARGIN_WIDTH 
)

Set the report display line width.

Parameters
[in]lineWidthNew line width.
[in]marginWidthNew margin width.

◆ lineWidth()

size_t ts::Grid::lineWidth ( ) const
inline

Get the report display line width.

Returns
The line width.

◆ marginWidth()

size_t ts::Grid::marginWidth ( ) const
inline

Get the report display margin width.

Returns
The margin width.

◆ lineCount()

size_t ts::Grid::lineCount ( ) const
inline

Get the number of displayed lines.

Returns
The number of displayed lines.

◆ tableIsOpen()

bool ts::Grid::tableIsOpen ( ) const
inline

Check if a table is open.

Returns
True if a table is open.

◆ putLine() [1/2]

void ts::Grid::putLine ( const UString line = UString())

Write a line with one field, truncated.

Parameters
[in]lineLine content.

◆ putMultiLine()

void ts::Grid::putMultiLine ( const UString text = UString())

Write a text, wrap on multiple lines when necessary.

Parameters
[in]textText to display.

◆ putLine() [2/2]

void ts::Grid::putLine ( const UString left,
const UString right,
bool  oneLine = true 
)

Write a line with two fields, possibly on two lines.

Parameters
[in]leftLeft-side content.
[in]rightRight-side content.
[in]oneLineIf true, force the packing on one line. If false, allow two lines, one for each text, in case of overflow.

◆ left()

ColumnLayout ts::Grid::left ( size_t  width = 0,
UChar  pad = SPACE 
) const
inline

Build a ColumnLayout with one text field, left-justified.

Parameters
[in]widthRequested width in characters.
[in]padPadding character.
Returns
The corresponding ColumnLayout.

◆ right()

ColumnLayout ts::Grid::right ( size_t  width = 0,
UChar  pad = SPACE 
) const
inline

Build a ColumnLayout with one text field, right-justified.

Parameters
[in]widthRequested width in characters.
[in]padPadding character.
Returns
The corresponding ColumnLayout.

◆ both()

ColumnLayout ts::Grid::both ( size_t  width = 0,
UChar  pad = SPACE 
) const
inline

Build a ColumnLayout with two text field, left-justified and right-justified.

In case of overflow, both are truncated.

Parameters
[in]widthRequested width in characters.
[in]padPadding character.
Returns
The corresponding ColumnLayout.

◆ bothTruncateLeft()

ColumnLayout ts::Grid::bothTruncateLeft ( size_t  width = 0,
UChar  pad = SPACE 
) const
inline

Build a ColumnLayout with two text field, left-justified and right-justified, truncate left one on overflow.

Parameters
[in]widthRequested width in characters.
[in]padPadding character.
Returns
The corresponding ColumnLayout.

◆ bothTruncateRight()

ColumnLayout ts::Grid::bothTruncateRight ( size_t  width = 0,
UChar  pad = SPACE 
) const
inline

Build a ColumnLayout with two text field, left-justified and right-justified, truncate right one on overflow.

Parameters
[in]widthRequested width in characters.
[in]padPadding character.
Returns
The corresponding ColumnLayout.

◆ border()

ColumnLayout ts::Grid::border ( ) const
inline

Build a ColumnLayout creating a vertical border between the two adjacent columns.

Returns
The corresponding ColumnLayout.

◆ setLayout()

void ts::Grid::setLayout ( const std::initializer_list< ColumnLayout layout)

Define the current column layout.

Parameters
[in]layoutList of columns layouts. Depending on the width of the grid, the layout may be rearranged.

◆ putLayout()

void ts::Grid::putLayout ( const std::initializer_list< ColumnText text)

Write one line of text in the columns layout.

Parameters
[in]textContent of the columns. There should be no element for Border() columns. For Left() and Right() column, only one text shall be set. For Both() layout, the two texts shall be set.

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