98 if (w > std::numeric_limits<unsigned short>::max()) {
99 w = std::numeric_limits<unsigned short>::max();
122 size_t collectionSize = collection.size();
123 for (
size_t index = 0; index < collectionSize; ++index) {
124 auto stringEle = collection[index];
130 if (index == 0 || index == collectionSize - 1) {
132 }
else if (index == 1) {
145 if (index != collectionSize - 1 &&
fTable.size() <= row) {
168 : fTypes(types), fWidths(columnNames.size(), 0), fRepresentations(columnNames.size()),
169 fCollectionsRepresentations(columnNames.size()), fNColumns(columnNames.size()), fEntries(entries)
173 fTable.push_back(std::vector<DElement_t>(columnNames.size()));
174 for (
auto name : columnNames) {
181 size_t totalWidth = 0;
184 for (
size_t i = 0; i < size; ++i) {
196 auto columnsToPrint =
198 std::vector<bool> hasPrintedNext(
fNColumns,
201 auto nrRows =
fTable.size();
202 for (
size_t rowIndex = 0; rowIndex < nrRows; ++rowIndex) {
203 auto &row =
fTable[rowIndex];
205 std::stringstream stringRow;
206 bool isRowEmpty =
true;
208 for (
size_t columnIndex = 0; columnIndex < columnsToPrint; ++columnIndex) {
209 const auto &element = row[columnIndex];
210 std::string printedElement =
"";
212 if (element.IsDot()) {
213 printedElement =
"...";
214 }
else if (element.IsPrint()) {
216 if (!hasPrintedNext[columnIndex]) {
217 printedElement = element.GetRepresentation();
219 hasPrintedNext[columnIndex] =
224 if (!hasPrintedNext[columnIndex]) {
225 size_t i = rowIndex + 1;
226 for (; !
fTable[i][columnIndex].IsPrint(); ++i) {
229 printedElement =
fTable[i][columnIndex].GetRepresentation();
230 hasPrintedNext[columnIndex] =
true;
233 if (!printedElement.empty()) {
238 stringRow << std::left << std::setw(
fWidths[columnIndex]) << std::setfill(
fgSeparator) << printedElement
242 std::cout << stringRow.str() << std::endl;
251 std::stringstream stringRepresentation;
253 for (
size_t i = 0; i < row.size(); ++i) {
254 stringRepresentation << std::left << std::setw(
fWidths[i]) << std::setfill(
fgSeparator)
255 << row[i].GetRepresentation() <<
" | ";
257 stringRepresentation <<
"\n";
259 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.
void EnsureCurrentColumnWidth(size_t w)
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.