12#ifndef ROOT_StringConv
13#define ROOT_StringConv
18#include "RConfigure.h"
37template <
typename value_type>
44 static const char *
const suffix[][2] =
53 value_type unit = si ? 1000 : 1024;
61 }
else if (
bytes > 0) {
62 exp = std::min( (
int) (std::log(
bytes) / std::log(unit)),
63 (
int) (
sizeof(suffix) /
sizeof(suffix[0]) - 1));
65 *coeff =
bytes / std::pow(unit, exp);
66 *units = suffix[exp][!si];
89 size_t cur,
size = str.size();
91 const double coeff = stod(std::string(str.data(), str.size()), &cur);
94 while (cur<
size && isspace(str[cur])) ++cur;
97 int exp = 0, unit = 1000;
100 double v = exp ? coeff * std::pow(unit, exp / 3) : coeff;
101 if (
v < (
double) std::numeric_limits<T>::max()) {
110 switch (toupper(str[cur])) {
111 case 'B': exp = 0;
break;
112 case 'K': exp = 3;
break;
113 case 'M': exp = 6;
break;
114 case 'G': exp = 9;
break;
115 case 'T': exp = 12;
break;
116 case 'E': exp = 15;
break;
117 case 'Z': exp = 18;
break;
118 case 'Y': exp = 21;
break;
125 if (cur<
size && toupper(str[cur]) ==
'I') {
133 switch (toupper(str[cur])) {
136 case '\t': ++cur;
break;
138 case '\0':
return result();
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t bytes
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
void ToHumanReadableSize(value_type bytes, Bool_t si, Double_t *coeff, const char **units)
Return the size expressed in 'human readable' format.
EFromHumanReadableSize FromHumanReadableSize(std::string_view str, T &value)
Convert strings like the following into byte counts 5MB, 5 MB, 5M, 3.7GB, 123b, 456kB,...