109 if (
w > std::numeric_limits<unsigned short>::max()) {
110 w = std::numeric_limits<unsigned short>::max();
133 size_t collectionSize = collection.size();
135 auto stringEle = collection[
index];
156 if (
index != collectionSize - 1 &&
fTable.size() <= row) {
179 : fTypes(types), fWidths(columnNames.
size(), 0), fRepresentations(columnNames.
size()),
180 fCollectionsRepresentations(columnNames.
size()), fNColumns(columnNames.
size()),
181 fNMaxCollectionElements(nMaxCollectionElements)
184 fTable.push_back(std::vector<DElement_t>(columnNames.size()));
186 for (
auto name = columnNames.begin() + 1;
name != columnNames.end(); ++
name) {
193 size_t totalWidth = 0;
196 for (
size_t i = 0; i <
size; ++i) {
209 std::string DashesStr =
"+";
210 for (
size_t i = 0; i < lastColToPrint; ++i){
211 DashesStr += std::string(
fWidths[i] + 2,
'-');
215 DashesStr +=
"-----+";
225 bool allColumnsFit =
true;
226 if (
fNColumns > 2u && columnsToShorten > 0u){
230 columnsToPrint =
fNColumns - columnsToShorten;
235 Info(
"Print",
"Only showing %lu columns out of %lu\n", columnsToPrint,
fNColumns);
236 allColumnsFit =
false;
242 auto nrRows =
fTable.size();
244 for (
size_t rowIndex = 0; rowIndex < nrRows; ++rowIndex) {
245 auto &row =
fTable[rowIndex];
247 std::stringstream stringRow;
248 bool isRowEmpty =
true;
250 if (std::any_of(row[0].GetRepresentation().begin(), row[0].GetRepresentation().end(), ::isdigit)){
255 for (
size_t columnIndex = 0; columnIndex < columnsToPrint; ++columnIndex) {
256 const auto &element = row[columnIndex];
257 std::string printedElement =
"";
259 if (element.IsDot()) {
260 printedElement =
"...";
261 }
else if (element.IsPrint()) {
262 printedElement = element.GetRepresentation();
266 if (!printedElement.empty()) {
271 stringRow << std::left << std::setw(
fWidths[columnIndex]) << std::setfill(
fgSeparator) << printedElement
277 stringRow <<
"... | ";
279 std::cout << stringRow.str() << std::endl;
289 std::stringstream stringRepresentation;
293 if (std::any_of(row[0].GetRepresentation().begin(), row[0].GetRepresentation().end(), ::isdigit)){
296 stringRepresentation <<
"| ";
297 for (
size_t i = 0; i < row.size(); ++i) {
298 stringRepresentation << std::left << std::setw(
fWidths[i]) << std::setfill(
fgSeparator)
299 << row[i].GetRepresentation() <<
" | ";
301 stringRepresentation <<
"\n";
304 return stringRepresentation.str();
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
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
RDisplay(const VecStr_t &columnNames, const VecStr_t &types, size_t nMaxCollectionElements)
Creates an RDisplay to print the event values.
size_t fNMaxCollectionElements
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
Maximum width of the table that Print() displays.
void EnsureCurrentColumnWidth(size_t w)
size_t fNextRow
Next row to be filled.
std::string DashesBetweenLines(size_t lastColToPrint, bool allColumnsFit) const
Generate dashes between entries in Print() and AsString() Methods.
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.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.