STORMM Source Documentation
Loading...
Searching...
No Matches
stormm::namelist::ReportTable Class Reference

Tables in output file sections work differently than tables dumped to the terminal window. These tables will take in an array of data with some dimensions and then find the best way to organize it, storing all columns and rows as a series of strings. More...

#include <report_table.h>

Public Member Functions

int getColumnCount () const
 Get the number of columns.
 
int getHeaderRowCount () const
 Get the number of header rows.
 
int getDataRowCount () const
 Get the number of data rows.
 
int getColumnWidth (int column_index) const
 Get the width of a particular column.
 
int getTableWidth () const
 Get the internal format width setting.
 
TableContentKind getContentKind () const
 Get the type of content in the table. All content is stored as strings, but depending on whether it started as real numbers, integers, or string data there may be significance.
 
const std::string & getValue (size_t row_index, size_t column_index) const
 Get the rendered data for a particular column and row.
 
void setVariableName (const std::string &variable_name_in)
 Set the variable name associated with this table.
 
void unprotectContent ()
 Convert a table of strings into a table of unprotected strings (unprotected by comment characters if the table is printed to a file intended to be parsed by third-party programs).
 
 ReportTable (const std::vector< std::string > &data_in, const std::vector< std::string > &column_headings, const std::string &variable_name_in=std::string(""), int format_width_in=default_output_file_width, const std::vector< JustifyText > &alignments={}, bool enforce_format_width=false)
 The constructor takes multiple input formats but converts all data to strings for internal storage, negating the need for templating.
 
 ReportTable (const std::vector< double > &data_in, const std::vector< std::string > &column_headings, double precision=1.0e-6, const std::string &variable_name_in=std::string(""), int format_width_in=default_output_file_width, const std::vector< JustifyText > &alignments={})
 
 ReportTable (const std::vector< double > &data_in, const std::vector< std::string > &column_headings, const std::vector< double > &precision, const std::string &variable_name_in=std::string(""), int format_width_in=default_output_file_width, const std::vector< JustifyText > &alignments={})
 
 ReportTable (const std::vector< double > &data_in, const std::vector< std::string > &column_headings, const std::vector< int > &decimal_places, const std::string &variable_name_in=std::string(""), int format_width_in=default_output_file_width, const std::vector< JustifyText > &alignments={})
 
 ReportTable (const std::vector< int > &data_in, const std::vector< std::string > &column_headings, const std::string &variable_name_in=std::string(""), int format_width_in=default_output_file_width, const std::vector< JustifyText > &alignments={})
 
 ReportTable (const std::vector< llint > &data_in, const std::vector< std::string > &column_headings, const std::string &variable_name_in=std::string(""), int format_width_in=default_output_file_width, const std::vector< JustifyText > &alignments={})
 
 ReportTable (const std::vector< char4 > &data_in, const std::vector< std::string > &column_headings, const std::string &variable_name_in=std::string(""), int format_width_in=default_output_file_width, const std::vector< JustifyText > &alignments={})
 
 ReportTable (const ReportTable &original)=default
 With no const members or pointers to repair and all Standard Template Library components, the ReportTable can be copied or moved using default constructors and assignement operators.
 
 ReportTable (ReportTable &&original)=default
 
ReportTableoperator= (const ReportTable &original)=default
 
ReportTableoperator= (ReportTable &&original)=default
 
std::string printTable (OutputSyntax style, int width=-1, int data_row_start=0, int data_row_end=-1) const
 Print the table based on some external directives.
 
void printTable (std::ofstream *foutp, OutputSyntax style, int width=-1, int data_row_start=0, int data_row_end=-1) const
 
void printTable (const std::string &file_name, PrintSituation expectation, OutputSyntax style, int width=-1, int data_row_start=0, int data_row_end=-1) const
 

Detailed Description

Tables in output file sections work differently than tables dumped to the terminal window. These tables will take in an array of data with some dimensions and then find the best way to organize it, storing all columns and rows as a series of strings.

Constructor & Destructor Documentation

◆ ReportTable()

stormm::review::ReportTable::ReportTable ( const std::vector< std::string > & data_in,
const std::vector< std::string > & column_headings,
const std::string & variable_name_in = std::string(""),
int format_width_in = default_output_file_width,
const std::vector< JustifyText > & alignments = {},
bool enforce_format_width = false )

The constructor takes multiple input formats but converts all data to strings for internal storage, negating the need for templating.

Parameters
enforce_format_widthIn a table based on strings, setting this to TRUE will attempt to enforce the overall table width to fit within the display space by shrinking the widest column

Member Function Documentation

◆ getColumnWidth()

int stormm::review::ReportTable::getColumnWidth ( int column_index) const

Get the width of a particular column.

Parameters
column_indexIndex of the column of interest, starting from zero

◆ getValue()

const std::string & stormm::review::ReportTable::getValue ( size_t row_index,
size_t column_index ) const

Get the rendered data for a particular column and row.

Parameters
row_indexIndex of the row of interest, starting from zero
column_indexIndex of the column of interest, starting from zero

◆ printTable()

std::string stormm::review::ReportTable::printTable ( OutputSyntax style,
int width = -1,
int data_row_start = 0,
int data_row_end = -1 ) const

Print the table based on some external directives.

Overloaded:

  • Print to a formatted string containing appropriate carriage returns
  • Print to a named file based on an expectation about the state in which that file will be found
  • Print to an open file using a file pointer
Parameters
variable_nameName of the variable to assign at the beginning of table data rows. The entire contents of the table will fall under this variable name.
styleOne of several options for formatting the non-protected portion of the table to be amenable to certain plotting programs
widthWidth of the output file (ASCII characters per line) to be respected when printing the table
data_row_startThe first data row to print
data_row_endThe upper limit of data rows to print (this row index is the first that will not be printed). The default of -1 implies printing all rows.
foutpFile stream pointer for the output
file_nameName of the file to open and write the table into
expectationThe state in which the output file is to be found to permit writing

◆ setVariableName()

void stormm::review::ReportTable::setVariableName ( const std::string & variable_name_in)

Set the variable name associated with this table.

Parameters
variable_name_inThe variable name to assign

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