STORMM Source Documentation
Loading...
Searching...
No Matches
report_table.h
1// -*-c++-*-
2#ifndef STORMM_REPORT_TABLE_H
3#define STORMM_REPORT_TABLE_H
4
5#include <string>
6#include <vector>
7#include "copyright.h"
8#include "DataTypes/common_types.h"
9#include "DataTypes/stormm_vector_types.h"
10#include "FileManagement/file_enumerators.h"
11#include "Parsing/parsing_enumerators.h"
12#include "reporting_enumerators.h"
13#include "summary_file.h"
14
15namespace stormm {
16namespace review {
17
18using diskutil::PrintSituation;
19using parse::JustifyText;
20
25public:
26
34 ReportTable(const std::vector<std::string> &data_in,
35 const std::vector<std::string> &column_headings,
36 const std::string &variable_name_in = std::string(""),
37 int format_width_in = default_output_file_width,
38 const std::vector<JustifyText> &alignments = {}, bool enforce_format_width = false);
39
40 ReportTable(const std::vector<double> &data_in, const std::vector<std::string> &column_headings,
41 double precision = 1.0e-6, const std::string &variable_name_in = std::string(""),
42 int format_width_in = default_output_file_width,
43 const std::vector<JustifyText> &alignments = {});
44
45 ReportTable(const std::vector<double> &data_in, const std::vector<std::string> &column_headings,
46 const std::vector<double> &precision,
47 const std::string &variable_name_in = std::string(""),
48 int format_width_in = default_output_file_width,
49 const std::vector<JustifyText> &alignments = {});
50
51 ReportTable(const std::vector<double> &data_in, const std::vector<std::string> &column_headings,
52 const std::vector<int> &decimal_places,
53 const std::string &variable_name_in = std::string(""),
54 int format_width_in = default_output_file_width,
55 const std::vector<JustifyText> &alignments = {});
56
57 ReportTable(const std::vector<int> &data_in, const std::vector<std::string> &column_headings,
58 const std::string &variable_name_in = std::string(""),
59 int format_width_in = default_output_file_width,
60 const std::vector<JustifyText> &alignments = {});
61
62 ReportTable(const std::vector<llint> &data_in, const std::vector<std::string> &column_headings,
63 const std::string &variable_name_in = std::string(""),
64 int format_width_in = default_output_file_width,
65 const std::vector<JustifyText> &alignments = {});
66
67 ReportTable(const std::vector<char4> &data_in, const std::vector<std::string> &column_headings,
68 const std::string &variable_name_in = std::string(""),
69 int format_width_in = default_output_file_width,
70 const std::vector<JustifyText> &alignments = {});
72
77 ReportTable(const ReportTable &original) = default;
78 ReportTable(ReportTable &&original) = default;
79 ReportTable& operator=(const ReportTable &original) = default;
80 ReportTable& operator=(ReportTable &&original) = default;
82
84 int getColumnCount() const;
85
87 int getHeaderRowCount() const;
88
90 int getDataRowCount() const;
91
95 int getColumnWidth(int column_index) const;
96
98 int getTableWidth() const;
99
103 TableContentKind getContentKind() const;
104
109 const std::string& getValue(size_t row_index, size_t column_index) const;
110
133 std::string printTable(OutputSyntax style, int width = -1, int data_row_start = 0,
134 int data_row_end = -1) const;
135
136 void printTable(std::ofstream *foutp, OutputSyntax style, int width = -1, int data_row_start = 0,
137 int data_row_end = -1) const;
138
139 void printTable(const std::string &file_name, PrintSituation expectation, OutputSyntax style,
140 int width = -1, int data_row_start = 0, int data_row_end = -1) const;
142
146 void setVariableName(const std::string &variable_name_in);
147
151 void unprotectContent();
152
153private:
154 int column_count;
155 int data_row_count;
156 int header_row_count;
160 int format_width;
163 TableContentKind data_kind;
164 std::vector<std::string> rendered_data;
166 std::vector<std::string> column_headings;
171 std::vector<int> column_widths;
174 std::string variable_name;
179
187 void formatColumnHeadings(const std::vector<std::string> &column_headings_in,
188 const std::vector<size_t> &data_widths);
189
196 void findColumnWidths(const std::vector<size_t> &data_widths,
197 const std::vector<JustifyText> &alignments = {});
198
215 std::vector<std::string> dataAsStrings(const std::vector<double> &data_in, int ncol,
216 double precision);
217
218 std::vector<std::string> dataAsStrings(const std::vector<double> &data_in,
219 const std::vector<double> &precision);
220
221 std::vector<std::string> dataAsStrings(const std::vector<double> &data_in,
222 const std::vector<int> &decimal_places);
223
224 std::vector<std::string> dataAsStrings(const std::vector<int> &data_in, int ncol);
225
226 std::vector<std::string> dataAsStrings(const std::vector<llint> &data_in, int ncol);
227
228 std::vector<std::string> dataAsStrings(const std::vector<char4> &data_in, int ncol);
230
246 std::string formatVariableName(OutputSyntax style, int set_start, int set_end,
247 int data_row_start, int actual_row_end) const;
248
256
257 std::string formatClosure(OutputSyntax style, const std::string &comment_block,
258 const std::string &carriage_return, std::string *hstack_line,
259 std::string *hstack_declaration, int set_start, int set_end) const;
260};
261
262} // namespace review
263} // namespace stormm
264
265#endif
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,...
Definition report_table.cpp:26
void setVariableName(const std::string &variable_name_in)
Set the variable name associated with this table.
Definition report_table.cpp:534
ReportTable(const ReportTable &original)=default
With no const members or pointers to repair and all Standard Template Library components,...
void unprotectContent()
Convert a table of strings into a table of unprotected strings (unprotected by comment characters if ...
Definition report_table.cpp:539
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,...
Definition report_table.cpp:26
int getHeaderRowCount() const
Get the number of header rows.
Definition report_table.cpp:231
const std::string & getValue(size_t row_index, size_t column_index) const
Get the rendered data for a particular column and row.
Definition report_table.cpp:260
int getColumnCount() const
Get the number of columns.
Definition report_table.cpp:226
TableContentKind getContentKind() const
Get the type of content in the table. All content is stored as strings, but depending on whether it s...
Definition report_table.cpp:255
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.
Definition report_table.cpp:270
int getColumnWidth(int column_index) const
Get the width of a particular column.
Definition report_table.cpp:241
int getDataRowCount() const
Get the number of data rows.
Definition report_table.cpp:236
int getTableWidth() const
Get the internal format width setting.
Definition report_table.cpp:250