108 if (w > std::numeric_limits<unsigned short>::max()) {
109 w = std::numeric_limits<unsigned short>::max();
132 size_t collectionSize = collection.size();
133 for (
size_t index = 0; index < collectionSize; ++index) {
134 auto stringEle = collection[index];
155 if (index != collectionSize - 1 &&
fTable.size() <= row) {
183 fTable.push_back(std::vector<DElement_t>(columnNames.size()));
185 for (
auto name = columnNames.begin() + 1;
name != columnNames.end(); ++
name) {
192 size_t totalWidth = 0;
195 for (
size_t i = 0; i <
size; ++i) {
208 std::string DashesStr =
"+";
209 for (
size_t i = 0; i < lastColToPrint; ++i){
210 DashesStr += std::string(
fWidths[i] + 2,
'-');
214 DashesStr +=
"-----+";
243 std::stringstream ss;
245 ss <<
"<table style=\"border: 1px solid black; border-collapse: collapse;\">\n";
246 auto nrRows =
fTable.size();
247 std::string elemType =
"th";
249 for (
size_t rowIndex = 0; rowIndex < nrRows; ++rowIndex) {
250 const auto &row =
fTable[rowIndex];
252 bool isRowSeparator =
253 std::any_of(row[0].GetRepresentation().begin(), row[0].GetRepresentation().end(), ::isdigit);
256 static const char *bgColors[2] = {
"#fff",
"#eee"};
257 bgColorIdx = (bgColorIdx + isRowSeparator) & 1;
258 std::string bgColor = bgColors[bgColorIdx];
260 if (isRowSeparator) {
261 ss <<
" <tr style=\"border-top: 1px dotted; background: " + bgColor +
"\">\n";
263 ss <<
" <tr style=\"background: " + bgColor +
"\">\n";
266 for (
const auto &element : row) {
267 ss <<
" <" + elemType +
" style=\"padding: 1px 4px; border-right: 1px solid\">"
268 << element.GetRepresentation() <<
"</" + elemType +
">\n";
281 std::stringstream ss;
285 bool allColumnsFit =
true;
286 if (
fNColumns > 2u && columnsToShorten > 0u){
290 columnsToPrint =
fNColumns - columnsToShorten;
296 Info(
"Print",
"Only showing %zu columns out of %zu\n", columnsToPrint,
fNColumns);
298 allColumnsFit =
false;
302 Info(
"Print",
"No collections shown since fNMaxCollectionElements is 0\n");
304 auto nrRows =
fTable.size();
306 for (
size_t rowIndex = 0; rowIndex < nrRows; ++rowIndex) {
307 const auto &row =
fTable[rowIndex];
309 std::stringstream stringRow;
310 bool isRowEmpty =
true;
312 if (std::any_of(row[0].GetRepresentation().begin(), row[0].GetRepresentation().end(), ::isdigit)) {
317 for (
size_t columnIndex = 0; columnIndex < columnsToPrint; ++columnIndex) {
318 const auto &element = row[columnIndex];
319 std::string printedElement =
"";
322 if (considerDots && element.IsDot()) {
323 printedElement =
"...";
324 }
else if (!considerDots || element.IsPrint()) {
325 printedElement = element.GetRepresentation();
329 if (!printedElement.empty()) {
334 stringRow << std::left << std::setw(
fWidths[columnIndex]) << std::setfill(
fgSeparator) << printedElement
338 if (!allColumnsFit) {
340 stringRow <<
"... | ";
342 ss << stringRow.str() <<
"\n";
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
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.
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 AsStringHtml() const
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.
VecStr_t fRepresentations
Used by the JITted code to store the string representation of the data.
std::string AsStringMarkdown(bool considerDots) const
void MovePosition()
Moves to the next cell.
std::vector< unsigned short > fWidths
Tracks the maximum width of each column, based on the largest element.
void Print(const RPrintOptions &options={EPrintFormat::kMarkdown}) const
Prints the representation to the standard output.
static constexpr unsigned fgMaxWidth
Maximum width of the table that Print() displays.
std::string AsString(const RPrintOptions &options={EPrintFormat::kMarkdown}) const
Returns the representation as a string.
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::string AsStringInternal(bool considerDots, const RPrintOptions &options={EPrintFormat::kMarkdown}) const
std::vector< std::string > VecStr_t
std::vector< VecStr_t > fCollectionsRepresentations
Used by the JITted code to store the string representation of the data in case of collection.
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.
VecStr_t fTypes
This attribute stores the type of each column. It is needed by the interpreter to print it.
size_t fNColumns
Number of columns to be printed.