Teuchos Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
comm
src
Teuchos_TableFormat.hpp
Go to the documentation of this file.
1
// @HEADER
2
// ***********************************************************************
3
//
4
// Teuchos: Common Tools Package
5
// Copyright (2004) Sandia Corporation
6
//
7
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8
// license for use of this work by or on behalf of the U.S. Government.
9
//
10
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are
12
// met:
13
//
14
// 1. Redistributions of source code must retain the above copyright
15
// notice, this list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright
18
// notice, this list of conditions and the following disclaimer in the
19
// documentation and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the Corporation nor the names of the
22
// contributors may be used to endorse or promote products derived from
23
// this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
//
37
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38
//
39
// ***********************************************************************
40
// @HEADER
41
42
#ifndef TEUCHOS_TABLEFORMAT_H
43
#define TEUCHOS_TABLEFORMAT_H
44
48
49
#include "
Teuchos_ConfigDefs.hpp
"
50
#include "
Teuchos_TableColumn.hpp
"
51
#include <iostream>
52
53
namespace
Teuchos
54
{
55
65
class
TableFormat
66
{
67
public
:
69
TableFormat
() :
70
pageWidth_
(80),
71
precision_
(4),
72
columnSpacing_
(4),
73
lineInterval_
(10),
74
columnWidths_
()
75
{}
76
79
int
pageWidth
()
const
{
return
pageWidth_
;}
80
83
int
precision
()
const
{
return
precision_
;}
84
87
int
columnSpacing
()
const
{
return
columnSpacing_
;}
88
92
void
setPageWidth
(
int
pw)
const
{
pageWidth_
= pw;}
93
95
void
setPrecision
(
int
p) {
precision_
= p;}
96
98
void
setColumnSpacing
(
int
columnSpacing_in) {
columnSpacing_
= columnSpacing_in;}
99
105
void
setRowsBetweenLines
(
int
lineInterval) {
lineInterval_
=lineInterval;}
106
113
std::string
thinline
()
const
;
114
117
std::string
thickline
()
const
;
118
120
std::string
blanks
(
int
size
)
const
;
121
130
int
computeRequiredColumnWidth
(
const
std::string& name,
131
const
TableColumn
& column)
const
;
132
134
void
setColumnWidths
(
const
Array<int>
& colWidths)
135
{
columnWidths_
= colWidths;}
136
143
void
writeRow
(
144
std::ostream& out,
145
const
Array
<
RCP<TableEntry>
>& entries
146
)
const
;
147
155
void
writeRow
(
156
std::ostream& out,
157
int
rowIndex,
158
const
Array<TableColumn>
& columns
159
)
const
;
160
162
void
writeWholeTable
(
163
std::ostream& out,
164
const
std::string& tableTitle,
165
const
Array<std::string>
& columnNames,
166
const
Array<TableColumn>
& columns
167
)
const
;
168
169
protected
:
170
171
int
defaultColumnWidth
()
const
{
return
20;}
172
173
private
:
174
175
mutable
int
pageWidth_
;
176
int
precision_
;
177
int
columnSpacing_
;
178
//int maxNameSize_; // UNUSED
179
int
lineInterval_
;
180
Array<int>
columnWidths_
;
181
};
182
183
184
}
// namespace Teuchos
185
186
187
#endif
Teuchos_ConfigDefs.hpp
Teuchos header file which uses auto-configuration information to include necessary C++ headers.
Teuchos_TableColumn.hpp
A column of TableEntry objects.
Teuchos::Array
Replacement for std::vector that is compatible with the Teuchos Memory Management classes.
Definition
Teuchos_Array.hpp:195
Teuchos::Comm::size
int size(const Comm< Ordinal > &comm)
Get the number of processes in the communicator.
Definition
Teuchos_CommHelpers.hpp:1176
Teuchos::RCP
Smart reference counting pointer class for automatic garbage collection.
Definition
Teuchos_RCPDecl.hpp:429
Teuchos::TableColumn
Definition
Teuchos_TableColumn.hpp:62
Teuchos::TableFormat::thickline
std::string thickline() const
Return a thick horizontal line in equal signs "====" the width of the page.
Definition
Teuchos_TableFormat.cpp:63
Teuchos::TableFormat::columnWidths_
Array< int > columnWidths_
Definition
Teuchos_TableFormat.hpp:180
Teuchos::TableFormat::setColumnWidths
void setColumnWidths(const Array< int > &colWidths)
Set the column widths to be used for subsequent rows.
Definition
Teuchos_TableFormat.hpp:134
Teuchos::TableFormat::setPageWidth
void setPageWidth(int pw) const
Set the number of characters on a line. This quantity can be updated within the const method writeWho...
Definition
Teuchos_TableFormat.hpp:92
Teuchos::TableFormat::defaultColumnWidth
int defaultColumnWidth() const
Definition
Teuchos_TableFormat.hpp:171
Teuchos::TableFormat::precision
int precision() const
Get the precision for writing doubles. Default is 4.
Definition
Teuchos_TableFormat.hpp:83
Teuchos::TableFormat::setColumnSpacing
void setColumnSpacing(int columnSpacing_in)
Set the number of characters to be left as blank spaces in each column.
Definition
Teuchos_TableFormat.hpp:98
Teuchos::TableFormat::setPrecision
void setPrecision(int p)
Set the precision for writing doubles.
Definition
Teuchos_TableFormat.hpp:95
Teuchos::TableFormat::columnSpacing_
int columnSpacing_
Definition
Teuchos_TableFormat.hpp:177
Teuchos::TableFormat::setRowsBetweenLines
void setRowsBetweenLines(int lineInterval)
Set the interval at which a horizontal line will be written between rows.
Definition
Teuchos_TableFormat.hpp:105
Teuchos::TableFormat::blanks
std::string blanks(int size) const
Return a std::string full of blanks up to the requested size.
Definition
Teuchos_TableFormat.cpp:74
Teuchos::TableFormat::writeRow
void writeRow(std::ostream &out, const Array< RCP< TableEntry > > &entries) const
Write the row of entries.
Definition
Teuchos_TableFormat.cpp:102
Teuchos::TableFormat::columnSpacing
int columnSpacing() const
Get the number of characters to be left as blank spaces in each column. Default is 4.
Definition
Teuchos_TableFormat.hpp:87
Teuchos::TableFormat::pageWidth
int pageWidth() const
Get the maximum number of characters per line. Default is 80.
Definition
Teuchos_TableFormat.hpp:79
Teuchos::TableFormat::pageWidth_
int pageWidth_
Definition
Teuchos_TableFormat.hpp:175
Teuchos::TableFormat::TableFormat
TableFormat()
Construct with a header and default format settings.
Definition
Teuchos_TableFormat.hpp:69
Teuchos::TableFormat::thinline
std::string thinline() const
Return a horizontal line in dashes "----" the width of the page.
Definition
Teuchos_TableFormat.cpp:51
Teuchos::TableFormat::precision_
int precision_
Definition
Teuchos_TableFormat.hpp:176
Teuchos::TableFormat::writeWholeTable
void writeWholeTable(std::ostream &out, const std::string &tableTitle, const Array< std::string > &columnNames, const Array< TableColumn > &columns) const
Definition
Teuchos_TableFormat.cpp:139
Teuchos::TableFormat::lineInterval_
int lineInterval_
Definition
Teuchos_TableFormat.hpp:179
Teuchos::TableFormat::computeRequiredColumnWidth
int computeRequiredColumnWidth(const std::string &name, const TableColumn &column) const
Computes the column width required to write all values to the required precision.
Definition
Teuchos_TableFormat.cpp:85
Teuchos
Definition
Teuchos_AbstractFactory.hpp:47
Generated by
1.17.0