TSDuck v3.40-3963
MPEG Transport Stream Toolkit
|
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. | |
This class produces a report in a grid format with tables and sections.
ts::Grid::Grid | ( | std::ostream & | output | ) |
Constructor.
[in,out] | output | Reference to the output text device. |
|
inline |
Get a reference to the output stream.
void ts::Grid::setLineWidth | ( | size_t | lineWidth = DEFAULT_LINE_WIDTH , |
size_t | marginWidth = DEFAULT_MARGIN_WIDTH |
||
) |
Set the report display line width.
[in] | lineWidth | New line width. |
[in] | marginWidth | New margin width. |
|
inline |
Get the report display line width.
|
inline |
Get the report display margin width.
|
inline |
Get the number of displayed lines.
|
inline |
Check if a table is open.
Write a line with one field, truncated.
[in] | line | Line content. |
Write a text, wrap on multiple lines when necessary.
[in] | text | Text to display. |
Write a line with two fields, possibly on two lines.
[in] | left | Left-side content. |
[in] | right | Right-side content. |
[in] | oneLine | If true, force the packing on one line. If false, allow two lines, one for each text, in case of overflow. |
|
inline |
Build a ColumnLayout with one text field, left-justified.
[in] | width | Requested width in characters. |
[in] | pad | Padding character. |
|
inline |
Build a ColumnLayout with one text field, right-justified.
[in] | width | Requested width in characters. |
[in] | pad | Padding character. |
|
inline |
Build a ColumnLayout with two text field, left-justified and right-justified.
In case of overflow, both are truncated.
[in] | width | Requested width in characters. |
[in] | pad | Padding character. |
|
inline |
Build a ColumnLayout with two text field, left-justified and right-justified, truncate left one on overflow.
[in] | width | Requested width in characters. |
[in] | pad | Padding character. |
|
inline |
Build a ColumnLayout with two text field, left-justified and right-justified, truncate right one on overflow.
[in] | width | Requested width in characters. |
[in] | pad | Padding character. |
|
inline |
Build a ColumnLayout creating a vertical border between the two adjacent columns.
void ts::Grid::setLayout | ( | const std::initializer_list< ColumnLayout > | layout | ) |
Define the current column layout.
[in] | layout | List of columns layouts. Depending on the width of the grid, the layout may be rearranged. |
void ts::Grid::putLayout | ( | const std::initializer_list< ColumnText > | text | ) |
Write one line of text in the columns layout.
[in] | text | Content 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. |