ComPWA
Common Partial-Wave-Analysis Framework
TableFormatter.hpp
Go to the documentation of this file.
1
// Copyright (c) 2015 The ComPWA Team.
2
// This file is part of the ComPWA framework, check
3
// https://github.com/ComPWA/ComPWA/license.txt for details.
4
5
#ifndef CORE_TABLEFORMATER_HPP_
6
#define CORE_TABLEFORMATER_HPP_
7
8
#include <iomanip>
9
#include <ostream>
10
#include <string>
11
#include <vector>
12
13
#include "
Core/FitParameter.hpp
"
14
15
namespace
ComPWA
{
16
17
class
TableFormatter
{
18
public
:
19
TableFormatter
(std::ostream *output)
20
:
OutputStream
(output),
CurRow
(0),
CurCol
(0),
TotalWidth
(0) {
21
sep
=
"|"
;
22
pm
=
"+-"
;
23
firstSep
=
sep
;
24
lastSep
=
sep
;
25
};
26
27
virtual
~TableFormatter
() {}
28
29
virtual
void
reset
();
30
31
virtual
void
delim
();
32
33
virtual
void
footer
();
34
35
virtual
void
header
();
36
37
virtual
void
addColumn
(std::string title,
unsigned
int
fixlength = 999);
38
39
void
trimString
(std::string &src);
40
41
template
<
typename
T>
TableFormatter
&
operator<<
(T in) {
42
if
(
CurCol
== 0)
43
*
OutputStream
<<
firstSep
+
" "
;
44
else
45
*
OutputStream
<<
" "
<<
sep
<<
" "
;
46
*
OutputStream
<< std::setw(
ColumnWidth
.at(
CurCol
)) << in;
47
CurCol
++;
48
if
(CurCol ==
ColumnWidth
.size()) {
49
*
OutputStream
<<
" "
<<
lastSep
<< std::endl;
50
CurRow
++;
51
CurCol = 0;
52
}
53
return
*
this
;
54
};
55
56
protected
:
57
std::ostream *
OutputStream
;
58
std::vector<unsigned int>
ColumnWidth
;
59
std::vector<std::string>
ColumnTitle
;
60
61
unsigned
int
CurRow
;
62
unsigned
int
CurCol
;
63
unsigned
int
TotalWidth
;
64
std::string
sep
;
65
std::string
firstSep
;
66
std::string
lastSep
;
67
std::string
pm
;
68
};
69
70
}
// namespace ComPWA
71
72
#endif
ComPWA::TableFormatter::reset
virtual void reset()
Definition:
TableFormatter.cpp:38
ComPWA::TableFormatter::header
virtual void header()
Definition:
TableFormatter.cpp:18
ComPWA
Definition:
Efficiency.cpp:7
FitParameter.hpp
ComPWA::TableFormatter::lastSep
std::string lastSep
Definition:
TableFormatter.hpp:66
ComPWA::TableFormatter::trimString
void trimString(std::string &src)
Definition:
TableFormatter.cpp:46
ComPWA::TableFormatter::OutputStream
std::ostream * OutputStream
Definition:
TableFormatter.hpp:54
ComPWA::TableFormatter::TableFormatter
TableFormatter(std::ostream *output)
Definition:
TableFormatter.hpp:19
ComPWA::TableFormatter::~TableFormatter
virtual ~TableFormatter()
Definition:
TableFormatter.hpp:27
ComPWA::TableFormatter::footer
virtual void footer()
Definition:
TableFormatter.cpp:16
ComPWA::TableFormatter::operator<<
TableFormatter & operator<<(T in)
Definition:
TableFormatter.hpp:41
ComPWA::TableFormatter
Definition:
TableFormatter.hpp:17
ComPWA::TableFormatter::CurRow
unsigned int CurRow
Definition:
TableFormatter.hpp:61
ComPWA::TableFormatter::firstSep
std::string firstSep
Definition:
TableFormatter.hpp:65
ComPWA::TableFormatter::ColumnTitle
std::vector< std::string > ColumnTitle
Definition:
TableFormatter.hpp:59
ComPWA::TableFormatter::sep
std::string sep
Definition:
TableFormatter.hpp:64
ComPWA::TableFormatter::ColumnWidth
std::vector< unsigned int > ColumnWidth
Definition:
TableFormatter.hpp:58
ComPWA::TableFormatter::CurCol
unsigned int CurCol
Definition:
TableFormatter.hpp:62
ComPWA::TableFormatter::pm
std::string pm
Definition:
TableFormatter.hpp:67
ComPWA::TableFormatter::TotalWidth
unsigned int TotalWidth
Definition:
TableFormatter.hpp:63
ComPWA::TableFormatter::delim
virtual void delim()
Definition:
TableFormatter.cpp:9
ComPWA::TableFormatter::addColumn
virtual void addColumn(std::string title, unsigned int fixlength=999)
Definition:
TableFormatter.cpp:27
Core
TableFormatter.hpp
Generated on Mon Jun 22 2020 13:03:33 for ComPWA by
1.8.13