Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
17 #include "Teuchos_ConfigDefs.hpp"
18 #include "Teuchos_TableColumn.hpp"
19 #include <iostream>
20 
21 namespace Teuchos
22 {
23 
34 {
35 public:
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 
66  void setColumnSpacing(int columnSpacing_in) {columnSpacing_ = columnSpacing_in;}
67 
73  void setRowsBetweenLines(int lineInterval) {lineInterval_=lineInterval;}
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 
102  void setColumnWidths(const Array<int>& colWidths)
103  {columnWidths_ = colWidths;}
104 
111  void writeRow(
112  std::ostream& out,
113  const Array<RCP<TableEntry> >& entries
114  ) const;
115 
123  void writeRow(
124  std::ostream& out,
125  int rowIndex,
126  const Array<TableColumn>& columns
127  ) const;
128 
130  void writeWholeTable(
131  std::ostream& out,
132  const std::string& tableTitle,
133  const Array<std::string>& columnNames,
134  const Array<TableColumn>& columns
135  ) const ;
136 
137 protected:
138 
139  int defaultColumnWidth() const {return 20;}
140 
141 private:
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
void setColumnWidths(const Array< int > &colWidths)
Set the column widths to be used for subsequent rows.
void writeWholeTable(std::ostream &out, const std::string &tableTitle, const Array< std::string > &columnNames, const Array< TableColumn > &columns) const
void setColumnSpacing(int columnSpacing_in)
Set the number of characters to be left as blank spaces in each column.
int computeRequiredColumnWidth(const std::string &name, const TableColumn &column) const
Computes the column width required to write all values to the required precision. ...
Teuchos header file which uses auto-configuration information to include necessary C++ headers...
int pageWidth() const
Get the maximum number of characters per line. Default is 80.
A column of TableEntry objects.
void setPrecision(int p)
Set the precision for writing doubles.
int precision() const
Get the precision for writing doubles. Default is 4.
std::string blanks(int size) const
Return a std::string full of blanks up to the requested size.
void setPageWidth(int pw) const
Set the number of characters on a line. This quantity can be updated within the const method writeWho...
TableFormat()
Construct with a header and default format settings.
int columnSpacing() const
Get the number of characters to be left as blank spaces in each column. Default is 4...
std::string thickline() const
Return a thick horizontal line in equal signs &quot;====&quot; the width of the page.
void setRowsBetweenLines(int lineInterval)
Set the interval at which a horizontal line will be written between rows.
std::string thinline() const
Return a horizontal line in dashes &quot;----&quot; the width of the page.
Smart reference counting pointer class for automatic garbage collection.
void writeRow(std::ostream &out, const Array< RCP< TableEntry > > &entries) const
Write the row of entries.
Encapsulation of formatting specifications for writing data in a clean tabular form.