Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
comm
src
Teuchos_TableEntry.cpp
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
#include "
Teuchos_TableEntry.hpp
"
11
12
using namespace
Teuchos
;
13
14
15
/* --------- base class methods ---------------------------------------------- */
16
17
std::string
TableEntry::toChoppedString
(
int
maxWidth)
const
18
{
19
return
toString
().substr(0, maxWidth);
20
}
21
22
23
24
/* --------- DoubleEntry methods -------------------------------------------- */
25
26
DoubleEntry::DoubleEntry
(
const
double
& value,
int
precision,
const
std::ios_base::fmtflags& flags)
27
:
TableEntry
(), data_(value), precision_(precision), fmtflags_(flags)
28
{}
29
30
std::string
DoubleEntry::toString
()
const
31
{
32
std::ostringstream toss;
33
toss.setf(fmtflags_);
34
toss << std::setprecision(precision_) << data_;
35
return
toss.str();
36
}
37
38
39
40
/* --------- IntEntry methods -------------------------------------------- */
41
42
IntEntry::IntEntry
(
int
value,
const
std::ios_base::fmtflags& flags)
43
:
TableEntry
(), data_(value), fmtflags_(flags)
44
{}
45
46
std::string
IntEntry::toString
()
const
47
{
48
std::ostringstream toss;
49
toss.setf(fmtflags_);
50
toss << data_;
51
return
toss.str();
52
}
53
54
55
56
/* --------- StringEntry methods -------------------------------------------- */
57
58
StringEntry::StringEntry
(std::string value)
59
:
TableEntry
(), data_(value)
60
{}
61
62
std::string
StringEntry::toString
()
const
63
{
64
return
data_;
65
}
66
67
68
69
70
71
/* --------- CompoundEntryWithParentheses methods ------------------------- */
72
73
CompoundEntryWithParentheses
74
::CompoundEntryWithParentheses(
const
RCP<TableEntry>
& first,
75
const
RCP<TableEntry>
& second,
76
bool
spaceBeforeParens)
77
:
TableEntry
(),
78
first_(first),
79
second_(second),
80
spaceBeforeParens_(spaceBeforeParens)
81
{}
82
83
std::string
CompoundEntryWithParentheses::toString
()
const
84
{
85
std::ostringstream toss;
86
87
toss << first_->
toString
();
88
if
(spaceBeforeParens_) toss <<
" "
;
89
toss <<
"("
<< second_->toString() <<
")"
;
90
91
return
toss.str();
92
}
93
94
95
96
97
98
Teuchos_TableEntry.hpp
Base class for representing compound entries in a printed table of data. "Compound" means that each e...
Teuchos::CompoundEntryWithParentheses::toString
virtual std::string toString() const
Write the specified entry to a std::string.
Definition
Teuchos_TableEntry.cpp:83
Teuchos::DoubleEntry::toString
virtual std::string toString() const
Write the specified entry to a std::string.
Definition
Teuchos_TableEntry.cpp:30
Teuchos::DoubleEntry::DoubleEntry
DoubleEntry(const double &value, int precision, const std::ios_base::fmtflags &flags)
Construct with a value and a precision.
Definition
Teuchos_TableEntry.cpp:26
Teuchos::IntEntry::toString
virtual std::string toString() const
Write the specified entry to a std::string.
Definition
Teuchos_TableEntry.cpp:46
Teuchos::IntEntry::IntEntry
IntEntry(int value, const std::ios_base::fmtflags &flags)
Construct with a value.
Definition
Teuchos_TableEntry.cpp:42
Teuchos::RCP
Smart reference counting pointer class for automatic garbage collection.
Definition
Teuchos_RCPDecl.hpp:397
Teuchos::StringEntry::StringEntry
StringEntry(std::string value)
Construct with a value.
Definition
Teuchos_TableEntry.cpp:58
Teuchos::StringEntry::toString
virtual std::string toString() const
Write the specified entry to a std::string.
Definition
Teuchos_TableEntry.cpp:62
Teuchos::TableEntry
An entry, perhaps compound, to be written into a table.
Definition
Teuchos_TableEntry.hpp:38
Teuchos::TableEntry::TableEntry
TableEntry()
Empty ctor.
Definition
Teuchos_TableEntry.hpp:41
Teuchos::TableEntry::toString
virtual std::string toString() const =0
Return a std::string representation of this entry.
Teuchos::TableEntry::toChoppedString
virtual std::string toChoppedString(int maxWidth) const
Return a std::string representation of this entry, truncated if necessary to fit within the given col...
Definition
Teuchos_TableEntry.cpp:17
Teuchos
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Generated by
1.17.0