![]() |
Documentation 6b54b78464
|
Class for writing output in a table. More...
#include <printing_toolbox.hpp>
Public Types | |
| enum | alignment { CENTER , LEFT , RIGHT } |
Public Member Functions | |
| CTablePrinter (std::ostream *output, const std::string &separator="|") | |
| int | GetNumColumns () const |
| Get number of columns of the table. | |
| int | GetTableWidth () const |
| Get total width of the table. | |
| void | SetSeparator (const std::string &separator) |
| Set the separator between columns (outer decoration) | |
| void | SetInnerSeparator (const std::string &inner_separator) |
| Set the separator between columns (inner decoration) | |
| void | SetAlign (int align_) |
| Set the alignment of the table entries (CENTER only works for the header at the moment). | |
| void | SetPrintHeaderBottomLine (bool print) |
| Set whether to print the line at the bottom of the table. | |
| void | SetPrintHeaderTopLine (bool print) |
| Set whether to print the line at the top of the table. | |
| void | AddColumn (const std::string &header_name, int column_width) |
| Add a column to the table by specifiying the header name and the width. | |
| void | PrintHeader () |
| Print the header. | |
| void | PrintFooter () |
| Print the footer. | |
| void | SetPrecision (int precision) |
| Set the floating point precision. | |
| template<typename T > | |
| CTablePrinter & | operator<< (T input) |
Class for writing output in a table.
For example the output
+----------------------------------------—+ | MG Level| Presmooth|PostSmooth|CorrectSmo| +----------------------------------------—+ | 0| 1| 0| 0| | 1| 1| 0| 0| | 2| 1| 0| 0| | 3| 1| 0| 0| +----------------------------------------—+
can be generated with the code
CTablePrinter MGTable(&std::cout); MGTable.AddColumn("MG Level", 10); MGTable.AddColumn("Presmooth", 10); MGTable.AddColumn("PostSmooth", 10); MGTable.AddColumn("CorrectSmooth", 10); MGTable.PrintHeader(); for (unsigned short iLevel = 0; iLevel < nMGLevels+1; iLevel++) { MGTable << iLevel << MG_PreSmooth[iLevel] << MG_PostSmooth[iLevel] << MG_CorrecSmooth[iLevel]; } MGTable.PrintFooter();
| PrintingToolbox::CTablePrinter::CTablePrinter | ( | std::ostream * | output, |
| const std::string & | separator = "|" |
||
| ) |
| void PrintingToolbox::CTablePrinter::AddColumn | ( | const std::string & | header_name, |
| int | column_width | ||
| ) |
Add a column to the table by specifiying the header name and the width.
| [in] | header_name | - The name printed in the header. |
| [in] | column_width | - The width of the column. |
| int PrintingToolbox::CTablePrinter::GetNumColumns | ( | ) | const |
Get number of columns of the table.
| int PrintingToolbox::CTablePrinter::GetTableWidth | ( | ) | const |
Get total width of the table.
|
inline |
| void PrintingToolbox::CTablePrinter::PrintFooter | ( | ) |
Print the footer.
| void PrintingToolbox::CTablePrinter::PrintHeader | ( | ) |
Print the header.
| void PrintingToolbox::CTablePrinter::SetAlign | ( | int | align_ | ) |
Set the alignment of the table entries (CENTER only works for the header at the moment).
| [in] | align_ | - The alignment (CENTER, LEFT, RIGHT). |
| void PrintingToolbox::CTablePrinter::SetInnerSeparator | ( | const std::string & | inner_separator | ) |
Set the separator between columns (inner decoration)
| [in] | separator | - The separation character. |
| void PrintingToolbox::CTablePrinter::SetPrecision | ( | int | precision | ) |
Set the floating point precision.
| void PrintingToolbox::CTablePrinter::SetPrintHeaderBottomLine | ( | bool | ) |
Set whether to print the line at the bottom of the table.
| [in] | - If TRUE, the bottom line is printed. |
| void PrintingToolbox::CTablePrinter::SetPrintHeaderTopLine | ( | bool | ) |
Set whether to print the line at the top of the table.
| [in] | - If TRUE, the top line is printed. |
| void PrintingToolbox::CTablePrinter::SetSeparator | ( | const std::string & | separator | ) |
Set the separator between columns (outer decoration)
| [in] | separator | - The separation character. |