CbmRoot
CbmTextReportElement.cxx
Go to the documentation of this file.
1 
6 #include "CbmTextReportElement.h"
7 
8 #include <iomanip> // for operator<<, setfill, setw
9 #include <sstream> // for string, basic_ostream, stringstream
10 #include <string> // for char_traits
11 
12 using std::endl;
13 using std::left;
14 using std::right;
15 using std::setfill;
16 using std::setw;
17 using std::string;
18 using std::stringstream;
19 using std::vector;
20 
22 
24 
25 string CbmTextReportElement::TableBegin(const string& caption,
26  const vector<string>& colNames) const {
27  stringstream ss;
28  ss << caption << endl;
29  ss << right;
30  ss << setfill('_') << setw(colNames.size() * fColW) << "_" << endl;
31  ss << setfill(' ');
32  for (UInt_t i = 0; i < colNames.size(); i++) {
33  ss << FormatCell(colNames[i]); //setw(fColW) << colNames[i];
34  }
35  ss << endl;
36  ss << setfill('_') << setw(colNames.size() * fColW) << "_" << endl;
37  return ss.str();
38 }
39 
41  stringstream ss;
42  ss << endl;
43  return ss.str();
44 }
45 
47  const string& name) const {
48  stringstream ss;
49  ss << setfill('-') << left;
50  ss << setw(nofCols * fColW) << name << endl;
51  ss << setfill(' ') << left;
52  return ss.str();
53 }
54 
55 string CbmTextReportElement::TableRow(const vector<string>& row) const {
56  stringstream ss;
57  ss << right;
58  for (UInt_t i = 0; i < row.size(); i++) {
59  ss << FormatCell(row[i]); //setw(fColW) << row[i];
60  }
61  ss << endl;
62  return ss.str();
63 }
64 
65 string CbmTextReportElement::Image(const string& /*title*/,
66  const string& /*file*/) const {
67  return "";
68 }
69 
71  stringstream ss;
72  ss << "------------------------------------------------" << endl;
73  return ss.str();
74 }
75 
76 string CbmTextReportElement::DocumentEnd() const { return ""; }
77 
78 string CbmTextReportElement::Title(Int_t /*size*/, const string& title) const {
79  return title;
80 }
81 
82 string CbmTextReportElement::FormatCell(const string& cell) const {
83  if (static_cast<Int_t>(cell.size()) <= fColW) {
84  stringstream ss;
85  ss << setw(fColW) << cell;
86  return ss.str();
87  } else {
88  string str = cell;
89  str.resize(fColW - 3);
90  str.insert(fColW - 3, "...");
91  return str;
92  }
93 }
94 
CbmTextReportElement::Image
virtual std::string Image(const std::string &title, const std::string &file) const
Inherited from CbmReportElement.
Definition: CbmTextReportElement.cxx:65
CbmTextReportElement::DocumentEnd
virtual std::string DocumentEnd() const
Inherited from CbmReportElement.
Definition: CbmTextReportElement.cxx:76
CbmTextReportElement::TableEnd
virtual std::string TableEnd() const
Inherited from CbmReportElement.
Definition: CbmTextReportElement.cxx:40
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmTextReportElement::TableRow
virtual std::string TableRow(const std::vector< std::string > &row) const
Inherited from CbmReportElement.
Definition: CbmTextReportElement.cxx:55
CbmTextReportElement::TableBegin
virtual std::string TableBegin(const std::string &caption, const std::vector< std::string > &colNames) const
Inherited from CbmReportElement.
Definition: CbmTextReportElement.cxx:25
CbmTextReportElement::~CbmTextReportElement
virtual ~CbmTextReportElement()
Destructor.
Definition: CbmTextReportElement.cxx:23
CbmTextReportElement::DocumentBegin
virtual std::string DocumentBegin() const
Inherited from CbmReportElement.
Definition: CbmTextReportElement.cxx:70
CbmTextReportElement::fColW
Int_t fColW
Definition: CbmTextReportElement.h:83
CbmTextReportElement::FormatCell
std::string FormatCell(const std::string &cell) const
Definition: CbmTextReportElement.cxx:82
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmTextReportElement::TableEmptyRow
virtual std::string TableEmptyRow(Int_t nofCols, const std::string &name) const
Inherited from CbmReportElement.
Definition: CbmTextReportElement.cxx:46
CbmTextReportElement::Title
virtual std::string Title(Int_t size, const std::string &title) const
Inherited from CbmReportElement.
Definition: CbmTextReportElement.cxx:78
CbmTextReportElement::CbmTextReportElement
CbmTextReportElement()
Constructor.
Definition: CbmTextReportElement.cxx:21
CbmTextReportElement
Implementation of CbmLitReportElement for text output.
Definition: CbmTextReportElement.h:24
CbmTextReportElement.h
Implementation of CbmLitReportElement for text output.