111 for (
size_t index = 0; index < collectionSize; ++index) {
120 if (index == 0 || index == collectionSize - 1) {
122 }
else if (index == 1) {
137 if (index != collectionSize - 1 &&
fTable.size() <= row) {
163 if (TInterpreter::EErrorCode::kNoError != errorCode) {
164 std::string msg =
"Cannot jit during Display call. Interpreter error code is " + std::to_string(errorCode) +
".";
165 throw std::runtime_error(msg);
170 : fTypes(types), fWidths(columnNames.size(), 0), fRepresentations(columnNames.size()),
171 fCollectionsRepresentations(columnNames.size()), fNColumns(columnNames.size()), fEntries(entries)
175 fTable.push_back(std::vector<DElement_t>(columnNames.size()));
176 for (
auto name : columnNames) {
183 size_t totalWidth = 0;
186 for (
size_t i = 0; i < size; ++i) {
198 auto columnsToPrint =
200 std::vector<bool> hasPrintedNext(
fNColumns,
203 auto nrRows =
fTable.size();
204 for (
size_t rowIndex = 0; rowIndex < nrRows; ++rowIndex) {
205 auto &row =
fTable[rowIndex];
207 std::stringstream stringRow;
208 bool isRowEmpty =
true;
210 for (
size_t columnIndex = 0; columnIndex < columnsToPrint; ++columnIndex) {
211 const auto &element = row[columnIndex];
212 std::string printedElement =
"";
214 if (element.IsDot()) {
215 printedElement =
"...";
216 }
else if (element.IsPrint()) {
218 if (!hasPrintedNext[columnIndex]) {
219 printedElement = element.GetRepresentation();
221 hasPrintedNext[columnIndex] =
226 if (!hasPrintedNext[columnIndex]) {
227 size_t i = rowIndex + 1;
228 for (; !
fTable[i][columnIndex].IsPrint(); ++i) {
231 printedElement =
fTable[i][columnIndex].GetRepresentation();
232 hasPrintedNext[columnIndex] =
true;
235 if (!printedElement.empty()) {
240 stringRow << std::left << std::setw(
fWidths[columnIndex]) << std::setfill(
fgSeparator) << printedElement
244 std::cout << stringRow.str() << std::endl;
253 std::stringstream stringRepresentation;
255 for (
size_t i = 0; i < row.size(); ++i) {
256 stringRepresentation << std::left << std::setw(
fWidths[i]) << std::setfill(
fgSeparator)
257 << row[i].GetRepresentation() <<
" | ";
259 stringRepresentation <<
"\n";
261 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 CallInterpreter(const std::string &code)
Feed a piece of code to cling and handle errors.
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.