CbmRoot
Loading...
Searching...
No Matches
CbmTextReportElement.cxx
Go to the documentation of this file.
1/* Copyright (C) 2011-2020 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Semen Lebedev, Andrey Lebedev [committer], Florian Uhlig */
4
11
12#include <iomanip> // for operator<<, setfill, setw
13#include <sstream> // for string, basic_ostream, stringstream
14#include <string> // for char_traits
15
16using std::endl;
17using std::left;
18using std::right;
19using std::setfill;
20using std::setw;
21using std::string;
22using std::stringstream;
23using std::vector;
24
26
28
29string CbmTextReportElement::TableBegin(const string& caption, const vector<string>& colNames) const
30{
31 stringstream ss;
32 ss << caption << endl;
33 ss << right;
34 ss << setfill('_') << setw(colNames.size() * fColW) << "_" << endl;
35 ss << setfill(' ');
36 for (UInt_t i = 0; i < colNames.size(); i++) {
37 ss << FormatCell(colNames[i]); //setw(fColW) << colNames[i];
38 }
39 ss << endl;
40 ss << setfill('_') << setw(colNames.size() * fColW) << "_" << endl;
41 return ss.str();
42}
43
45{
46 stringstream ss;
47 ss << endl;
48 return ss.str();
49}
50
51string CbmTextReportElement::TableEmptyRow(Int_t nofCols, const string& name) const
52{
53 stringstream ss;
54 ss << setfill('-') << left;
55 ss << setw(nofCols * fColW) << name << endl;
56 ss << setfill(' ') << left;
57 return ss.str();
58}
59
60string CbmTextReportElement::TableRow(const vector<string>& row) const
61{
62 stringstream ss;
63 ss << right;
64 for (UInt_t i = 0; i < row.size(); i++) {
65 ss << FormatCell(row[i]); //setw(fColW) << row[i];
66 }
67 ss << endl;
68 return ss.str();
69}
70
71string CbmTextReportElement::Image(const string& /*title*/, const string& /*file*/) const { return ""; }
72
74{
75 stringstream ss;
76 ss << "------------------------------------------------" << endl;
77 return ss.str();
78}
79
80string CbmTextReportElement::DocumentEnd() const { return ""; }
81
82string CbmTextReportElement::Title(Int_t /*size*/, const string& title) const { return title; }
83
84string CbmTextReportElement::FormatCell(const string& cell) const
85{
86 if (static_cast<Int_t>(cell.size()) <= fColW) {
87 stringstream ss;
88 ss << setw(fColW) << cell;
89 return ss.str();
90 }
91 else {
92 string str = cell;
93 str.resize(fColW - 3);
94 str.insert(fColW - 3, "...");
95 return str;
96 }
97}
98
ClassImp(CbmConverterManager)
Implementation of CbmLitReportElement for text output.
Implementation of CbmLitReportElement for text output.
virtual std::string Title(Int_t size, const std::string &title) const
Inherited from CbmReportElement.
virtual ~CbmTextReportElement()
Destructor.
virtual std::string TableRow(const std::vector< std::string > &row) const
Inherited from CbmReportElement.
virtual std::string Image(const std::string &title, const std::string &file) const
Inherited from CbmReportElement.
virtual std::string TableBegin(const std::string &caption, const std::vector< std::string > &colNames) const
Inherited from CbmReportElement.
virtual std::string TableEmptyRow(Int_t nofCols, const std::string &name) const
Inherited from CbmReportElement.
virtual std::string DocumentEnd() const
Inherited from CbmReportElement.
std::string FormatCell(const std::string &cell) const
virtual std::string TableEnd() const
Inherited from CbmReportElement.
virtual std::string DocumentBegin() const
Inherited from CbmReportElement.