137#include <nlohmann/json.hpp>
164 Bool_t usearraylen = (arraylen > (isloop ? 0 : 1));
166 if (usearrayindx && (arraylen > 0)) {
171 ::Error(
"TArrayIndexProducer",
"Problem with JSON coding of element %s type %d", elem->
GetName(),
179 for (
int dim = 0; dim < elem->
GetArrayDim(); dim++)
182 }
else if (usearraylen) {
190 fIndicies.Set(fMaxIndex.GetSize());
206 for (
int dim = 0; dim < member->
GetArrayDim(); dim++) {
281 while ((cnt >= 0) && (cnt <
fIndicies.GetSize())) {
295 nlohmann::json *
ExtractNode(nlohmann::json *topnode,
bool next =
true)
299 nlohmann::json *subnode = &((*((nlohmann::json *)topnode))[
fIndicies[0]]);
300 for (
int k = 1; k <
fIndicies.GetSize(); ++k)
323 return &(prnt->at(
fIndx++));
326 nlohmann::json *
json = &(prnt->at(
fIndx));
361 std::unique_ptr<TArrayIndexProducer>
fIndx;
403 if (map_convert_type) {
404 if (!
json->is_object())
return -1;
407 for (
auto it =
json->begin(); it !=
json->end(); ++it) {
408 if ((strlen(map_convert_type)==0) || (it.key().compare(map_convert_type) != 0)) sz++;
414 if (
json->is_array())
418 if (
json->is_object() && (
json->count(
"$arr") == 1))
419 return json->at(
"len").get<
int>();
426 auto res = std::stoi(
fValues.back());
437 auto indx = std::make_unique<TArrayIndexProducer>(
fElem, -1,
"");
440 if (!indx->IsArray() || (indx->NumDimensions() < 2))
450 fStlRead = std::make_unique<StlRead>();
452 if (map_convert == 2) {
453 if (!
fNode->is_object()) {
454 ::Error(
"TJSONStackObj::AssignStl",
"when reading %s expecting JSON object", cl->
GetName());
458 fStlRead->fTypeTag = typename_tag && (strlen(typename_tag) > 0) ? typename_tag :
nullptr;
460 if (!
fNode->is_array() && !(
fNode->is_object() && (
fNode->count(
"$arr") == 1))) {
461 ::Error(
"TJSONStackObj::AssignStl",
"when reading %s expecting JSON array", cl->
GetName());
493 char *loc = setlocale(LC_NUMERIC,
nullptr);
494 if (loc && (strcmp(loc,
"C") != 0)) {
496 setlocale(LC_NUMERIC,
"C");
535 TClass *clActual =
nullptr;
536 void *ptr = (
void *)obj;
558 int srcsize = (
int) strlen(
json);
560 buf.resize(srcsize + 500);
562 int tgtsize = buf.length();
679 ::Error(
"TBufferJSON::ConvertToJSON",
"Unknown class (probably missing dictionary).");
683 const void *actualStart = obj;
684 if (clActual && (clActual != cl)) {
689 clActual =
const_cast<TClass *
>(cl);
692 if (member_name && actualStart) {
697 while ((rdata =
dynamic_cast<TRealData *
>(iter())) !=
nullptr) {
699 if (member && strcmp(member->
GetName(), member_name) == 0)
711 arraylen = *((
int *)((
char *)actualStart + idata->
GetThisOffset()));
717 ptr = *((
char **)ptr);
754 Error(
"StoreObject",
"Can not store object into TBuffer for reading");
798 if (!obj || !filename || (*filename == 0))
801 Int_t compact = strstr(filename,
".json.gz") ? 3 : 0;
802 if (option && (*option >=
'0') && (*option <=
'3'))
807 std::ofstream ofs(filename);
809 if (strstr(filename,
".json.gz")) {
810 const char *objbuf =
json.Data();
813 unsigned long objcrc = R__crc32(0,
nullptr, 0);
814 objcrc = R__crc32(objcrc, (
const unsigned char *)objbuf, objlen);
817 Int_t buflen = 10 + objlen + 8;
821 char *buffer = (
char *)
malloc(buflen);
825 char *bufcur = buffer;
841 memcpy(dummy, bufcur - 6, 6);
844 unsigned long ziplen = R__memcompress(bufcur - 6, objlen + 6, (
char *)objbuf, objlen);
846 memcpy(bufcur - 6, dummy, 6);
848 bufcur += (ziplen - 6);
850 *bufcur++ = objcrc & 0xff;
851 *bufcur++ = (objcrc >> 8) & 0xff;
852 *bufcur++ = (objcrc >> 16) & 0xff;
853 *bufcur++ = (objcrc >> 24) & 0xff;
855 *bufcur++ = objlen & 0xff;
856 *bufcur++ = (objlen >> 8) & 0xff;
857 *bufcur++ = (objlen >> 16) & 0xff;
858 *bufcur++ = (objlen >> 24) & 0xff;
860 ofs.write(buffer, bufcur - buffer);
869 return json.Length();
878 if (!obj || !cl || !filename || (*filename == 0))
881 Int_t compact = strstr(filename,
".json.gz") ? 3 : 0;
882 if (option && (*option >=
'0') && (*option <=
'3'))
887 std::ofstream ofs(filename);
889 if (strstr(filename,
".json.gz")) {
890 const char *objbuf =
json.Data();
893 unsigned long objcrc = R__crc32(0,
nullptr, 0);
894 objcrc = R__crc32(objcrc, (
const unsigned char *)objbuf, objlen);
897 Int_t buflen = 10 + objlen + 8;
901 char *buffer = (
char *)
malloc(buflen);
905 char *bufcur = buffer;
921 memcpy(dummy, bufcur - 6, 6);
924 unsigned long ziplen = R__memcompress(bufcur - 6, objlen + 6, (
char *)objbuf, objlen);
926 memcpy(bufcur - 6, dummy, 6);
928 bufcur += (ziplen - 6);
930 *bufcur++ = objcrc & 0xff;
931 *bufcur++ = (objcrc >> 8) & 0xff;
932 *bufcur++ = (objcrc >> 16) & 0xff;
933 *bufcur++ = (objcrc >> 24) & 0xff;
935 *bufcur++ = objlen & 0xff;
936 *bufcur++ = (objlen >> 8) & 0xff;
937 *bufcur++ = (objlen >> 16) & 0xff;
938 *bufcur++ = (objlen >> 24) & 0xff;
940 ofs.write(buffer, bufcur - buffer);
949 return json.Length();
971 return (
TObject *)(((
char *)obj) + delta);
996 nlohmann::json docu = nlohmann::json::parse(json_str);
998 if (docu.is_null() || (!docu.is_object() && !docu.is_array()))
1001 TClass *objClass =
nullptr;
1027 TClass *resClass =
const_cast<TClass *
>(expectedClass);
1031 if (!res || !resClass)
1034 if (resClass == expectedClass)
1039 ::Error(
"TBufferJSON::ConvertFromJSONChecked",
"expected class %s is not base for read class %s",
1045 return (
char *)res - offset;
1070 return (tid ==
kCharStar) ?
"\"\"" :
"null";
1085 char *ppp = (
char *)ptr;
1131 ppp += shift * unitSize;
1133 }
while (!indx.
IsDone());
1144 memberClass->
Streamer((
void *)ptr, *
this);
1153 if (arr && (arr->
GetSize() > 0)) {
1156 if (
Stack()->fValues.size() > 1) {
1157 Warning(
"TBufferJSON",
"When streaming TArray, more than 1 object in the stack, use second item");
1162 }
else if (memberClass && !strcmp(memberClass->
GetName(),
"string")) {
1164 memberClass->
Streamer((
void *)ptr, *
this);
1171 if (!memberClass || (member->
GetArrayDim() > 0) || (arraylen > 0))
1172 return "<not supported>";
1183 next->fLevel = inclevel;
1185 next->fNode = (nlohmann::json *)readnode;
1186 }
else if (
fStack.size() > 0) {
1187 auto prev =
Stack();
1188 next->fLevel += prev->fLevel;
1189 next->fMemberPtr = prev->fMemberPtr;
1191 fStack.emplace_back(next);
1203 return fStack.size() > 0 ?
fStack.back().get() :
nullptr;
1218 if (strlen(line1) > 0) {
1220 if (
Stack()->fLevel > 0)
1236 stack->fMemberPtr = &stack->fMemberCnt;
1255 stack->fMemberCnt = 0;
1267 const char *elem_name =
nullptr;
1270 switch (special_kind) {
1272 if (base_class)
return;
1274 if (strcmp(elem_name,
"fLineStyle") == 0)
1275 if ((strcmp(elem->
GetTypeName(),
"TString") == 0) && (strcmp(elem->
GetFullName(),
"fLineStyle[30]") == 0)) {
1277 if (st1->IsStreamerInfo() && st1->fInfo && (strcmp(st1->fInfo->GetName(),
"TStyle") == 0))
1278 elem_name =
"fLineStyles";
1305 if (
json->count(elem_name) != 1) {
1306 Error(
"JsonStartElement",
"Missing JSON structure for element %s", elem_name);
1313 Error(
"JsonStartElement",
"Missing array when reading TArray class for element %s", elem->
GetName());
1315 if ((
gDebug > 1) && base_class)
1316 Info(
"JsonStartElement",
"Reading baseclass %s from element %s", base_class->
GetName(), elem_name);
1365 if (isstd && !strcmp(cl->
GetName(),
"string"))
1382 Info(
"JsonWriteObject",
"Object %p class %s check_map %s", obj, cl ? cl->
GetName() :
"null",
1383 check_map ?
"true" :
"false");
1387 TString fObjectOutput, *fPrevOutput{
nullptr};
1400 }
else if ((special_kind <= 0) || (special_kind >
json_TArray)) {
1412 Error(
"JsonWriteObject",
"Cannot stream class %s without dictionary", cl->
GetName());
1423 if (special_kind <= 0) {
1441 }
else if (map_convert == 2) {
1447 fValue.Form(
"{\"$ref\":%u}", (
unsigned)(refid - 1));
1468 Info(
"JsonWriteObject",
"Starting object %p write for class: %s", obj, cl->
GetName());
1475 (
const_cast<TClass *
>(cl))->Streamer((
void *)obj, *
this);
1478 Info(
"JsonWriteObject",
"Done object %p write for class: %s", obj, cl->
GetName());
1481 if (stack->
fValues.size() != 1)
1482 Error(
"JsonWriteObject",
"Problem when writing array");
1485 if (stack->
fValues.size() > 2)
1486 Error(
"JsonWriteObject",
"Problem when writing TString or std::string");
1490 }
else if ((special_kind > 0) && (special_kind <
ROOT::kSTLend)) {
1493 if (map_convert == 2) {
1499 const char *separ = (
fCompact < 2) ?
", " :
",";
1500 const char *semi = (
fCompact < 2) ?
": " :
":";
1524 }
else if (stack->
fValues.empty()) {
1527 Error(
"JsonWriteObject",
"With empty stack fValue!=0");
1533 bool trivial_format =
false;
1538 TClass *value_class = proxy ? proxy->GetValueClass() :
nullptr;
1540 trivial_format =
false;
1542 trivial_format =
true;
1545 if (trivial_format) {
1548 if (
fValue.Length() == 0) {
1549 Error(
"JsonWriteObject",
"Empty value when it should contain something");
1554 const char *separ =
"[";
1559 if ((
size * 2 == (
int) stack->
fValues.size() - 1) && (map_convert > 0)) {
1563 if (pairtype.
Index(
"unordered_map<") == 0)
1564 pairtype.
Replace(0, 14,
"pair<");
1565 else if (pairtype.
Index(
"unordered_multimap<") == 0)
1566 pairtype.
Replace(0, 19,
"pair<");
1567 else if (pairtype.
Index(
"multimap<") == 0)
1568 pairtype.
Replace(0, 9,
"pair<");
1569 else if (pairtype.
Index(
"map<") == 0)
1570 pairtype.
Replace(0, 4,
"pair<");
1582 fValue.Append(
"\"$pair\"");
1586 fValue.Append(
"\"first\"");
1590 fValue.Append(
"\"second\"");
1613 if ((special_kind == 0) && (!stack->
fValues.empty() || (
fValue.Length() > 0))) {
1615 Info(
"JsonWriteObject",
"Create blob value for class %s", cl->
GetName());
1620 const char *separ =
"[";
1622 for (
auto &elem: stack->
fValues) {
1628 if (
fValue.Length() > 0) {
1641 if ((special_kind <= 0))
1649 if ((special_kind <= 0) || (special_kind >
json_TArray))
1651 else if (fObjectOutput.
Length() != 0)
1652 Error(
"JsonWriteObject",
"Non-empty object output for special class %s", cl->
GetName());
1672 auto map =
dynamic_cast<TMap *
>(col);
1673 auto lst =
dynamic_cast<TList *
>(col);
1683 auto lnk = lst->FirstLink();
1694 sopt.
Append(lnk->GetAddOption());
1705 while (
auto obj = iter()) {
1726 while (
auto obj = iter()) {
1755 TList *lst =
nullptr;
1759 lst =
dynamic_cast<TList *
>(col);
1761 map =
dynamic_cast<TMap *
>(col);
1767 std::string
name =
json->at(
"name");
1770 nlohmann::json &arr =
json->at(
"arr");
1771 int size = arr.size();
1773 for (
int n = 0;
n <
size; ++
n) {
1774 nlohmann::json *subelem = &arr.at(
n);
1777 subelem = &subelem->at(
"first");
1781 TClass *readClass =
nullptr, *objClass =
nullptr;
1782 void *subobj =
nullptr;
1790 Error(
"JsonReadCollection",
1791 "Cannot detect class name for TClonesArray - typename tag not configured");
1795 Error(
"JsonReadCollection",
"TClonesArray size %d smaller than required %d", clones->
GetSize(),
size);
1810 if (!subobj || !readClass) {
1813 Error(
"JsonReadCollection",
"Try to add object %s not derived from TObject", readClass->
GetName());
1822 readClass =
nullptr;
1827 if (!subobj2 || !readClass) {
1830 Error(
"JsonReadCollection",
"Try to add object %s not derived from TObject", readClass->
GetName());
1834 map->Add(tobj,
static_cast<TObject *
>(subobj2));
1836 auto &elem =
json->at(
"opt").at(
n);
1840 lst->
Add(tobj, elem.get<std::string>().c_str());
1854 *readClass =
nullptr;
1862 if (
json->is_null())
1868 if (
json->is_object() && (
json->size() == 1) && (
json->find(
"$ref") !=
json->end())) {
1869 unsigned refid =
json->at(
"$ref").get<
unsigned>();
1871 void *ref_obj =
nullptr;
1872 TClass *ref_cl =
nullptr;
1876 if (!ref_obj || !ref_cl) {
1877 Error(
"JsonReadObject",
"Fail to find object for reference %u", refid);
1882 *readClass = ref_cl;
1885 Info(
"JsonReadObject",
"Extract object reference %u %p cl:%s expects:%s", refid, ref_obj, ref_cl->
GetName(),
1886 (objClass ? objClass->
GetName() :
"---"));
1894 obj = objClass->
New();
1897 Info(
"JsonReadObject",
"Read string from %s",
json->dump().c_str());
1900 *((std::string *)obj) =
json->get<std::string>();
1902 *((
TString *)obj) =
json->get<std::string>().c_str();
1905 *readClass =
const_cast<TClass *
>(objClass);
1912 if (isBase && (!obj || !objClass)) {
1913 Error(
"JsonReadObject",
"No object when reading base class");
1917 Int_t map_convert = 0;
1920 map_convert =
json->is_object() ? 2 : 1;
1923 Error(
"JsonReadObject",
"Cannot stream class %s without dictionary", objClass->
GetName());
1933 TClass *jsonClass =
nullptr;
1934 Int_t jsonClassVersion = 0;
1938 jsonClass =
const_cast<TClass *
>(objClass);
1941 obj = jsonClass->
New();
1948 Error(
"JsonReadObject",
"Not array when expecting such %s",
json->dump().c_str());
1951 Info(
"JsonReadObject",
"Reading special kind %d %s ptr %p", special_kind, objClass->
GetName(), obj);
1953 }
else if (isBase) {
1956 jsonClass =
const_cast<TClass *
>(objClass);
1959 Info(
"JsonReadObject",
"Reading baseclass %s ptr %p", objClass->
GetName(), obj);
1966 Error(
"JsonReadObject",
"Cannot find class %s", clname.c_str());
1969 jsonClass =
const_cast<TClass *
>(objClass);
1981 if (objClass && (jsonClass != objClass)) {
1984 Error(
"JsonReadObject",
"Not possible to read %s and casting to %s pointer as the two classes are unrelated",
1987 Error(
"JsonReadObject",
"Reading %s and casting to %s pointer is currently not supported",
1996 obj = jsonClass->
New();
1999 Info(
"JsonReadObject",
"Reading object of class %s refid %u ptr %p", jsonClass->
GetName(),
fJsonrCnt, obj);
2033 Info(
"JsonReadObject",
"Calling streamer of class %s", jsonClass->
GetName());
2035 if (isBase && (special_kind == 0))
2036 Error(
"JsonReadObject",
"Should not be used for reading of base class %s", jsonClass->
GetName());
2039 jsonClass->
Streamer((
void *)obj, *
this);
2051 Info(
"JsonReadObject",
"Reading object of class %s done", jsonClass->
GetName());
2054 *readClass = jsonClass;
2065 nlohmann::json *
json = node ? (nlohmann::json *)node :
Stack()->
fNode;
2067 UInt_t uid =
json->at(
"fUniqueID").get<
unsigned>();
2068 UInt_t bits =
json->at(
"fBits").get<
unsigned>();
2076 if (tobj_fbits_offset > 0) {
2077 UInt_t *fbits = (
UInt_t *) ((
char* ) tobj + tobj_fbits_offset);
2108 Info(
"WorkWithClass",
"Class: %s", cl->
GetName());
2127 stack->
fInfo = sinfo;
2146 Info(
"DecrementLevel",
" Perform post-processing elem: %s", stack->
fElem->
GetName());
2155 Error(
"DecrementLevel",
" Mismatch of streamer info");
2160 Info(
"DecrementLevel",
"Class: %s done", (info ? info->
GetClass()->
GetName() :
"custom"));
2179 Info(
"SetStreamerElementNumber",
"Element name %s", elem->
GetName());
2193 Error(
"WorkWithElement",
"stack is empty");
2198 Info(
"WorkWithElement",
" Start element %s type %d typename %s", elem ? elem->
GetName() :
"---",
2206 Info(
"WorkWithElement",
" Perform post-processing elem: %s", stack->
fElem->
GetName());
2216 Error(
"WorkWithElement",
"Lost of stack");
2222 Error(
"WorkWithElement",
"Problem in Inc/Dec level");
2229 Error(
"WorkWithElement",
"streamer info returns elem = nullptr");
2236 stack->
fElem = elem;
2246 stack->
fIndx = std::make_unique<TArrayIndexProducer>(elem, -1,
fArraySepar.Data());
2324 if (!
name || (strlen(
name) == 0)) {
2325 Error(
"ClassMember",
"Invalid member name");
2333 if (strcmp(typeName,
"raw:data") == 0)
2343 if (strcmp(
name, typeName) == 0) {
2351 if (tname[tname.
Length() - 1] ==
'*') {
2357 Error(
"ClassMember",
"Invalid class specifier %s", typeName);
2381 }
else if ((typ_id > 0) && (typ_id < 20)) {
2397 Error(
"ClassMember",
"Invalid combination name = %s type = %s",
name, typeName);
2422 if (!elem && !obj_cl)
2449 isTArray = (strncmp(
"TArray", typname, 6) == 0);
2452 if (isTString || isSTLstring) {
2456 Info(
"PerformPostProcessing",
"reformat string value = '%s'",
fValue.Data());
2459 }
else if (isOffsetPArray) {
2464 }
else if ((stack->
fValues.size() == 1) && (stack->
fValues[0] ==
"1")) {
2467 Error(
"PerformPostProcessing",
"Wrong values for kOffsetP element %s", (elem ? elem->
GetName() :
"---"));
2471 }
else if (isTObject || isTRef) {
2480 if (cnt < 2 || cnt > 3) {
2482 Error(
"PerformPostProcessing",
"When storing TObject/TRef, strange number of items %d", cnt);
2491 auto tbits = std::atol((stack->
fValues.size() > 1) ? stack->
fValues[1].c_str() :
fValue.Data());
2504 }
else if (isTArray) {
2509 if (elem && elem->
IsBase() && (
fValue.Length() == 0)) {
2514 if (!stack->
fValues.empty()) {
2517 for (
auto &blob: stack->
fValues) {
2523 if (
fValue.Length() == 0) {
2559 if (!cl &&
Stack()->fClVersion) {
2565 Info(
"ReadVersion",
"Result: %d Class: %s", res, (cl ? cl->
GetName() :
"---"));
2584 Info(
"ReadObjectAny",
"From current JSON node");
2600 Info(
"WriteObjectClass",
"Class %s", (actualClass ? actualClass->
GetName() :
" null"));
2721template <
typename T>
2724 Info(
"ReadArray",
"Not implemented");
2725 return value ? 1 : 0;
2835template <
typename T>
2838 if (!arr || (arrsize <= 0))
2842 Info(
"ReadFastArray",
"Reading array sz %d from JSON %s", arrsize,
json->dump().substr(0, 30).c_str());
2845 TArrayI &indx = indexes->GetIndices();
2847 if (indexes->TotalLength() != arrsize)
2848 Error(
"ReadFastArray",
"Mismatch %d-dim array sizes %d %d", lastdim + 1, arrsize, (
int)indexes->TotalLength());
2849 for (
int cnt = 0; cnt < arrsize; ++cnt) {
2850 nlohmann::json *elem = &(
json->at(indx[0]));
2851 for (
int k = 1; k < lastdim; ++k)
2852 elem = &((*elem)[indx[k]]);
2853 arr[cnt] = (asstring && elem->is_string()) ? elem->get<std::string>()[indx[lastdim]] : (*elem)[indx[lastdim]].get<T>();
2854 indexes->NextSeparator();
2856 }
else if (asstring &&
json->is_string()) {
2857 std::string str =
json->get<std::string>();
2858 for (
int cnt = 0; cnt < arrsize; ++cnt)
2859 arr[cnt] = (cnt < (
int)str.length()) ? str[cnt] : 0;
2860 }
else if (
json->is_object() && (
json->count(
"$arr") == 1)) {
2861 if (
json->at(
"len").get<
int>() != arrsize)
2862 Error(
"ReadFastArray",
"Mismatch compressed array size %d %d", arrsize,
json->at(
"len").get<
int>());
2864 for (
int cnt = 0; cnt < arrsize; ++cnt)
2867 if (
json->count(
"b") == 1) {
2868 auto base64 =
json->at(
"b").get<std::string>();
2870 int offset = (
json->count(
"o") == 1) ?
json->at(
"o").get<
int>() : 0;
2875 if (arrsize * (
long)
sizeof(T) < (offset + decode.Length())) {
2876 Error(
"ReadFastArray",
"Base64 data %ld larger than target array size %ld", (
long) decode.Length() + offset, (
long) (arrsize*
sizeof(T)));
2877 }
else if ((
sizeof(T) > 1) && (decode.Length() %
sizeof(T) != 0)) {
2878 Error(
"ReadFastArray",
"Base64 data size %ld not matches with element size %ld", (
long) decode.Length(), (
long)
sizeof(T));
2880 memcpy((
char *) arr + offset, decode.Data(), decode.Length());
2886 std::string
idname =
"", pname, vname, nname;
2887 while (p < arrsize) {
2888 pname = std::string(
"p") +
idname;
2889 if (
json->count(pname) == 1)
2890 p =
json->at(pname).get<
int>();
2891 vname = std::string(
"v") +
idname;
2892 if (
json->count(vname) != 1)
2894 nlohmann::json &
v =
json->at(vname);
2896 for (
unsigned sub = 0; sub <
v.size(); ++sub)
2897 arr[p++] =
v[sub].get<T>();
2899 nname = std::string(
"n") +
idname;
2900 unsigned ncopy = (
json->count(nname) == 1) ?
json->at(nname).get<
unsigned>() : 1;
2901 for (
unsigned sub = 0; sub < ncopy; ++sub)
2902 arr[p++] =
v.get<T>();
2904 idname = std::to_string(++
id);
2907 if ((
int)
json->size() != arrsize)
2908 Error(
"ReadFastArray",
"Mismatch array sizes %d %d", arrsize, (
int)
json->size());
2909 for (
int cnt = 0; cnt < arrsize; ++cnt)
2910 arr[cnt] =
json->at(cnt).get<T>();
3036 Info(
"ReadFastArray",
"void* n:%d cl:%s",
n, cl->
GetName());
3045 int objectSize = cl->
Size();
3046 char *obj = (
char *)
start;
3049 nlohmann::json *topnode = stack->
fNode, *subnode = topnode;
3051 subnode = stack->
fIndx->ExtractNode(topnode);
3058 for (
Int_t j = 0; j <
n; j++, obj += objectSize) {
3066 stack->
fNode = topnode;
3076 Info(
"ReadFastArray",
"void** n:%d cl:%s prealloc:%s",
n, cl->
GetName(), (isPreAlloc ?
"true" :
"false"));
3092 nlohmann::json *topnode = stack->
fNode, *subnode = topnode;
3094 subnode = stack->
fIndx->ExtractNode(topnode);
3098 for (
Int_t j = 0; j <
n; j++) {
3103 void *old =
start[j];
3114 stack->
fNode = topnode;
3117template <
typename T>
3122 if (!is_base64 && ((
fArrayCompact == 0) || (arrsize < 6))) {
3124 for (
Int_t indx = 0; indx < arrsize; indx++) {
3130 }
else if (is_base64 && !arrsize) {
3135 Int_t aindx(0), bindx(arrsize);
3136 while ((aindx < arrsize) && (vname[aindx] == 0))
3138 while ((aindx < bindx) && (vname[bindx - 1] == 0))
3143 if ((aindx *
sizeof(T) < 5) && (aindx < bindx))
3146 if ((aindx > 0) && (aindx < bindx))
3150 fValue.Append(
"\"b\":\"");
3156 }
else if (aindx < bindx) {
3158 Int_t p(aindx), suffixcnt(-1), lastp(0);
3160 if (vname[p] == 0) {
3164 Int_t p0(p++), pp(0), nsame(1);
3170 for (; p <= bindx; ++p) {
3171 if ((p < bindx) && (vname[p] == vname[p - 1])) {
3175 if (vname[p - 1] == 0) {
3180 }
else if (nsame > 5) {
3193 if (++suffixcnt > 0)
3194 suffix.
Form(
"%d", suffixcnt);
3199 if ((nsame > 1) || (pp - p0 == 1)) {
3205 for (
Int_t indx = p0; indx < pp; indx++) {
3341template <
typename T>
3350 const Int_t maxElements = std::numeric_limits<Int_t>::max();
3351 if (arrsize > maxElements) {
3352 Fatal(
"JsonWriteFastArray",
"Array larger than 2^31 elements cannot be stored in JSON");
3370 if (++cnt == indexes.
GetSize()) {
3371 (*this.*method)((arr + shift), len, typname);
3377 (*this.*method)(arr, arrsize, typname);
3398 Bool_t need_blob =
false;
3403 }
else if (has_zero || !isprint(
c[i])) {
3409 if (need_blob && (
n >= 1000) && (!
Stack()->fElem || (
Stack()->fElem->GetArrayDim() < 2)))
3517 Info(
"WriteFastArray",
"void *start cl:%s n:%lld", cl ? cl->
GetName() :
"---",
n);
3531 char *obj = (
char *)
start;
3571 Info(
"WriteFastArray",
"void **startp cl:%s n:%lld", cl->
GetName(),
n);
3626 Info(
"StreamObject",
"Class: %s", (cl ? cl->
GetName() :
"none"));
3637template <
typename T>
3656 if (!
Stack()->fValues.empty())
3691 if (!
Stack()->fValues.empty())
3743 if (
json->is_null())
3744 val = std::numeric_limits<Float_t>::quiet_NaN();
3748 }
catch (nlohmann::detail::type_error &
e) {
3749 auto aux =
json->get<std::string>();
3750 if (aux ==
"nanf") {
3751 val = std::numeric_limits<Float_t>::quiet_NaN();
3752 }
else if (aux ==
"inff") {
3753 val = std::numeric_limits<Float_t>::infinity();
3754 }
else if (aux ==
"-inff") {
3755 val = -std::numeric_limits<Float_t>::infinity();
3757 Error(
"ReadFloat",
"%s '%s'",
e.what(), aux.c_str());
3758 val = std::numeric_limits<Float_t>::quiet_NaN();
3769 if (
json->is_null())
3770 val = std::numeric_limits<Double_t>::quiet_NaN();
3774 }
catch (nlohmann::detail::type_error &
e) {
3775 auto aux =
json->get<std::string>();
3777 val = std::numeric_limits<Double_t>::quiet_NaN();
3778 }
else if (aux ==
"inf") {
3779 val = std::numeric_limits<Double_t>::infinity();
3780 }
else if (aux ==
"-inf") {
3781 val = -std::numeric_limits<Double_t>::infinity();
3783 Error(
"ReadDouble",
"%s '%s'",
e.what(), aux.c_str());
3784 val = std::numeric_limits<Double_t>::quiet_NaN();
3794 Error(
"ReadCharP",
"Not implemented");
3828 std::size_t nch = str.length();
3830 s =
new char[nch + 1];
3831 memcpy(s, str.c_str(), nch);
4002 snprintf(buf,
sizeof(buf),
"%d", value);
4012 snprintf(buf,
sizeof(buf),
"%hd", value);
4022 snprintf(buf,
sizeof(buf),
"%d", value);
4032 snprintf(buf,
sizeof(buf),
"%ld", value);
4041 fValue.Append(std::to_string(value).c_str());
4049 if (std::isinf(value)) {
4051 fValue.Append((value < 0.) ?
"-2e308" :
"2e308");
4053 fValue.Append((value < 0.) ?
"\"-inff\"" :
"\"inff\"");
4054 }
else if (std::isnan(value)) {
4058 fValue.Append(
"\"nanf\"");
4071 if (std::isinf(value)) {
4073 fValue.Append((value < 0.) ?
"-2e308" :
"2e308");
4075 fValue.Append((value < 0.) ?
"\"-inf\"" :
"\"inf\"");
4076 }
else if (std::isnan(value)) {
4080 fValue.Append(
"\"nan\"");
4093 fValue.Append(value ?
"true" :
"false");
4102 snprintf(buf,
sizeof(buf),
"%u", value);
4112 snprintf(buf,
sizeof(buf),
"%hu", value);
4122 snprintf(buf,
sizeof(buf),
"%u", value);
4132 snprintf(buf,
sizeof(buf),
"%lu", value);
4141 fValue.Append(std::to_string(value).c_str());
4158 len = strlen(value);
4161 unsigned char c = value[
n];
4163 case 0:
n = len;
break;
4164 case '\n':
fValue.Append(
"\\n");
break;
4165 case '\t':
fValue.Append(
"\\t");
break;
4166 case '\"':
fValue.Append(
"\\\"");
break;
4167 case '\\':
fValue.Append(
"\\\\");
break;
4168 case '\b':
fValue.Append(
"\\b");
break;
4169 case '\f':
fValue.Append(
"\\f");
break;
4170 case '\r':
fValue.Append(
"\\r");
break;
4171 case '/':
fValue.Append(
"\\/");
break;
4175 }
else if (
c < 0x80) {
4177 }
else if ((
n < len - 1) && ((
c & 0xe0) == 0xc0) && ((value[
n+1] & 0xc0) == 0x80)) {
4178 unsigned code = ((unsigned)value[
n+1] & 0x3f) | (((
unsigned)
c & 0x1f) << 6);
4181 }
else if ((
n < len - 2) && ((
c & 0xf0) == 0xe0) && ((value[
n+1] & 0xc0) == 0x80) && ((value[
n+2] & 0xc0) == 0x80)) {
4182 unsigned code = ((unsigned)value[
n+2] & 0x3f) | (((
unsigned) value[
n+1] & 0x3f) << 6) | (((unsigned)
c & 0x0f) << 12);
4185 }
else if ((
n < len - 3) && ((
c & 0xf8) == 0xf0) && ((value[
n+1] & 0xc0) == 0x80) && ((value[
n+2] & 0xc0) == 0x80) && ((value[
n+3] & 0xc0) == 0x80)) {
4186 unsigned code = ((unsigned)value[
n+3] & 0x3f) | (((
unsigned) value[
n+2] & 0x3f) << 6) | (((unsigned) value[
n+1] & 0x3f) << 12) | (((
unsigned)
c & 0x07) << 18);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short).
int Int_t
Signed integer 4 bytes (int).
long Longptr_t
Integer large enough to hold a pointer (platform-dependent).
short Version_t
Class version identifier (short).
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char).
char Char_t
Character 1 byte (char).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
bool Bool_t
Boolean (0=false, 1=true) (bool).
short Short_t
Signed Short integer 2 bytes (short).
double Double_t
Double 8 bytes.
long long Long64_t
Portable signed long integer 8 bytes.
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
float Float_t
Float 4 bytes (float).
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
Array of integers (32 bits per element).
JSON array separators for multi-dimensional JSON arrays It fully reproduces array dimensions as in or...
TArrayI & GetIndices()
return array with current index
nlohmann::json * ExtractNode(nlohmann::json *topnode, bool next=true)
Int_t NumDimensions() const
returns number of array dimensions
Int_t TotalLength() const
returns total number of elements in array
TArrayIndexProducer(TDataMember *member, Int_t extradim, const char *separ)
const char * NextSeparator()
increment indexes and returns intermediate or last separator
TArrayIndexProducer(TStreamerElement *elem, Int_t arraylen, const char *separ)
Abstract array base class.
virtual void Streamer(TBuffer &)
static TString Decode(const char *data)
Decode a base64 string date into a generic TString.
static TString Encode(const char *data)
Transform data into a null terminated base64 string.
void InitMap() override
Create the fMap container and initialize them with the null object.
void MapObject(const TObject *obj, UInt_t offset=1) override
Add object to the fMap container.
Long64_t GetObjectTag(const void *obj)
Returns tag for specified object from objects map (if exists) Returns 0 if object not included into o...
void GetMappedObject(UInt_t tag, void *&ptr, TClass *&ClassPtr) const override
Retrieve the object stored in the buffer's object map at 'tag' Set ptr and ClassPtr respectively to t...
Int_t WriteObjectAny(const void *obj, const TClass *ptrClass, Bool_t cacheReuse=kTRUE) override
Write object to I/O buffer.
void ReadULong(ULong_t &l) final
Reads ULong_t value from buffer.
void JsonWriteBasic(Char_t value)
converts Char_t to string and add to json value buffer
void WriteShort(Short_t s) final
Writes Short_t value to buffer.
void JsonWriteCollection(TCollection *obj, const TClass *objClass)
store content of ROOT collection
TString fSemicolon
! depending from compression level, " : " or ":"
Int_t fCompact
! 0 - no any compression, 1 - no spaces in the begin, 2 - no new lines, 3 - no spaces at all
void ReadULong64(ULong64_t &l) final
Reads ULong64_t value from buffer.
void WriteStdString(const std::string *s) final
Writes a std::string.
void JsonWriteFastArray(const T *arr, Long64_t arrsize, const char *typname, void(TBufferJSON::*method)(const T *, Int_t, const char *))
Template method to write array of arbitrary dimensions Different methods can be used for store last a...
void * ReadObjectAny(const TClass *clCast) final
Read object from buffer. Only used from TBuffer.
static TObject * ConvertFromJSON(const char *str)
Read TObject-based class from JSON, produced by ConvertToJSON() method.
void ClassBegin(const TClass *, Version_t=-1) final
Should be called in the beginning of custom class streamer.
Int_t JsonReadArray(T *value)
Read static array from JSON - not used.
void IncrementLevel(TVirtualStreamerInfo *) final
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and indent new level in js...
void WriteLong(Long_t l) final
Writes Long_t value to buffer.
TString fValue
! buffer for current value
void WriteUInt(UInt_t i) final
Writes UInt_t value to buffer.
void ReadFloat(Float_t &f) final
Reads Float_t value from buffer.
static TString ConvertToJSON(const TObject *obj, Int_t compact=0, const char *member_name=nullptr)
Converts object, inherited from TObject class, to JSON string Lower digit of compact parameter define...
void WriteCharStar(char *s) final
Writes a char*.
void PerformPostProcessing(TJSONStackObj *stack, const TClass *obj_cl=nullptr)
Function is converts TObject and TString structures to more compact representation.
void ReadShort(Short_t &s) final
Reads Short_t value from buffer.
void JsonReadFastArray(T *arr, Int_t arrsize, bool asstring=false)
Template method to read array from the JSON.
TString StoreObject(const void *obj, const TClass *cl)
Store provided object as JSON structure Allows to configure different TBufferJSON properties before c...
std::deque< std::unique_ptr< TJSONStackObj > > fStack
! hierarchy of currently streamed element
void ReadChar(Char_t &c) final
Reads Char_t value from buffer.
static Int_t ExportToFile(const char *filename, const TObject *obj, const char *option=nullptr)
Convert object into JSON and store in text file Returns size of the produce file Used in TObject::Sav...
TString fNumericLocale
! stored value of setlocale(LC_NUMERIC), which should be recovered at the end
void SetTypeversionTag(const char *tag=nullptr)
Configures _typeversion tag in JSON One can specify name of the JSON tag like "_typeversion" or "$tv"...
TString fTypeVersionTag
! JSON member used to store class version, default empty
void ReadCharStar(char *&s) final
Reads a char* string.
UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE) final
Ignored in TBufferJSON.
void ReadUShort(UShort_t &s) final
Reads UShort_t value from buffer.
TJSONStackObj * PushStack(Int_t inclevel=0, void *readnode=nullptr)
add new level to the structures stack
TBufferJSON(TBuffer::EMode mode=TBuffer::kWrite)
Creates buffer object to serialize data into json.
void JsonDisablePostprocessing()
disable post-processing of the code
void WorkWithElement(TStreamerElement *elem, Int_t)
This is call-back from streamer which indicates that class member will be streamed Name of element us...
void ReadCharP(Char_t *c) final
Reads array of characters from buffer.
void ReadUChar(UChar_t &c) final
Reads UChar_t value from buffer.
void WriteUShort(UShort_t s) final
Writes UShort_t value to buffer.
unsigned fJsonrCnt
! counter for all objects, used for referencing
Int_t fArrayCompact
! 0 - no array compression, 1 - exclude leading/trailing zeros, 2 - check value repetition
void ReadFastArray(Bool_t *b, Int_t n) final
read array of Bool_t from buffer
void JsonReadBasic(T &value)
Template function to read basic value from JSON.
void JsonReadCollection(TCollection *obj, const TClass *objClass)
read content of ROOT collection
void JsonPushValue()
If value exists, push in the current stack for post-processing.
@ kStoreInfNaN
explicitly store special float numbers as strings ("inf", "nan")
@ kBase64
all binary arrays will be compressed with base64 coding, supported by JSROOT
@ kSkipTypeInfo
do not store typenames in JSON
@ kNoSpaces
no new lines plus remove all spaces around "," and ":" symbols
@ kMapAsObject
store std::map, std::unordered_map as JSON object
@ kSameSuppression
zero suppression plus compress many similar values together
void WriteULong(ULong_t l) final
Writes ULong_t value to buffer.
void SetTypenameTag(const char *tag="_typename")
Configures _typename tag in JSON structures By default "_typename" field in JSON structures used to s...
TVirtualStreamerInfo * GetInfo() final
Return current streamer info element.
~TBufferJSON() override
destroy buffer
void JsonStartElement(const TStreamerElement *elem, const TClass *base_class)
Start new class member in JSON structures.
void DecrementLevel(TVirtualStreamerInfo *) final
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and decrease level in json...
void WriteFloat(Float_t f) final
Writes Float_t value to buffer.
Bool_t IsSkipClassInfo(const TClass *cl) const
Returns true if class info will be skipped from JSON.
void ReadLong(Long_t &l) final
Reads Long_t value from buffer.
void WriteClass(const TClass *cl) final
suppressed function of TBuffer
TClass * ReadClass(const TClass *cl=nullptr, UInt_t *objTag=nullptr) final
suppressed function of TBuffer
static TString zipJSON(const char *json)
zip JSON string and convert into base64 string to be used with JSROOT unzipJSON() function Main appli...
void ClassMember(const char *name, const char *typeName=nullptr, Int_t arrsize1=-1, Int_t arrsize2=-1) final
Method indicates name and typename of class member, which should be now streamed in custom streamer F...
TString * fOutput
! current output buffer for json code
TString fTypeNameTag
! JSON member used for storing class name, when empty - no class name will be stored
static void * ConvertFromJSONAny(const char *str, TClass **cl=nullptr)
Read object from JSON In class pointer (if specified) read class is returned One must specify expecte...
void ReadUInt(UInt_t &i) final
Reads UInt_t value from buffer.
void ReadLong64(Long64_t &l) final
Reads Long64_t value from buffer.
Bool_t fStoreInfNaN
! when true, store inf and nan as string, this is not portable for other JSON readers
Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr) final
read version value from buffer
static void * ConvertFromJSONChecked(const char *str, const TClass *expectedClass)
Read objects from JSON, one can reuse existing object.
Int_t ReadStaticArray(Bool_t *b) final
Read array of Bool_t from buffer.
void WriteBool(Bool_t b) final
Writes Bool_t value to buffer.
void SetStreamerElementNumber(TStreamerElement *elem, Int_t comp_type) final
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and add/verify next elemen...
void WriteDouble(Double_t d) final
Writes Double_t value to buffer.
TString JsonWriteMember(const void *ptr, TDataMember *member, TClass *memberClass, Int_t arraylen)
Convert single data member to JSON structures Note; if data member described by 'member'is pointer,...
void ReadInt(Int_t &i) final
Reads Int_t value from buffer.
std::vector< const TClass * > fSkipClasses
! list of classes, which class info is not stored
void WriteCharP(const Char_t *c) final
Writes array of characters to buffer.
TString fArraySepar
! depending from compression level, ", " or ","
void SetSkipClassInfo(const TClass *cl)
Specify class which typename will not be stored in JSON Several classes can be configured To exclude ...
Int_t ReadArray(Bool_t *&b) final
Read array of Bool_t from buffer.
void WriteFastArray(const Bool_t *b, Long64_t n) final
Write array of Bool_t to buffer.
void AppendOutput(const char *line0, const char *line1=nullptr)
Append two string to the output JSON, normally separate by line break.
TString fOutBuffer
! main output buffer for json code
TJSONStackObj * PopStack()
remove one level from stack
void JsonWriteArrayCompress(const T *vname, Int_t arrsize, const char *typname)
void WriteInt(Int_t i) final
Writes Int_t value to buffer.
void WriteArray(const Bool_t *b, Int_t n) final
Write array of Bool_t to buffer.
void ReadBaseClass(void *start, TStreamerBase *elem) final
Read data of base class.
void ReadFastArrayString(Char_t *c, Int_t n) final
read array of Char_t from buffer
TJSONStackObj * JsonStartObjectWrite(const TClass *obj_class, TStreamerInfo *info=nullptr)
Start object element with typeinfo.
void ReadStdString(std::string *s) final
Reads a std::string.
void ReadDouble(Double_t &d) final
Reads Double_t value from buffer.
void ClassEnd(const TClass *) final
Should be called at the end of custom streamer See TBufferJSON::ClassBegin for more details.
Int_t JsonSpecialClass(const TClass *cl) const
return non-zero value when class has special handling in JSON it is TCollection (-130),...
void SkipObjectAny() final
Skip any kind of object from buffer.
void SetCompact(int level)
Set level of space/newline/array compression Lower digit of compact parameter define formatting rules...
Bool_t fMapAsObject
! when true, std::map will be converted into JSON object
void WriteUChar(UChar_t c) final
Writes UChar_t value to buffer.
void WriteTString(const TString &s) final
Writes a TString.
void JsonWriteConstChar(const char *value, Int_t len=-1, const char *=nullptr)
writes string value, processing all kind of special characters
void * RestoreObject(const char *str, TClass **cl)
Read object from JSON In class pointer (if specified) read class is returned One must specify expecte...
void WriteObjectClass(const void *actualObjStart, const TClass *actualClass, Bool_t cacheReuse) final
Write object to buffer. Only used from TBuffer.
void StreamObject(void *obj, const TClass *cl, const TClass *onFileClass=nullptr) final
stream object to/from buffer
void WriteLong64(Long64_t l) final
Writes Long64_t value to buffer.
void WriteFastArrayString(const Char_t *c, Long64_t n) final
Write array of Char_t to buffer.
void JsonReadTObjectMembers(TObject *obj, void *node=nullptr)
Read TObject data members from JSON.
void WriteULong64(ULong64_t l) final
Writes ULong64_t value to buffer.
void ReadBool(Bool_t &b) final
Reads Bool_t value from buffer.
void WriteChar(Char_t c) final
Writes Char_t value to buffer.
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...
void * JsonReadObject(void *obj, const TClass *objClass=nullptr, TClass **readClass=nullptr)
Read object from current JSON node.
void WorkWithClass(TStreamerInfo *info, const TClass *cl=nullptr)
Prepares buffer to stream data of specified class.
void ReadTString(TString &s) final
Reads a TString.
static const char * ConvertFloat(Float_t v, char *buf, unsigned len, Bool_t not_optimize=kFALSE)
convert float to string with configured format
TBufferText()
Default constructor.
static const char * ConvertDouble(Double_t v, char *buf, unsigned len, Bool_t not_optimize=kFALSE)
convert float to string with configured format
virtual void ReadBaseClass(void *start, TStreamerBase *elem)
Read data of base class.
TClass instances represent classes, structs and namespaces in the ROOT type system.
void Streamer(void *obj, TBuffer &b, const TClass *onfile_class=nullptr) const
ROOT::ESTLType GetCollectionType() const
Return the 'type' of the STL the TClass is representing.
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Bool_t HasDictionary() const
Check whether a class has a dictionary or not.
void Destructor(void *obj, Bool_t dtorOnly=kFALSE)
Explicitly call destructor for object.
Longptr_t GetDataMemberOffset(const char *membername) const
return offset for member name.
TList * GetListOfRealData() const
Int_t Size() const
Return size of object of this class.
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Int_t GetBaseClassOffset(const TClass *toBase, void *address=nullptr, bool isDerivedObject=true)
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
Version_t GetClassVersion() const
TClass * GetActualClass(const void *object) const
Return a pointer to the real class of the object.
TRealData * GetRealData(const char *name) const
Return pointer to TRealData element with name "name".
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.
An array of clone (identical) objects.
TClass * GetClass() const
void SetClass(const char *classname, Int_t size=1000)
see TClonesArray::SetClass(const TClass*)
TObject * ConstructedAt(Int_t idx)
Get an object at index 'idx' that is guaranteed to have been constructed.
Collection abstract base class.
void SetName(const char *name)
const char * GetName() const override
Return name of this collection.
virtual void Add(TObject *obj)=0
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
All ROOT classes may have RTTI (run time type identification) support added.
Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
const char * GetTrueTypeName() const
Get the desugared type name of this data member, including const and volatile qualifiers.
Int_t GetArrayDim() const
Return number of array dimensions.
Int_t GetUnitSize() const
Get the sizeof the underlying type of the data member (i.e.
Bool_t IsBasic() const
Return true if data member is a basic type, e.g. char, int, long...
Int_t IsSTLContainer()
The return type is defined in TDictionary (kVector, kList, etc.).
Bool_t IsaPointer() const
Return true if data member is a pointer.
TDataType * GetDataType() const
const char * GetTypeName() const
Get the decayed type name of this data member, removing const and volatile qualifiers,...
const char * GetArrayIndex() const
If the data member is pointer and has a valid array size in its comments GetArrayIndex returns a stri...
Basic data type descriptor (datatype information is obtained from CINT).
Int_t Size() const
Get size of basic typedef'ed type.
nlohmann::json * GetStlNode()
Bool_t AssignStl(TClass *cl, Int_t map_convert, const char *typename_tag)
Bool_t fIsPostProcessed
! indicate that value is written
Bool_t IsStreamerInfo() const
void PushValue(TString &v)
~TJSONStackObj() override
Bool_t IsStreamerElement() const
std::unique_ptr< TArrayIndexProducer > MakeReadIndexes()
int fMemberCnt
! count number of object members, normally _typename is first member
nlohmann::json * fNode
! JSON node, used for reading
int * fMemberPtr
! pointer on members counter, can be inherit from parent stack objects
std::vector< std::string > fValues
! raw values
Bool_t fAccObjects
! if true, accumulate whole objects in values
std::unique_ptr< StlRead > fStlRead
! custom structure for stl container reading
Version_t fClVersion
! keep actual class version, workaround for ReadVersion in custom streamer
void PushIntValue(Int_t v)
Int_t fLevel
! indent level
std::unique_ptr< TArrayIndexProducer > fIndx
! producer of ndim indexes
TStreamerElement * fElem
! element in streamer info
Int_t IsJsonArray(nlohmann::json *json=nullptr, const char *map_convert_type=nullptr)
checks if specified JSON node is array (compressed or not compressed) returns length of array (or -1 ...
Bool_t fIsObjStarted
! indicate that object writing started, should be closed in postprocess
Bool_t fBase64
! enable base64 coding when writing array
const char * NextMemberSeparator()
returns separator for data members
void Add(TObject *obj) override
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
Int_t IndexOf(const TObject *obj) const override
Mother of all ROOT objects.
@ kIsOnHeap
object is on heap
@ kNotDeleted
object has not been deleted
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
TObject()
TObject constructor.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
The TRealData class manages the effective list of all data members for a given class.
TDataMember * GetDataMember() const
Long_t GetThisOffset() const
TClass * GetClassPointer() const override
Returns a pointer to the TClass of this element.
Describe one element (data member) to be Streamed.
virtual const char * GetFullName() const
Return element name including dimensions, if any Note that this function stores the name into a stati...
virtual TClass * GetClassPointer() const
Returns a pointer to the TClass of this element and updates fClassObject.
virtual void SetArrayDim(Int_t dim)
Set number of array dimensions.
Int_t GetArrayDim() const
Int_t GetArrayLength() const
Int_t GetMaxIndex(Int_t i) const
const char * GetTypeName() const
virtual Bool_t IsBase() const
Return kTRUE if the element represent a base class.
virtual void SetMaxIndex(Int_t dim, Int_t max)
set maximum index for array with dimension dim
Describes a persistent version of a class.
Int_t GetClassVersion() const override
TClass * GetClass() const override
TObjArray * GetElements() const override
Int_t Atoi() const
Return integer value of string.
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
const char * Data() const
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Abstract Interface class describing Streamer information for one class.
static Bool_t CanDelete()
static function returning true if ReadBuffer can delete object
virtual TClass * GetClass() const =0
bool IsStdClass(const char *type)
return true if the class belongs to the std namespace
@ kZLIB
Use ZLIB compression.
@ kDefaultZLIB
Compression level reserved for ZLIB compression algorithm (fastest compression).
const char * fTypeTag
! type tag used for std::map stored as JSON object
nlohmann::json fValue
! temporary value reading std::map as JSON
Bool_t fFirst
! is first or second element is used in the pair
nlohmann::json * GetStlNode(nlohmann::json *prnt)
nlohmann::json::iterator fIter
! iterator for std::map stored as JSON object
Int_t fIndx
! index of object in STL container
Int_t fMap
! special iterator over STL map::key members