Documentation 6b54b78464
Loading...
Searching...
No Matches
PrintingToolbox::CTablePrinter Class Reference

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)
 

Detailed Description

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();

Author
T. Albring

Member Enumeration Documentation

◆ alignment

Enumerator
CENTER 
LEFT 
RIGHT 

Constructor & Destructor Documentation

◆ CTablePrinter()

PrintingToolbox::CTablePrinter::CTablePrinter ( std::ostream *  output,
const std::string &  separator = "|" 
)

Member Function Documentation

◆ AddColumn()

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.

Parameters
[in]header_name- The name printed in the header.
[in]column_width- The width of the column.

◆ GetNumColumns()

int PrintingToolbox::CTablePrinter::GetNumColumns ( ) const

Get number of columns of the table.

Returns
Number of columns.

◆ GetTableWidth()

int PrintingToolbox::CTablePrinter::GetTableWidth ( ) const

Get total width of the table.

Returns
Total width of the table.

◆ operator<<()

template<typename T >
CTablePrinter & PrintingToolbox::CTablePrinter::operator<< ( T  input)
inline

◆ PrintFooter()

void PrintingToolbox::CTablePrinter::PrintFooter ( )

Print the footer.

◆ PrintHeader()

void PrintingToolbox::CTablePrinter::PrintHeader ( )

Print the header.

◆ SetAlign()

void PrintingToolbox::CTablePrinter::SetAlign ( int  align_)

Set the alignment of the table entries (CENTER only works for the header at the moment).

Parameters
[in]align_- The alignment (CENTER, LEFT, RIGHT).

◆ SetInnerSeparator()

void PrintingToolbox::CTablePrinter::SetInnerSeparator ( const std::string &  inner_separator)

Set the separator between columns (inner decoration)

Parameters
[in]separator- The separation character.

◆ SetPrecision()

void PrintingToolbox::CTablePrinter::SetPrecision ( int  precision)

Set the floating point precision.

◆ SetPrintHeaderBottomLine()

void PrintingToolbox::CTablePrinter::SetPrintHeaderBottomLine ( bool  print)

Set whether to print the line at the bottom of the table.

Parameters
[in]print- If TRUE, the bottom line is printed.

◆ SetPrintHeaderTopLine()

void PrintingToolbox::CTablePrinter::SetPrintHeaderTopLine ( bool  print)

Set whether to print the line at the top of the table.

Parameters
[in]print- If TRUE, the top line is printed.

◆ SetSeparator()

void PrintingToolbox::CTablePrinter::SetSeparator ( const std::string &  separator)

Set the separator between columns (outer decoration)

Parameters
[in]separator- The separation character.

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