Skip to content
Snippets Groups Projects
Commit e903f766 authored by Sergey Linev's avatar Sergey Linev
Browse files

[rdf] fix windows warning about precision lost in RDisplay::fWidth

Here size_t variable converted into unsigned short - windows complains.
Original message:

RDFDisplay.cxx(96): warning C4267: '=': conversion from 'size_t' to
'_Ty', possible loss of data 

RDFDisplay.cxx(117): warning C4267: '=': conversion from 'size_t' to
'_Ty', possible loss of data
parent 7218e9db
No related branches found
No related tags found
No related merge requests found
...@@ -183,6 +183,8 @@ private: ...@@ -183,6 +183,8 @@ private:
/// If the number of required rows has been parsed, returns false. /// If the number of required rows has been parsed, returns false.
bool HasNext() { return fEntries > 0; } bool HasNext() { return fEntries > 0; }
void EnsureCurrentColumnWidth(size_t w);
public: public:
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
/// Creates an RDisplay to print the event values /// Creates an RDisplay to print the event values
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "TInterpreter.h" #include "TInterpreter.h"
#include <iomanip> #include <iomanip>
#include <limits>
namespace ROOT { namespace ROOT {
namespace Internal { namespace Internal {
...@@ -89,12 +90,23 @@ bool RDisplayElement::IsEmpty() const ...@@ -89,12 +90,23 @@ bool RDisplayElement::IsEmpty() const
} // namespace Internal } // namespace Internal
namespace RDF { namespace RDF {
void RDisplay::AddToRow(const std::string &stringEle)
void RDisplay::EnsureCurrentColumnWidth(size_t w)
{ {
// If the current element is wider than the widest element found, update the width // If the current element is wider than the widest element found, update the width
if (fWidths[fCurrentColumn] < stringEle.length()) { if (fWidths[fCurrentColumn] < w) {
fWidths[fCurrentColumn] = stringEle.length(); if (w > std::numeric_limits<unsigned short>::max()) {
w = std::numeric_limits<unsigned short>::max();
}
fWidths[fCurrentColumn] = (unsigned short) w;
} }
}
void RDisplay::AddToRow(const std::string &stringEle)
{
// If the current element is wider than the widest element found, update the width
EnsureCurrentColumnWidth(stringEle.length());
// Save the element... // Save the element...
fTable[fCurrentRow][fCurrentColumn] = DElement_t(stringEle); fTable[fCurrentRow][fCurrentColumn] = DElement_t(stringEle);
...@@ -113,18 +125,14 @@ void RDisplay::AddCollectionToRow(const std::vector<std::string> &collection) ...@@ -113,18 +125,14 @@ void RDisplay::AddCollectionToRow(const std::vector<std::string> &collection)
auto element = DElement_t(stringEle); auto element = DElement_t(stringEle);
// Update the width if this element is the biggest found // Update the width if this element is the biggest found
if (fWidths[fCurrentColumn] < stringEle.length()) { EnsureCurrentColumnWidth(stringEle.length());
fWidths[fCurrentColumn] = stringEle.length();
}
if (index == 0 || index == collectionSize - 1) { if (index == 0 || index == collectionSize - 1) {
// Do nothing, by default DisplayElement is printed // Do nothing, by default DisplayElement is printed
} else if (index == 1) { } else if (index == 1) {
element.SetDots(); element.SetDots();
// Be sure the "..." fit // Be sure the "..." fit
if (fWidths[fCurrentColumn] < 3) { EnsureCurrentColumnWidth(3);
fWidths[fCurrentColumn] = 3;
}
} else { } else {
// In the Print(), after the dots, all element will just be ignored except the last one. // In the Print(), after the dots, all element will just be ignored except the last one.
element.SetIgnore(); element.SetIgnore();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment