Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_TableFormat.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Teuchos: Common Tools Package
4//
5// Copyright 2004 NTESS and the Teuchos contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef TEUCHOS_TABLEFORMAT_H
11#define TEUCHOS_TABLEFORMAT_H
12
19#include <iostream>
20
21namespace Teuchos
22{
23
34{
35public:
38 pageWidth_ (80),
39 precision_ (4),
40 columnSpacing_ (4),
41 lineInterval_ (10),
42 columnWidths_ ()
43 {}
44
47 int pageWidth() const {return pageWidth_;}
48
51 int precision() const {return precision_;}
52
55 int columnSpacing() const {return columnSpacing_;}
56
60 void setPageWidth(int pw) const {pageWidth_ = pw;}
61
63 void setPrecision(int p) {precision_ = p;}
64
67
74
81 std::string thinline() const ;
82
85 std::string thickline() const ;
86
88 std::string blanks(int size) const ;
89
98 int computeRequiredColumnWidth(const std::string& name,
99 const TableColumn& column) const ;
100
103 {columnWidths_ = colWidths;}
104
111 void writeRow(
112 std::ostream& out,
114 ) const;
115
123 void writeRow(
124 std::ostream& out,
125 int rowIndex,
127 ) const;
128
130 void writeWholeTable(
131 std::ostream& out,
132 const std::string& tableTitle,
135 ) const ;
136
137protected:
138
139 int defaultColumnWidth() const {return 20;}
140
141private:
142
143 mutable int pageWidth_;
144 int precision_;
145 int columnSpacing_;
146 //int maxNameSize_; // UNUSED
147 int lineInterval_;
148 Array<int> columnWidths_;
149};
150
151
152} // namespace Teuchos
153
154
155#endif
Teuchos header file which uses auto-configuration information to include necessary C++ headers.
A column of TableEntry objects.
Replacement for std::vector that is compatible with the Teuchos Memory Management classes.
Smart reference counting pointer class for automatic garbage collection.
Encapsulation of formatting specifications for writing data in a clean tabular form.
std::string thickline() const
Return a thick horizontal line in equal signs "====" the width of the page.
void setColumnWidths(const Array< int > &colWidths)
Set the column widths to be used for subsequent rows.
void setPageWidth(int pw) const
Set the number of characters on a line. This quantity can be updated within the const method writeWho...
int precision() const
Get the precision for writing doubles. Default is 4.
void setColumnSpacing(int columnSpacing_in)
Set the number of characters to be left as blank spaces in each column.
void setPrecision(int p)
Set the precision for writing doubles.
void setRowsBetweenLines(int lineInterval)
Set the interval at which a horizontal line will be written between rows.
std::string blanks(int size) const
Return a std::string full of blanks up to the requested size.
void writeRow(std::ostream &out, const Array< RCP< TableEntry > > &entries) const
Write the row of entries.
int columnSpacing() const
Get the number of characters to be left as blank spaces in each column. Default is 4.
int pageWidth() const
Get the maximum number of characters per line. Default is 80.
TableFormat()
Construct with a header and default format settings.
std::string thinline() const
Return a horizontal line in dashes "----" the width of the page.
void writeWholeTable(std::ostream &out, const std::string &tableTitle, const Array< std::string > &columnNames, const Array< TableColumn > &columns) const
int computeRequiredColumnWidth(const std::string &name, const TableColumn &column) const
Computes the column width required to write all values to the required precision.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...