110 size_t collectionSize = collection.size();
111 for (
size_t index = 0; index < collectionSize; ++index) {
112 auto stringEle = collection[index];
120 if (index == 0 || index == collectionSize - 1) {
122 }
else if (index == 1) {
137 if (index != collectionSize - 1 &&
fTable.size() <= row) {
160 : fTypes(types), fWidths(columnNames.size(), 0), fRepresentations(columnNames.size()),
161 fCollectionsRepresentations(columnNames.size()), fNColumns(columnNames.size()), fEntries(entries)
165 fTable.push_back(std::vector<DElement_t>(columnNames.size()));
166 for (
auto name : columnNames) {
173 size_t totalWidth = 0;
176 for (
size_t i = 0; i < size; ++i) {
188 auto columnsToPrint =
190 std::vector<bool> hasPrintedNext(
fNColumns,
193 auto nrRows =
fTable.size();
194 for (
size_t rowIndex = 0; rowIndex < nrRows; ++rowIndex) {
195 auto &row =
fTable[rowIndex];
197 std::stringstream stringRow;
198 bool isRowEmpty =
true;
200 for (
size_t columnIndex = 0; columnIndex < columnsToPrint; ++columnIndex) {
201 const auto &element = row[columnIndex];
202 std::string printedElement =
"";
204 if (element.IsDot()) {
205 printedElement =
"...";
206 }
else if (element.IsPrint()) {
208 if (!hasPrintedNext[columnIndex]) {
209 printedElement = element.GetRepresentation();
211 hasPrintedNext[columnIndex] =
216 if (!hasPrintedNext[columnIndex]) {
217 size_t i = rowIndex + 1;
218 for (; !
fTable[i][columnIndex].IsPrint(); ++i) {
221 printedElement =
fTable[i][columnIndex].GetRepresentation();
222 hasPrintedNext[columnIndex] =
true;
225 if (!printedElement.empty()) {
230 stringRow << std::left << std::setw(
fWidths[columnIndex]) << std::setfill(
fgSeparator) << printedElement
234 std::cout << stringRow.str() << std::endl;
243 std::stringstream stringRepresentation;
245 for (
size_t i = 0; i < row.size(); ++i) {
246 stringRepresentation << std::left << std::setw(
fWidths[i]) << std::setfill(
fgSeparator)
247 << row[i].GetRepresentation() <<
" | ";
249 stringRepresentation <<
"\n";
251 return stringRepresentation.str();
bool IsIgnore() const
Return if the cell has to be skipped.
bool IsDot() const
Return if the cell has to be replaced by "...".
const std::string & GetRepresentation() const
bool IsPrint() const
Return if the cell has to be printed.
void SetDots()
Flag this cell to be replaced by "...".
PrintingAction fPrintingAction
void SetPrint()
Flag this cell as to be printed.
void SetIgnore()
Flag this cell as to be skipped.
std::string fRepresentation
RDisplayElement()
Constructor assuming an empty representation to be printed.
void AddCollectionToRow(const VecStr_t &collection)
Adds a collection to the table.
size_t fCurrentColumn
Column that is being filled.
ROOT::Internal::RDF::RDisplayElement DElement_t
std::vector< std::vector< DElement_t > > fTable
String representation of the data to be printed.
std::string AsString() const
Returns the representation as a string.
void AddToRow(const std::string &stringEle)
Adds a single element to the next slot in the table.
size_t fCurrentRow
Row that is being filled.
void MovePosition()
Moves to the next cell.
std::vector< unsigned short > fWidths
Tracks the maximum width of each column, based on the largest element.
static constexpr unsigned fgMaxWidth
RDisplay(const VecStr_t &columnNames, const VecStr_t &types, int entries)
Creates an RDisplay to print the event values.
size_t fNextRow
Next row to be filled.
std::vector< std::string > VecStr_t
void Print() const
Prints the representation to the standard output.
size_t GetNColumnsToShorten() const
Get the number of columns that do NOT fit in the characters limit.
static constexpr char fgSeparator
Spacing used to align the table entries.
size_t fNColumns
Number of columns to be printed.
Namespace for new ROOT classes and functions.