94void RDisplay::EnsureCurrentColumnWidth(
size_t w)
98 if (w > std::numeric_limits<unsigned short>::max()) {
99 w = std::numeric_limits<unsigned short>::max();
105void RDisplay::AddToRow(
const std::string &stringEle)
117void RDisplay::AddCollectionToRow(
const std::vector<std::string> &collection)
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) {
155void RDisplay::MovePosition()
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) {
179size_t RDisplay::GetNColumnsToShorten()
const
181 size_t totalWidth = 0;
184 for (
size_t i = 0; i < size; ++i) {
194void RDisplay::Print()
const
196 auto columnsToPrint =
198 std::vector<bool> hasPrintedNext(
fNColumns,
203 Info(
"Print",
"Only showing %lu columns out of %lu\n", columnsToPrint,
fNColumns);
205 auto nrRows =
fTable.size();
206 for (
size_t rowIndex = 0; rowIndex < nrRows; ++rowIndex) {
207 auto &row =
fTable[rowIndex];
209 std::stringstream stringRow;
210 bool isRowEmpty =
true;
212 for (
size_t columnIndex = 0; columnIndex < columnsToPrint; ++columnIndex) {
213 const auto &element = row[columnIndex];
214 std::string printedElement =
"";
216 if (element.IsDot()) {
217 printedElement =
"...";
218 }
else if (element.IsPrint()) {
220 if (!hasPrintedNext[columnIndex]) {
221 printedElement = element.GetRepresentation();
223 hasPrintedNext[columnIndex] =
228 if (!hasPrintedNext[columnIndex]) {
229 size_t i = rowIndex + 1;
230 for (; !
fTable[i][columnIndex].IsPrint(); ++i) {
233 printedElement =
fTable[i][columnIndex].GetRepresentation();
234 hasPrintedNext[columnIndex] =
true;
237 if (!printedElement.empty()) {
242 stringRow << std::left << std::setw(
fWidths[columnIndex]) << std::setfill(
fgSeparator) << printedElement
246 std::cout << stringRow.str() << std::endl;
251std::string RDisplay::AsString()
const
255 std::stringstream stringRepresentation;
257 for (
size_t i = 0; i < row.size(); ++i) {
258 stringRepresentation << std::left << std::setw(
fWidths[i]) << std::setfill(
fgSeparator)
259 << row[i].GetRepresentation() <<
" | ";
261 stringRepresentation <<
"\n";
263 return stringRepresentation.str();
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
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.
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.
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
void EnsureCurrentColumnWidth(size_t w)
size_t fNextRow
Next row to be filled.
std::vector< std::string > VecStr_t
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.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...