69 #ifdef R__VISUAL_CPLUSPLUS 70 #define FLong64 "%I64d" 71 #define FULong64 "%I64u" 73 #define FLong64 "%lld" 74 #define FULong64 "%llu" 88 class TArrayIndexProducer {
112 Bool_t usearraylen = (arraylen > (isloop ? 0 : 1));
114 if (usearrayindx && (arraylen > 0)) {
119 printf(
"Problem with JSON coding of element %s type %d \n", elem->
GetName(), elem->
GetType());
128 fIsArray = fTotalLen>1;
131 fTotalLen = arraylen;
133 fMaxIndex[0] = arraylen;
143 TArrayIndexProducer(
TDataMember* member,
Int_t extradim,
const char* separ) :
153 if (extradim > 0) ndim++;
166 fMaxIndex[ndim-1] = extradim;
167 fTotalLen *= extradim;
170 fIsArray = fTotalLen>1;
173 Int_t ReduceDimension()
177 if (fMaxIndex.
GetSize() == 0)
return 0;
179 Int_t len = fMaxIndex[ndim];
182 fTotalLen = fTotalLen/len;
183 fIsArray = fTotalLen>1;
196 return !IsArray() || (fCnt >= fTotalLen);
199 const char* GetBegin()
216 const char* NextSeparator()
220 if (++fCnt >= fTotalLen)
return GetEnd();
227 while ((cnt >= 0) && (cnt < fIndicies.
GetSize())) {
228 if (fIndicies[cnt] >= fMaxIndex[cnt]) {
230 fIndicies[cnt--] = 0;
231 if (cnt >= 0) fIndicies[
cnt]++;
234 fRes.
Append(fIndicies[cnt] == 0 ?
"[" : fSepar);
247 class TJSONStackObj :
public TObject {
258 TArrayIndexProducer *fIndx;
276 virtual ~TJSONStackObj()
278 if (fIsElemOwner)
delete fElem;
279 if (fIndx)
delete fIndx;
282 Bool_t IsStreamerInfo()
const 284 return fIsStreamerInfo;
286 Bool_t IsStreamerElement()
const 288 return !fIsStreamerInfo && (fElem != 0);
328 char* loc = setlocale(LC_NUMERIC, 0);
329 if ((loc!=0) && (strcmp(loc,
"C")!=0)) {
331 setlocale(LC_NUMERIC,
"C");
365 void *ptr = (
void *) obj;
416 Int_t compact,
const char *member_name)
418 if ((member_name!=0) && (obj!=0)) {
423 while ((rdata = dynamic_cast<TRealData*>(iter())) != 0) {
425 if (member && strcmp(member->
GetName(), member_name)==0)
break;
428 if (member==0)
return TString();
435 arraylen = *((
int *) ((
char *) obj + idata->
GetThisOffset()));
440 if (member->
IsaPointer()) ptr = *((
char **) ptr);
463 if ((ptr == 0) || (member == 0))
return TString(
"null");
471 if ((mcl != 0) && (mcl !=
TString::Class()) && !stlstring && !isstl &&
489 if (!obj || !filename || (*filename==0))
return 0;
491 Int_t compact = strstr(filename,
".json.gz") ? 3 : 0;
492 if (option && (*option >=
'0') && (*option <=
'3')) compact =
TString(option).
Atoi();
496 std::ofstream ofs(filename);
498 if (strstr(filename,
".json.gz")) {
499 const char *objbuf = json.
Data();
502 unsigned long objcrc = R__crc32(0, NULL, 0);
503 objcrc = R__crc32(objcrc, (
const unsigned char *) objbuf, objlen);
506 Int_t buflen = 10 + objlen + 8;
507 if (buflen < 512) buflen = 512;
509 char *buffer = (
char *)
malloc(buflen);
510 if (buffer == 0)
return 0;
512 char *bufcur = buffer;
528 memcpy(dummy, bufcur - 6, 6);
531 unsigned long ziplen = R__memcompress(bufcur - 6, objlen + 6, (
char *) objbuf, objlen);
533 memcpy(bufcur - 6, dummy, 6);
535 bufcur += (ziplen - 6);
537 *bufcur++ = objcrc & 0xff;
538 *bufcur++ = (objcrc >> 8) & 0xff;
539 *bufcur++ = (objcrc >> 16) & 0xff;
540 *bufcur++ = (objcrc >> 24) & 0xff;
542 *bufcur++ = objlen & 0xff;
543 *bufcur++ = (objlen >> 8) & 0xff;
544 *bufcur++ = (objlen >> 16) & 0xff;
545 *bufcur++ = (objlen >> 24) & 0xff;
547 ofs.write(buffer, bufcur - buffer);
565 if (!obj || !cl || !filename || (*filename==0))
return 0;
567 Int_t compact = strstr(filename,
".json.gz") ? 3 : 0;
568 if (option && (*option >=
'0') && (*option <=
'3')) compact =
TString(option).
Atoi();
572 std::ofstream ofs (filename);
574 if (strstr(filename,
".json.gz")) {
575 const char *objbuf = json.
Data();
578 unsigned long objcrc = R__crc32(0, NULL, 0);
579 objcrc = R__crc32(objcrc, (
const unsigned char *) objbuf, objlen);
582 Int_t buflen = 10 + objlen + 8;
583 if (buflen < 512) buflen = 512;
585 char *buffer = (
char *)
malloc(buflen);
586 if (buffer == 0)
return 0;
588 char *bufcur = buffer;
604 memcpy(dummy, bufcur - 6, 6);
607 unsigned long ziplen = R__memcompress(bufcur - 6, objlen + 6, (
char *) objbuf, objlen);
609 memcpy(bufcur - 6, dummy, 6);
611 bufcur += (ziplen - 6);
613 *bufcur++ = objcrc & 0xff;
614 *bufcur++ = (objcrc >> 8) & 0xff;
615 *bufcur++ = (objcrc >> 16) & 0xff;
616 *bufcur++ = (objcrc >> 24) & 0xff;
618 *bufcur++ = objlen & 0xff;
619 *bufcur++ = (objlen >> 8) & 0xff;
620 *bufcur++ = (objlen >> 16) & 0xff;
621 *bufcur++ = (objlen >> 24) & 0xff;
623 ofs.write(buffer, bufcur - buffer);
642 if (member == 0)
return "null";
645 Info(
"JsonWriteMember",
"Write member %s type %s ndim %d",
652 if (ptr==0)
return (tid ==
kCharStar) ?
"\"\"" :
"null";
663 if (indx.IsArray() && (tid==
kChar_t))
664 shift = indx.ReduceDimension();
666 char* ppp = (
char*) ptr;
744 }
while (!indx.IsDone());
756 ((
TClass *)memberClass)->Streamer((
void *)ptr, *
this);
764 if ((arr != 0) && (arr->
GetSize() > 0)) {
765 arr->Streamer(*
this);
768 Warning(
"TBufferJSON",
"When streaming TArray, more than 1 object in the stack, use second item");
773 }
else if (memberClass && !strcmp(memberClass->
GetName(),
"string")) {
775 ((
TClass *)memberClass)->Streamer((
void *)ptr, *
this);
781 if ((memberClass == 0) || (member->
GetArrayDim() > 0) || (arraylen > 0))
return "<not supported>";
792 if (obj == 0)
return kTRUE;
802 if (ptr == 0)
return kTRUE;
815 Info(
"WriteObject",
"Object %p", obj);
825 TJSONStackObj *curr =
Stack();
826 TJSONStackObj *stack =
new TJSONStackObj();
827 stack->fLevel = (curr ? curr->fLevel : 0) + inclevel;
843 return dynamic_cast<TJSONStackObj *
>(
fStack.
Last());
851 TJSONStackObj *stack = 0;
867 if (strlen(line1) > 0) {
869 TJSONStackObj *stack =
Stack();
870 if ((stack != 0) && (stack->fLevel > 0))
882 const char *elem_name = 0;
884 if (base_class == 0) {
889 elem_name =
"fVector";
895 elem_name =
"fForwardlist";
898 elem_name =
"fDeque";
904 elem_name =
"fMultiMap";
910 elem_name =
"fMultiSet";
913 elem_name =
"fUnorderedSet";
916 elem_name =
"fUnorderedMultiSet";
919 elem_name =
"fUnorderedMap";
922 elem_name =
"fUnorderedMultiMap";
925 elem_name =
"fBitSet";
928 elem_name =
"fArray";
932 elem_name =
"fString";
937 if (elem_name != 0) {
949 TJSONStackObj *stack =
Stack();
950 if (stack != 0) stack->fIsPostProcessed =
kTRUE;
959 if (cl == 0)
return 0;
963 if (isarray)
return 100;
974 if (isstlcont > 0)
return isstlcont;
977 if (isstd && !strcmp(cl->
GetName(),
"string"))
return 120;
996 Info(
"JsonWriteObject",
"Object %p class %s check_map %s", obj, cl ? cl->
GetName() :
"null", check_map ?
"true" :
"false");
1000 TString fObjectOutput, *fPrevOutput(0);
1002 TJSONStackObj *stack =
Stack();
1004 if (stack && stack->fAccObjects && ((
fValue.
Length() > 0) || (stack->fValues.GetLast() >= 0))) {
1015 }
else if ((special_kind <= 0) || (special_kind > 100)) {
1025 if (special_kind <= 0) {
1028 std::map<const void *, unsigned>::const_iterator iter =
fJsonrMap.find(obj);
1054 Info(
"JsonWriteObject",
"Starting object %p write for class: %s",
1057 stack->fAccObjects = special_kind < 10;
1059 if (special_kind == -130)
1062 ((
TClass *)cl)->Streamer((
void *)obj, *
this);
1065 Info(
"JsonWriteObject",
"Done object %p write for class: %s",
1068 if (special_kind == 100) {
1069 if (stack->fValues.GetLast() != 0)
1070 Error(
"JsonWriteObject",
"Problem when writing array");
1071 stack->fValues.Delete();
1072 }
else if ((special_kind == 110) || (special_kind == 120)) {
1073 if (stack->fValues.GetLast() > 1)
1074 Error(
"JsonWriteObject",
"Problem when writing TString or std::string");
1075 stack->fValues.Delete();
1081 if (stack->fValues.GetLast() < 0) {
1083 if (
fValue !=
"0")
Error(
"JsonWriteObject",
"With empty stack fValue!=0");
1087 Int_t size =
TString(stack->fValues.At(0)->GetName()).Atoi();
1089 if ((stack->fValues.GetLast() == 0) && ((size > 1) || (
fValue.
Index(
"[") == 0))) {
1091 stack->fValues.Delete();
1093 Error(
"JsonWriteObject",
"Empty value when it should contain something");
1098 const char *separ =
"[";
1105 if ((size * 2 == stack->fValues.GetLast()) &&
1112 if (pairtype.
Index(
"multimap<") == 0)
1113 pairtype.
Replace(0, 9,
"pair<");
1114 else if (pairtype.
Index(
"map<") == 0)
1115 pairtype.
Replace(0, 4,
"pair<");
1119 for (
Int_t k = 1; k < stack->fValues.GetLast(); k += 2) {
1139 for (
Int_t k = 1; k <= stack->fValues.GetLast(); k++) {
1147 stack->fValues.Delete();
1155 if ((special_kind == 0) &&
1156 ((stack->fValues.GetLast() >= 0) || (
fValue.
Length() > 0))) {
1158 Info(
"JsonWriteObject",
"Create blob value for class %s", cl->
GetName());
1163 const char *separ =
"[";
1165 for (
Int_t k = 0; k <= stack->fValues.GetLast(); k++) {
1179 stack->fValues.Delete();
1184 if (special_kind <= 0) {
1190 if (fPrevOutput != 0) {
1193 if ((special_kind <= 0) || (special_kind > 100))
1195 else if (fObjectOutput.
Length() != 0)
1196 Error(
"JsonWriteObject",
"Non-empty object output for special class %s", cl->
GetName());
1220 if (islist) { sopt.
Capacity(500); sopt =
"["; }
1225 while ((obj = iter()) != 0) {
1287 if (sinfo != 0) cl = sinfo->
GetClass();
1289 if (cl == 0)
return;
1293 TJSONStackObj *stack =
Stack();
1295 if ((stack != 0) && stack->IsStreamerElement() && !stack->fIsObjStarted &&
1299 stack->fIsObjStarted =
kTRUE;
1313 stack->fInfo = sinfo;
1314 stack->fIsStreamerInfo =
kTRUE;
1324 Info(
"DecrementLevel",
"Class: %s",
1327 TJSONStackObj *stack =
Stack();
1329 if (stack->IsStreamerElement()) {
1331 Info(
"DecrementLevel",
" Perform post-processing elem: %s",
1332 stack->fElem->GetName());
1340 Error(
"DecrementLevel",
" Mismatch of streamer info");
1345 Info(
"DecrementLevel",
"Class: %s done",
1357 Info(
"SetStreamerElementNumber",
"Element name %s", elem->
GetName());
1369 TJSONStackObj *stack =
Stack();
1371 Error(
"WorkWithElement",
"stack is empty");
1376 Info(
"WorkWithElement",
" Start element %s type %d typename %s",
1379 if (stack->IsStreamerElement()) {
1383 Info(
"WorkWithElement",
" Perform post-processing elem: %s",
1384 stack->fElem->GetName());
1394 Error(
"WorkWithElement",
"Lost of stack");
1399 if (!stack->IsStreamerInfo()) {
1400 Error(
"WorkWithElement",
"Problem in Inc/Dec level");
1407 Error(
"WorkWithElement",
"streamer info returns elem = 0");
1415 stack->fIsElemOwner = (number < 0);
1490 if (typeName == 0) typeName =
name;
1492 if ((name == 0) || (strlen(name) == 0)) {
1493 Error(
"ClassMember",
"Invalid member name");
1501 if (strcmp(typeName,
"raw:data") == 0)
1512 if (strcmp(name, typeName) == 0) {
1519 if (tname[tname.
Length() - 1] ==
'*') {
1525 Error(
"ClassMember",
"Invalid class specifier %s", typeName);
1549 }
else if ((typ_id > 0) && (typ_id < 20)) {
1566 Error(
"ClassMember",
"Invalid combination name = %s type = %s",
1587 if (stack->fIsPostProcessed)
return;
1591 if (!elem && !obj_cl)
return;
1593 stack->fIsPostProcessed =
kTRUE;
1596 if (stack->fIsObjStarted) {
1613 isTArray = (strncmp(
"TArray", typname, 6) == 0);
1616 if (isTString || isSTLstring) {
1620 Info(
"PerformPostProcessing",
"reformat string value = '%s'",
fValue.
Data());
1622 stack->fValues.Delete();
1623 }
else if (isOffsetPArray) {
1626 if ((stack->fValues.GetLast() < 0) && (
fValue ==
"0")) {
1628 }
else if ((stack->fValues.GetLast() == 0) &&
1629 (strcmp(stack->fValues.Last()->GetName(),
"1") == 0)) {
1630 stack->fValues.Delete();
1632 Error(
"PerformPostProcessing",
"Wrong values for kOffsetP element %s",
1633 (elem ? elem->
GetName() :
"---"));
1634 stack->fValues.Delete();
1637 }
else if (isTObject || isTRef) {
1642 Int_t cnt = stack->fValues.GetLast()+1;
1645 if (cnt<2 || cnt>3) {
1647 Error(
"PerformPostProcessing",
"When storing TObject/TRef, strange number of items %d", cnt);
1663 stack->fValues.Delete();
1668 }
else if (isTArray) {
1670 stack->fValues.Delete();
1678 if (stack->fValues.GetLast() >= 0) {
1681 for (
Int_t n = 0;
n <= stack->fValues.GetLast();
n++) {
1694 if (stack->fValues.GetLast() >= 0)
1753 if (start) *start = 0;
1754 if (bcnt) *bcnt = 0;
1756 if (
gDebug > 3)
Info(
"ReadVersion",
"Version = %d", res);
1788 const TClass *actualClass,
1792 Info(
"WriteObjectClass",
"Class %s", (actualClass ? actualClass->
GetName() :
" null"));
1797 #define TJSONPushValue() \ 1798 if (fValue.Length() > 0) Stack()->PushValue(fValue); 1802 #define TBufferJSON_ReadArray(tname, vname) \ 1804 if (!vname) return 0; \ 2005 #define TBufferJSON_ReadStaticArray(vname) \ 2007 if (!vname) return 0; \ 2134 #define TBufferJSON_ReadFastArray(vname) \ 2136 if (n <= 0) return; \ 2137 if (!vname) return; \ 2325 #define TJSONWriteArrayCompress(vname, arrsize, typname) \ 2327 if ((fCompact < 10) || (arrsize < 6)) { \ 2328 fValue.Append("["); \ 2329 for (Int_t indx=0;indx<arrsize;indx++) { \ 2330 if (indx>0) fValue.Append(fArraySepar.Data()); \ 2331 JsonWriteBasic(vname[indx]); \ 2333 fValue.Append("]"); \ 2335 fValue.Append("{"); \ 2336 fValue.Append(TString::Format("\"$arr\":\"%s\"%s\"len\":%d",typname,fArraySepar.Data(),arrsize)); \ 2337 Int_t aindx(0), bindx(arrsize); \ 2338 while ((aindx<arrsize) && (vname[aindx]==0)) aindx++; \ 2339 while ((aindx<bindx) && (vname[bindx-1]==0)) bindx--; \ 2340 if (aindx<bindx) { \ 2341 TString suffix(""); \ 2342 Int_t p(aindx), suffixcnt(-1), lastp(0); \ 2344 if (vname[p]==0) { p++; continue; } \ 2345 Int_t p0(p++), pp(0), nsame(1); \ 2346 if (fCompact < 20) { pp = bindx; p = bindx+1; nsame = 0; } \ 2347 for(;p<=bindx;++p) { \ 2348 if ((p<bindx) && (vname[p]==vname[p-1])) { nsame++; continue; } \ 2349 if (vname[p-1]==0) { \ 2350 if (nsame>9) { nsame = 0; break; } \ 2353 if (pp) { p = pp; nsame = 0; } else pp = p; \ 2356 pp = p; nsame = 1; \ 2358 if (pp<=p0) continue; \ 2359 if (++suffixcnt > 0) suffix.Form("%d",suffixcnt); \ 2360 if (p0!=lastp) fValue.Append(TString::Format("%s\"p%s\":%d", fArraySepar.Data(), suffix.Data(), p0)); \ 2362 fValue.Append(TString::Format("%s\"v%s\":", fArraySepar.Data(), suffix.Data())); \ 2363 if ((nsame > 1) || (pp-p0 == 1)) { \ 2364 JsonWriteBasic(vname[p0]); \ 2365 if (nsame>1) fValue.Append(TString::Format("%s\"n%s\":%d", fArraySepar.Data(), suffix.Data(), nsame)); \ 2367 fValue.Append("["); \ 2368 for (Int_t indx=p0;indx<pp;indx++) { \ 2369 if (indx>p0) fValue.Append(fArraySepar.Data()); \ 2370 JsonWriteBasic(vname[indx]); \ 2372 fValue.Append("]"); \ 2376 fValue.Append("}"); \ 2381 #define TJSONWriteConstChar(vname,arrsize,typname) \ 2383 JsonWriteConstChar(vname, arrsize); \ 2388 #define TBufferJSON_WriteArray(vname, typname) \ 2391 TJSONWriteArrayCompress(vname, n, typname); \ 2521 #define TBufferJSON_WriteFastArray(vname,method,typname) \ 2524 if (n <= 0) { fValue.Append("[]"); return; } \ 2525 TStreamerElement* elem = Stack(0)->fElem; \ 2526 if ((elem!=0) && (elem->GetArrayDim()>1) && (elem->GetArrayLength()==n)) { \ 2527 TArrayI indexes(elem->GetArrayDim() - 1); \ 2529 Int_t cnt = 0, shift = 0, len = elem->GetMaxIndex(indexes.GetSize()); \ 2530 while (cnt >= 0) { \ 2531 if (indexes[cnt] >= elem->GetMaxIndex(cnt)) { \ 2532 fValue.Append("]"); \ 2533 indexes[cnt--] = 0; \ 2534 if (cnt >= 0) indexes[cnt]++; \ 2537 fValue.Append(indexes[cnt] == 0 ? "[" : fArraySepar.Data()); \ 2538 if (++cnt == indexes.GetSize()) { \ 2539 method((vname+shift), len, typname); \ 2545 method(vname, n, typname); \ 2687 Info(
"WriteFastArray",
"void *start cl %s n %d streamer %p",
2688 cl ? cl->
GetName() :
"---",
n, streamer);
2692 (*streamer)(*
this, start, 0);
2702 char *obj = (
char *)start;
2704 int size = cl->
Size();
2708 if (indexes.IsArray()) {
2713 for (
Int_t j = 0; j <
n; j++, obj += size) {
2725 if (indexes.IsArray())
2729 if (
Stack(0)->fIndx)
2740 Info(
"WriteFastArray",
"void **startp cl %s n %d streamer %p",
2745 (*streamer)(*
this, (
void *)start, 0);
2755 if (indexes.IsArray()) {
2760 for (
Int_t j = 0; j <
n; j++) {
2767 if (!start[j]) start[j] = ((
TClass *)cl)->New();
2778 if (indexes.IsArray())
2781 if (
Stack(0)->fIndx)
2819 Info(
"StreamObject",
"Class: %s", (cl ? cl->
GetName() :
"none"));
3121 snprintf(buf,
sizeof(buf),
"%d", value);
3131 snprintf(buf,
sizeof(buf),
"%hd", value);
3141 snprintf(buf,
sizeof(buf),
"%d", value);
3151 snprintf(buf,
sizeof(buf),
"%ld", value);
3175 char* pnt = 0, *
exp = 0, *lastdecimal = 0, *
s = sbuf;
3176 bool negative_exp =
false;
3178 while(*
s && --len) {
3180 case '.': pnt =
s;
break;
3182 case 'e':
exp =
s;
break;
3183 case '-':
if (
exp) negative_exp =
true;
break;
3186 if ((*
s <
'0') || (*
s >
'9'))
return;
3187 if (
exp) power = power*10 + (*
s -
'0');
else 3188 if (pnt && *
s!=
'0') lastdecimal =
s;
3198 if (lastdecimal) *(lastdecimal+1) = 0;
3203 if (lastdecimal) *(lastdecimal+1) = 0;
else 3206 if (!negative_exp && pnt &&
exp && (
exp-pnt > power)) {
3209 for (
int cnt=0;cnt<power;++
cnt) {
3214 if (lastdecimal && (pnt<lastdecimal)) *(lastdecimal+1) = 0;
3217 if (negative_exp && pnt &&
exp && (power < (
s-
exp))) {
3219 if (!lastdecimal) lastdecimal = pnt;
3220 *(lastdecimal+1) = 0;
3224 for (
char* pos = lastdecimal+1; pos>=pnt; --pos)
3225 *(pos+power) = *pos;
3228 for (
int cnt=1;cnt<power;++
cnt)
3233 if (lastdecimal) pnt = lastdecimal+1;
3236 if (*
exp==
'+') ++
exp;
else 3237 if (*
exp==
'-') *pnt++ = *
exp++;
3240 while (*
exp) *pnt++ = *
exp++;
3253 if ((value == std::nearbyint(value)) && (std::abs(value) < 1e15)) {
3254 snprintf(buf,
sizeof(buf),
"%1.0f", value);
3270 if ((value == std::nearbyint(value)) && (std::abs(value) < 1e25)) {
3271 snprintf(buf,
sizeof(buf),
"%1.0f", value);
3293 snprintf(buf,
sizeof(buf),
"%u", value);
3303 snprintf(buf,
sizeof(buf),
"%hu", value);
3313 snprintf(buf,
sizeof(buf),
"%u", value);
3323 snprintf(buf,
sizeof(buf),
"%lu", value);
3350 if (len<0) len = strlen(value);
3381 if ((c > 31) && (c < 127))
3399 if (fmt == 0) fmt =
"%e";
3418 if (fmt == 0) fmt =
"%.14e";
3442 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3443 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3444 iter != end; ++iter) {
3447 (*iter).PrintDebug(*
this, obj);
3448 (*iter)(*
this, obj);
3452 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3453 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3454 iter != end; ++iter) {
3457 (*iter)(*
this, obj);
3469 void *start_collection,
void *end_collection)
3476 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3477 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3478 iter != end; ++iter) {
3481 (*iter).PrintDebug(*
this, *(
char **)start_collection);
3482 (*iter)(*
this, start_collection, end_collection);
3486 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3487 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3488 iter != end; ++iter) {
3491 (*iter)(*
this, start_collection, end_collection);
3502 void *start_collection,
void *end_collection)
3513 void *arr0 = loopconfig->
GetFirstAddress(start_collection, end_collection);
3515 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3516 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3517 iter != end; ++iter) {
3520 (*iter).PrintDebug(*
this, arr0);
3521 (*iter)(*
this, start_collection, end_collection, loopconfig);
3525 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3526 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3527 iter != end; ++iter) {
3530 (*iter)(*
this, start_collection, end_collection, loopconfig);
3543 Info(
"WriteClones",
"Not yet tested");
3552 struct DynamicType {
3556 virtual ~DynamicType() {}
3584 Error(
"WriteObjectAny",
"ptrClass argument may not be 0");
3590 if (clActual == 0) {
3594 DynamicType *d_ptr = (DynamicType *)obj;
3596 "An object of type %s (from type_info) passed through a %s pointer was truncated (due a missing dictionary)!!!",
3597 typeid(*d_ptr).name(), ptrClass->
GetName());
3600 }
else if (clActual && (clActual != ptrClass)) {
3601 const char *temp = (
const char *) obj;
3626 sinfo = (
TStreamerInfo *)const_cast<TClass *>(cl)->GetCurrentStreamerInfo();
3628 const_cast<TClass *
>(cl)->BuildRealData(pointer);
3630 const_cast<TClass *
>(cl)->SetCurrentStreamerInfo(sinfo);
3631 const_cast<TClass *
>(cl)->RegisterStreamerInfo(sinfo);
3633 printf(
"Creating StreamerInfo for class: %s, version: %d\n",
3641 const_cast<TClass *
>(cl)->BuildRealData(pointer);
Abstract array base class.
Describe Streamer information for one class version.
virtual const char * GetName() const
Returns name of object.
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)
Ignored in TBufferJSON.
TString JsonWriteMember(const void *ptr, TDataMember *member, TClass *memberClass, Int_t arraylen)
Convert single data member to JSON structures Returns string with converted member.
virtual void WriteUChar(UChar_t c)
Writes UChar_t value to buffer.
virtual void WriteArrayFloat16(const Float_t *f, Int_t n, TStreamerElement *ele=0)
Write array of Float16_t to buffer.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
virtual Int_t WriteClones(TClonesArray *a, Int_t nobjects)
Interface to TStreamerInfo::WriteBufferClones.
virtual TClass * ReadClass(const TClass *cl=0, UInt_t *objTag=0)
suppressed function of TBuffer
virtual Int_t ReadStaticArray(Bool_t *b)
Read array of Bool_t from buffer.
ActionContainer_t fActions
virtual Int_t ReadArray(Bool_t *&b)
Read array of Bool_t from buffer.
void JsonDisablePostprocessing()
virtual void ReadShort(Short_t &s)
Reads Short_t value from buffer.
virtual Int_t ReadStaticArrayFloat16(Float_t *f, TStreamerElement *ele=0)
Read array of Float16_t from buffer.
virtual void WriteLong64(Long64_t l)
Writes Long64_t value to buffer.
#define TBufferJSON_ReadArray(tname, vname)
virtual TClass * GetClass() const =0
TLoopConfiguration * fLoopConfig
If this is a bundle of memberwise streaming action, this configures the looping.
Collectable string class.
virtual void ReadFloat(Float_t &f)
Reads Float_t value from buffer.
virtual void ReadWithFactor(Float_t *ptr, Double_t factor, Double_t minvalue)
Read a Double32_t from the buffer when the factor and minimun value have been specified see comments ...
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
virtual Int_t WriteObjectAny(const void *obj, const TClass *ptrClass, Bool_t cacheReuse=kTRUE)
Write object to I/O buffer.
All ROOT classes may have RTTI (run time type identification) support added.
R__EXTERN TVirtualMutex * gInterpreterMutex
virtual void ReadWithNbits(Float_t *ptr, Int_t nbits)
Read a Float16_t from the buffer when the number of bits is specified (explicitly or not) see comment...
TString fSemicolon
0 - no any compression, 1 - no spaces in the begin, 2 - no new lines, 3 - no spaces at all ...
virtual void SkipObjectAny()
Skip any kind of object from buffer.
Int_t GetUnitSize() const
Get the sizeof the underlying type of the data member (i.e.
virtual void ReadCharP(Char_t *c)
Reads array of characters from buffer.
virtual TClass * GetClassPointer() const
Returns a pointer to the TClass of this element.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual void DecrementLevel(TVirtualStreamerInfo *)
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and decrease level in json...
TString fArraySepar
depending from compression level, " : " or ":"
virtual void ReadFastArrayWithFactor(Float_t *ptr, Int_t n, Double_t factor, Double_t minvalue)
read array of Float16_t from buffer
const char * GetTypeName() const
Get type of data member, e,g.: "class TDirectory*" -> "TDirectory".
virtual void ReadBool(Bool_t &b)
Reads Bool_t value from buffer.
Int_t fCompact
stack of streamer infos
virtual void WriteDouble(Double_t d)
Writes Double_t value to buffer.
virtual void ReadLong64(Long64_t &l)
Reads Long64_t value from buffer.
virtual void ReadStdString(std::string *s)
Reads a std::string.
Buffer base class used for serializing objects.
void JsonWriteBasic(Char_t value)
converts Char_t to string and add to json value buffer
virtual TObject * Remove(TObject *obj)
Remove object from array.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
static void SetDoubleFormat(const char *fmt="%.14e")
set printf format for double members, default "%.14e" use it after SetFloatFormat, which also overwrites format for doubles
virtual void ReadFastArrayFloat16(Float_t *f, Int_t n, TStreamerElement *ele=0)
read array of Float16_t from buffer
virtual void WriteULong64(ULong64_t l)
Writes ULong64_t value to buffer.
Int_t JsonSpecialClass(const TClass *cl) const
return non-zero value when class has special handling in JSON it is TCollection (-130), TArray (100), TString (110), std::string (120) and STL containers (1..6)
Int_t GetArrayLength() const
virtual void ReadFastArray(Bool_t *b, Int_t n)
read array of Bool_t from buffer
#define TJSONWriteConstChar(vname, arrsize, typname)
static const char * fgDoubleFmt
printf argument for floats, either "%f" or "%e" or "%10f" and so on
virtual void ReadLong(Long_t &l)
Reads Long_t value from buffer.
virtual void WriteLong(Long_t l)
Writes Long_t value to buffer.
virtual Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *object)
Read one collection of objects from the buffer using the StreamerInfoLoopAction.
void SetParent(TObject *parent)
Set parent owning this buffer.
Option_t * GetOption() const
virtual void SetArrayDim(Int_t dim)
Set number of array dimensions.
TObject * At(Int_t idx) const
Int_t GetArrayDim() const
virtual void WriteFastArrayString(const Char_t *c, Int_t n)
Write array of Char_t to buffer.
virtual void SetMaxIndex(Int_t dim, Int_t max)
set maximum index for array with dimension dim
Array of integers (32 bits per element).
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
#define TBufferJSON_WriteFastArray(vname, method, typname)
virtual void WriteInt(Int_t i)
Writes Int_t value to buffer.
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)
suppressed function of TBuffer
Int_t GetBaseClassOffset(const TClass *toBase, void *address=0, bool isDerivedObject=true)
TObject * Last() const
Return the object in the last filled slot. Returns 0 if no entries.
virtual void ReadChar(Char_t &c)
Reads Char_t value from buffer.
Bool_t IsBasic() const
Return true if data member is a basic type, e.g. char, int, long...
virtual void ReadFastArrayDouble32(Double_t *d, Int_t n, TStreamerElement *ele=0)
read array of Double32_t from buffer
virtual void * GetFirstAddress(void *start, const void *end) const =0
virtual void WriteFastArray(const Bool_t *b, Int_t n)
Write array of Bool_t to buffer.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
virtual void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE)
Convert object into json structures.
virtual void ReadUShort(UShort_t &s)
Reads UShort_t value from buffer.
void Clear()
Clear string without changing its capacity.
virtual void ReadDouble(Double_t &d)
Reads Double_t value from buffer.
TJSONStackObj * Stack(Int_t depth=0)
return stack object of specified depth
TString & Append(const char *cs)
std::map< const void *, unsigned > fJsonrMap
buffer for current value
Long_t GetThisOffset() const
unsigned fJsonrCnt
map of recorded objects, used in JsonR to restore references
virtual void ReadCharStar(char *&s)
Reads a char* string.
TDataType * GetDataType() const
TObjArray fStack
counter for all objects and arrays
virtual void ReadUChar(UChar_t &c)
Reads UChar_t value from buffer.
#define TBufferJSON_ReadStaticArray(vname)
void Set(Int_t n)
Set size of this array to n ints.
Base class of the Configurations for the member wise looping routines.
void SetCompact(int level)
virtual void WriteFastArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=0)
Write array of Double32_t to buffer.
void JsonWriteConstChar(const char *value, Int_t len=-1)
writes string value, processing all kind of special characters
Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
virtual Int_t ReadStaticArrayDouble32(Double_t *d, TStreamerElement *ele=0)
Read array of Double32_t from buffer.
TString fNumericLocale
depending from compression level, ", " or ","
virtual void ReadInt(Int_t &i)
Reads Int_t value from buffer.
TString fValue
current output buffer for json code
virtual void SetStreamerElementNumber(TStreamerElement *elem, Int_t comp_type)
Function is called from TStreamerInfo WriteBuffer and Readbuffer functions and add/verify next elemen...
virtual void WriteStdString(const std::string *s)
Writes a std::string.
Bool_t IsCompiled() const
Int_t GetLast() const
Return index of last object in array.
virtual void IncrementLevel(TVirtualStreamerInfo *)
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and indent new level in js...
virtual void WriteObjectClass(const void *actualObjStart, const TClass *actualClass, Bool_t cacheReuse)
Write object to buffer. Only used from TBuffer.
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)
suppressed function of TBuffer
static Int_t ExportToFile(const char *filename, const TObject *obj, const char *option=0)
Convert object into JSON and store in text file Returns size of the produce file Used in TObject::Sav...
TClass * GetClass() const
void BuildOld()
rebuild the TStreamerInfo structure
virtual void TagStreamerInfo(TVirtualStreamerInfo *)
virtual void ReadULong(ULong_t &l)
Reads ULong_t value from buffer.
Basic data type descriptor (datatype information is obtained from CINT).
TClass * GetActualClass(const void *object) const
Return a pointer the the real class of the object.
static const char * GetDoubleFormat()
return current printf format for double members, default "%.14e"
virtual void ClassBegin(const TClass *, Version_t=-1)
Should be called in the beginning of custom class streamer.
virtual Int_t ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection)
Read one collection of objects from the buffer using the StreamerInfoLoopAction.
TString * fOutput
main output buffer for json code
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
TDataMember * GetDataMember() const
Collection abstract base class.
void AppendOutput(const char *line0, const char *line1=0)
Info("AppendOutput"," '%s' '%s'", line0, line1?line1 : "---");.
virtual void ReadDouble32(Double_t *d, TStreamerElement *ele=0)
read a Double32_t from the buffer
Int_t GetMaxIndex(Int_t i) const
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
char * Form(const char *fmt,...)
virtual void SkipVersion(const TClass *cl=0)
Skip class version from I/O buffer.
Int_t Size() const
Return size of object of this class.
The TRealData class manages the effective list of all data members for a given class.
Int_t GetArrayDim() const
Return number of array dimensions.
The ROOT global object gROOT contains a list of all defined classes.
ROOT::ESTLType GetCollectionType() const
Return the 'type' of the STL the TClass is representing.
static const char * fgFloatFmt
stored value of setlocale(LC_NUMERIC), which should be recovered at the end
virtual void WriteUShort(UShort_t s)
Writes UShort_t value to buffer.
void WorkWithElement(TStreamerElement *elem, Int_t)
This is call-back from streamer which indicates that class member will be streamed Name of element us...
virtual void WriteBool(Bool_t b)
Writes Bool_t value to buffer.
virtual void WriteDouble32(Double_t *d, TStreamerElement *ele=0)
write a Double32_t to the buffer
void WorkWithClass(TStreamerInfo *info, const TClass *cl=0)
Prepares buffer to stream data of specified class.
bool IsStdClass(const char *type)
return true if the class belongs to the std namespace
void JsonStartElement(const TStreamerElement *elem, const TClass *base_class=0)
virtual void ReadTString(TString &s)
Reads a TString.
virtual void WriteFloat(Float_t f)
Writes Float_t value to buffer.
const char * GetTrueTypeName() const
Get full type description of data member, e,g.: "class TDirectory*".
virtual void WriteFastArrayFloat16(const Float_t *d, Int_t n, TStreamerElement *ele=0)
Write array of Float16_t to buffer.
Version_t GetClassVersion() const
virtual void WriteTString(const TString &s)
Writes a TString.
void Build()
Build the I/O data structure for the current class version.
static const char * GetFloatFormat()
return current printf format for float members, default "%e"
virtual void WriteShort(Short_t s)
Writes Short_t value to buffer.
Class for serializing object into JavaScript Object Notation (JSON) format.
virtual void ReadFloat16(Float_t *f, TStreamerElement *ele=0)
read a Float16_t from the buffer
virtual Bool_t CheckObject(const TObject *)
Check that object already stored in the buffer.
virtual void WriteUInt(UInt_t i)
Writes UInt_t value to buffer.
virtual void WriteFloat16(Float_t *f, TStreamerElement *ele=0)
write a Float16_t to the buffer
virtual void WriteULong(ULong_t l)
Writes ULong_t value to buffer.
virtual void WriteArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=0)
Write array of Double32_t to buffer.
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Int_t IndexOf(const TObject *obj) const
unsigned long long ULong64_t
TList * GetListOfRealData() const
#define TJSONWriteArrayCompress(vname, arrsize, typname)
static RooMathCoreReg dummy
virtual Bool_t IsBase() const
Return kTRUE if the element represent a base class.
static TString ConvertToJSON(const TObject *obj, Int_t compact=0, const char *member_name=0)
Converts object, inherited from TObject class, to JSON string Lower digit of compact parameter define...
virtual void * ReadObjectAny(const TClass *clCast)
Read object from buffer. Only used from TBuffer.
static constexpr double s
virtual void WriteCharStar(char *s)
Writes a char*.
#define R__LOCKGUARD(mutex)
TStreamerInfoActions::TActionSequence * GetWriteTextActions()
TBufferJSON()
Creates buffer object to serialize data into json.
void JsonWriteObject(const void *obj, const TClass *objClass, Bool_t check_map=kTRUE)
Write object to buffer If object was written before, only pointer will be stored If check_map==kFALSE...
virtual void ReadULong64(ULong64_t &l)
Reads ULong64_t value from buffer.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
virtual void ClassEnd(const TClass *)
Should be called at the end of custom streamer See TBufferJSON::ClassBegin for more details...
virtual Int_t ReadArrayDouble32(Double_t *&d, TStreamerElement *ele=0)
Read array of Double32_t from buffer.
Mother of all ROOT objects.
TObjArray * GetElements() const
static void SetFloatFormat(const char *fmt="%e")
set printf format for float/double members, default "%e" to change format only for doubles...
Int_t IsSTLContainer()
The return type is defined in TDictionary (kVector, kList, etc.)
TJSONStackObj * PopStack()
remove one level from stack
virtual void StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass=0)
stream object to/from buffer
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
virtual void WriteChar(Char_t c)
Writes Char_t value to buffer.
An array of clone (identical) objects.
const char * GetTypeName() const
virtual Int_t ReadArrayFloat16(Float_t *&f, TStreamerElement *ele=0)
Read array of Float16_t from buffer.
virtual void WriteCharP(const Char_t *c)
Writes array of characters to buffer.
const char * GetArrayIndex() const
If the data member is pointer and has a valid array size in its comments GetArrayIndex returns a stri...
static void CompactFloatString(char *buf, unsigned len)
method compress float string, excluding exp and/or move float point
void PerformPostProcessing(TJSONStackObj *stack, const TClass *obj_cl=0)
Function is converts TObject and TString structures to more compact representation.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
TJSONStackObj * PushStack(Int_t inclevel=0)
add new level to the structures stack
#define TBufferJSON_ReadFastArray(vname)
#define TBufferJSON_WriteArray(vname, typname)
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Int_t Atoi() const
Return integer value of string.
void SetBaseVersion(Int_t v)
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)
Function called by the Streamer functions to serialize object at p to buffer b.
void JsonStreamCollection(TCollection *obj, const TClass *objClass)
store content of collection
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)
read version value from buffer
virtual ~TBufferJSON()
destroy buffer
virtual void WriteClass(const TClass *cl)
suppressed function of TBuffer
virtual void ReadFastArrayString(Char_t *c, Int_t n)
read array of Char_t from buffer
virtual void Compress()
Remove empty slots from array.
Abstract Interface class describing Streamer information for one class.
Bool_t IsaPointer() const
Return true if data member is a pointer.
virtual void WriteArray(const Bool_t *b, Int_t n)
Write array of Bool_t to buffer.
TRealData * GetRealData(const char *name) const
Return pointer to TRealData element with name "name".
virtual void ReadFastArrayWithNbits(Float_t *ptr, Int_t n, Int_t nbits)
read array of Float16_t from buffer
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual const char * GetName() const
Return name of this collection.
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
virtual void ReadUInt(UInt_t &i)
Reads UInt_t value from buffer.
virtual void ClassMember(const char *name, const char *typeName=0, Int_t arrsize1=-1, Int_t arrsize2=-1)
Method indicates name and typename of class member, which should be now streamed in custom streamer F...
const char * Data() const
TVirtualStreamerInfo * fStreamerInfo
StreamerInfo used to derive these actions.