Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
Teuchos::TableFormat Class Reference

Encapsulation of formatting specifications for writing data in a clean tabular form. More...

#include <Teuchos_TableFormat.hpp>

Public Member Functions

 TableFormat ()
 Construct with a header and default format settings. More...
 
int pageWidth () const
 Get the maximum number of characters per line. Default is 80. More...
 
int precision () const
 Get the precision for writing doubles. Default is 4. More...
 
int columnSpacing () const
 Get the number of characters to be left as blank spaces in each column. Default is 4. More...
 
void setPageWidth (int pw) const
 Set the number of characters on a line. This quantity can be updated within the const method writeWholeTables() More...
 
void setPrecision (int p)
 Set the precision for writing doubles. More...
 
void setColumnSpacing (int columnSpacing_in)
 Set the number of characters to be left as blank spaces in each column. More...
 
void setRowsBetweenLines (int lineInterval)
 Set the interval at which a horizontal line will be written between rows. More...
 
std::string thinline () const
 Return a horizontal line in dashes "----" the width of the page. More...
 
std::string thickline () const
 Return a thick horizontal line in equal signs "====" the width of the page. More...
 
std::string blanks (int size) const
 Return a std::string full of blanks up to the requested size. More...
 
int computeRequiredColumnWidth (const std::string &name, const TableColumn &column) const
 Computes the column width required to write all values to the required precision. More...
 
void setColumnWidths (const Array< int > &colWidths)
 Set the column widths to be used for subsequent rows. More...
 
void writeRow (std::ostream &out, const Array< RCP< TableEntry > > &entries) const
 Write the row of entries. More...
 
void writeRow (std::ostream &out, int rowIndex, const Array< TableColumn > &columns) const
 Write the row of entries. More...
 
void writeWholeTable (std::ostream &out, const std::string &tableTitle, const Array< std::string > &columnNames, const Array< TableColumn > &columns) const
 

Detailed Description

Encapsulation of formatting specifications for writing data in a clean tabular form.

Note: it is left to the programmer to avoid invalid settings such as negative column spaces, zero page widths, and other such potentially bad things.

KL 30 Apr 2006 – initial design.

Definition at line 65 of file Teuchos_TableFormat.hpp.

Constructor & Destructor Documentation

Teuchos::TableFormat::TableFormat ( )
inline

Construct with a header and default format settings.

Definition at line 69 of file Teuchos_TableFormat.hpp.

Member Function Documentation

int Teuchos::TableFormat::pageWidth ( ) const
inline

Get the maximum number of characters per line. Default is 80.

Definition at line 79 of file Teuchos_TableFormat.hpp.

int Teuchos::TableFormat::precision ( ) const
inline

Get the precision for writing doubles. Default is 4.

Definition at line 83 of file Teuchos_TableFormat.hpp.

int Teuchos::TableFormat::columnSpacing ( ) const
inline

Get the number of characters to be left as blank spaces in each column. Default is 4.

Definition at line 87 of file Teuchos_TableFormat.hpp.

void Teuchos::TableFormat::setPageWidth ( int  pw) const
inline

Set the number of characters on a line. This quantity can be updated within the const method writeWholeTables()

Definition at line 92 of file Teuchos_TableFormat.hpp.

void Teuchos::TableFormat::setPrecision ( int  p)
inline

Set the precision for writing doubles.

Definition at line 95 of file Teuchos_TableFormat.hpp.

void Teuchos::TableFormat::setColumnSpacing ( int  columnSpacing_in)
inline

Set the number of characters to be left as blank spaces in each column.

Definition at line 98 of file Teuchos_TableFormat.hpp.

void Teuchos::TableFormat::setRowsBetweenLines ( int  lineInterval)
inline

Set the interval at which a horizontal line will be written between rows.

lineInterval [in] the number of rows between each horizontal line

Definition at line 105 of file Teuchos_TableFormat.hpp.

std::string Teuchos::TableFormat::thinline ( ) const

Return a horizontal line in dashes "----" the width of the page.

Originally called hbar, but changed to avoid possible confusion for physicists expecting hbar() to return $1.05457168e-34$ :-).

Definition at line 51 of file Teuchos_TableFormat.cpp.

std::string Teuchos::TableFormat::thickline ( ) const

Return a thick horizontal line in equal signs "====" the width of the page.

Definition at line 63 of file Teuchos_TableFormat.cpp.

std::string Teuchos::TableFormat::blanks ( int  size) const

Return a std::string full of blanks up to the requested size.

Definition at line 74 of file Teuchos_TableFormat.cpp.

int Teuchos::TableFormat::computeRequiredColumnWidth ( const std::string &  name,
const TableColumn column 
) const

Computes the column width required to write all values to the required precision.

Parameters
name[in] the title of the column
column[in] the column data

Postcondition: colString.size()==values.size()

Definition at line 85 of file Teuchos_TableFormat.cpp.

void Teuchos::TableFormat::setColumnWidths ( const Array< int > &  colWidths)
inline

Set the column widths to be used for subsequent rows.

Definition at line 134 of file Teuchos_TableFormat.hpp.

void Teuchos::TableFormat::writeRow ( std::ostream &  out,
const Array< RCP< TableEntry > > &  entries 
) const

Write the row of entries.

Parameters
out[in/out] the output stream to which the row will be written
entries[in] the data to be written into this row. Each array element is the entry for a column on this row.

Definition at line 102 of file Teuchos_TableFormat.cpp.

void Teuchos::TableFormat::writeRow ( std::ostream &  out,
int  rowIndex,
const Array< TableColumn > &  columns 
) const

Write the row of entries.

Parameters
out[in/out] the output stream to which the row will be written
columns[in] the columns of data from which this row is to be sliced
rowIndex[in] the index into the columns used to obtain the values for this row

Definition at line 123 of file Teuchos_TableFormat.cpp.

void Teuchos::TableFormat::writeWholeTable ( std::ostream &  out,
const std::string &  tableTitle,
const Array< std::string > &  columnNames,
const Array< TableColumn > &  columns 
) const

Definition at line 139 of file Teuchos_TableFormat.cpp.


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