|
BenBot 1.7.5
A chess engine
|
#include </home/runner/work/BenBot/BenBot/libutil/include/libutil/TextTable.hpp>
Public Types | |
| using | PrintFunc = std::function<void(string_view)> |
Public Member Functions | |
| auto | append_column (string_view text) -> TextTable & |
| auto | new_row () -> TextTable & |
| void | print (PrintFunc &&printHeading, PrintFunc &&printCell, PrintFunc &&printOutline, std::function< void()> printNewline) const |
| auto | to_string () const -> string |
This class allows you to construct a table of text with vertically aligned columns. Rows may have different numbers of columns; the table's size is based on the maximum number of columns. The first row is the header, and a separator row will be added between it and the second manually added row.
Definition at line 41 of file TextTable.hpp.
| using util::strings::TextTable::PrintFunc = std::function<void(string_view)> |
Typedef for a function that accepts a string as an argument.
Definition at line 54 of file TextTable.hpp.
| auto util::strings::TextTable::append_column | ( | string_view | text | ) | -> TextTable & |
Appends a column to the current row.
| auto util::strings::TextTable::new_row | ( | ) | -> TextTable & |
Ends the current row. Subsequent calls to append_column() will write to the new row.
| void util::strings::TextTable::print | ( | PrintFunc && | printHeading, |
| PrintFunc && | printCell, | ||
| PrintFunc && | printOutline, | ||
| std::function< void()> | printNewline ) const |
Prints the table by calling lambda functions for each different element of the table. This allows you to do things like print the table to a terminal using ANSI color codes; using just the to_string() API would make it much more difficult to intersperse the needed escape codes to switch between styles for the cell text and outlines, etc.
| printHeading | Function object that will be called to print the contents of each heading cell. Note that the strings sent to this function will include trailing whitespace, to create the table's alignment. |
| printCell | Function object that will be called to print the contents of each non-heading cell. Note that the strings sent to this function will include trailing whitespace, to create the table's alignment. |
| printOutline | Function object that will be called to print outline/border characters between cells and surrounding the entire table. |
| printNewline | Function object that accepts no arguments and should insert a single newline character into the text stream being constructed. |
|
nodiscard |
Concatenates all the rows in the table into a single string, with separators between rows and columns.