132#include <nlohmann/json.hpp>
144class TArrayIndexProducer {
148 const char *fSepar{
nullptr};
160 Bool_t usearraylen = (arraylen > (isloop ? 0 : 1));
162 if (usearrayindx && (arraylen > 0)) {
167 ::Error(
"TArrayIndexProducer",
"Problem with JSON coding of element %s type %d", elem->
GetName(),
175 for (
int dim = 0; dim < elem->
GetArrayDim(); dim++)
177 fIsArray = fTotalLen > 1;
178 }
else if (usearraylen) {
179 fTotalLen = arraylen;
181 fMaxIndex[0] = arraylen;
191 TArrayIndexProducer(
TDataMember *member,
Int_t extradim,
const char *separ) : fSepar(separ)
202 for (
int dim = 0; dim < member->
GetArrayDim(); dim++) {
208 fMaxIndex[ndim - 1] = extradim;
209 fTotalLen *= extradim;
212 fIsArray = fTotalLen > 1;
216 Int_t NumDimensions()
const {
return fIndicies.
GetSize(); }
219 TArrayI &GetIndices() {
return fIndicies; };
222 Int_t TotalLength()
const {
return fTotalLen; }
224 Int_t ReduceDimension()
231 Int_t len = fMaxIndex[ndim];
234 fTotalLen = fTotalLen / len;
235 fIsArray = fTotalLen > 1;
239 Bool_t IsArray()
const {
return fIsArray; }
244 return !IsArray() || (fCnt >= fTotalLen);
247 const char *GetBegin()
267 const char *NextSeparator()
269 if (++fCnt >= fTotalLen)
277 while ((cnt >= 0) && (cnt < fIndicies.
GetSize())) {
278 if (fIndicies[cnt] >= fMaxIndex[cnt]) {
280 fIndicies[
cnt--] = 0;
285 fRes.
Append(fIndicies[cnt] == 0 ?
"[" : fSepar);
291 nlohmann::json *ExtractNode(nlohmann::json *topnode,
bool next =
true)
295 nlohmann::json *subnode = &((*((nlohmann::json *)topnode))[fIndicies[0]]);
296 for (
int k = 1; k < fIndicies.GetSize(); ++k)
297 subnode = &((*subnode)[fIndicies[k]]);
308class TJSONStackObj :
public TObject {
313 nlohmann::json::iterator fIter;
314 const char *fTypeTag{
nullptr};
315 nlohmann::json fValue;
316 nlohmann::json *GetStlNode(nlohmann::json *prnt)
319 return &(prnt->at(fIndx++));
322 nlohmann::json *json = &(prnt->at(fIndx));
323 if (!fFirst) fIndx++;
324 json = &(json->at(fFirst ?
"first" :
"second"));
331 if (fTypeTag && (fIter.key().compare(fTypeTag) == 0))
333 fValue = fIter.key();
336 fValue = fIter.value();
353 std::vector<std::string> fValues;
355 int *fMemberPtr{
nullptr};
357 std::unique_ptr<TArrayIndexProducer> fIndx;
358 nlohmann::json *fNode{
nullptr};
359 std::unique_ptr<StlRead> fStlRead;
362 TJSONStackObj() =
default;
370 Bool_t IsStreamerInfo()
const {
return fIsStreamerInfo; }
372 Bool_t IsStreamerElement()
const {
return !fIsStreamerInfo && fElem; }
376 fValues.emplace_back(
v.Data());
380 void PushIntValue(
Int_t v) { fValues.emplace_back(std::to_string(
v)); }
384 const char *NextMemberSeparator()
386 return (!fMemberPtr || ((*fMemberPtr)++ > 0)) ?
"," :
"";
389 Bool_t IsJsonString() {
return fNode && fNode->is_string(); }
394 Int_t IsJsonArray(nlohmann::json *json =
nullptr,
const char *map_convert_type =
nullptr)
399 if (map_convert_type) {
400 if (!json->is_object())
return -1;
403 for (
auto it = json->begin(); it != json->end(); ++it) {
404 if ((strlen(map_convert_type)==0) || (it.key().compare(map_convert_type) != 0)) sz++;
410 if (json->is_array())
414 if (json->is_object() && (json->count(
"$arr") == 1))
415 return json->at(
"len").get<
int>();
422 auto res = std::stoi(fValues.back());
427 std::unique_ptr<TArrayIndexProducer> MakeReadIndexes()
433 auto indx = std::make_unique<TArrayIndexProducer>(fElem, -1,
"");
436 if (!indx->IsArray() || (indx->NumDimensions() < 2))
442 Bool_t IsStl()
const {
return fStlRead.get() !=
nullptr; }
446 fStlRead = std::make_unique<StlRead>();
447 fStlRead->fMap = map_convert;
448 if (map_convert == 2) {
449 if (!fNode->is_object()) {
450 ::Error(
"TJSONStackObj::AssignStl",
"when reading %s expecting JSON object", cl->
GetName());
453 fStlRead->fIter = fNode->begin();
454 fStlRead->fTypeTag = typename_tag && (strlen(typename_tag) > 0) ? typename_tag : nullptr;
456 if (!fNode->is_array() && !(fNode->is_object() && (fNode->count(
"$arr") == 1))) {
457 ::Error(
"TJSONStackObj::AssignStl",
"when reading %s expecting JSON array", cl->
GetName());
464 nlohmann::json *GetStlNode()
466 return fStlRead ? fStlRead->GetStlNode(fNode) : fNode;
471 fStlRead.reset(
nullptr);
479 :
TBufferText(mode), fOutBuffer(), fOutput(nullptr), fValue(), fStack(), fSemicolon(
" : "), fArraySepar(
", "),
480 fNumericLocale(), fTypeNameTag(
"_typename")
489 char *loc = setlocale(LC_NUMERIC,
nullptr);
490 if (loc && (strcmp(loc,
"C") != 0)) {
492 setlocale(LC_NUMERIC,
"C");
526 TClass *clActual =
nullptr;
527 void *ptr = (
void *)obj;
532 clActual = TObject::Class();
533 else if (clActual != TObject::Class())
643 const void *actualStart = obj;
644 if (clActual && (clActual != cl)) {
649 clActual =
const_cast<TClass *
>(cl);
652 if (member_name && actualStart) {
657 while ((rdata =
dynamic_cast<TRealData *
>(iter())) !=
nullptr) {
659 if (member && strcmp(member->
GetName(), member_name) == 0)
671 arraylen = *((
int *)((
char *)actualStart + idata->
GetThisOffset()));
677 ptr = *((
char **)ptr);
714 Error(
"StoreObject",
"Can not store object into TBuffer for reading");
737 if (mcl && (mcl != TString::Class()) && !stlstring && !isstl && (mcl->
GetBaseClassOffset(TArray::Class()) != 0) &&
755 if (!obj || !filename || (*filename == 0))
758 Int_t compact = strstr(filename,
".json.gz") ? 3 : 0;
759 if (option && (*option >=
'0') && (*option <=
'3'))
764 std::ofstream ofs(filename);
766 if (strstr(filename,
".json.gz")) {
767 const char *objbuf = json.
Data();
770 unsigned long objcrc = R__crc32(0, NULL, 0);
771 objcrc = R__crc32(objcrc, (
const unsigned char *)objbuf, objlen);
774 Int_t buflen = 10 + objlen + 8;
778 char *buffer = (
char *)
malloc(buflen);
782 char *bufcur = buffer;
798 memcpy(dummy, bufcur - 6, 6);
801 unsigned long ziplen = R__memcompress(bufcur - 6, objlen + 6, (
char *)objbuf, objlen);
803 memcpy(bufcur - 6, dummy, 6);
805 bufcur += (ziplen - 6);
807 *bufcur++ = objcrc & 0xff;
808 *bufcur++ = (objcrc >> 8) & 0xff;
809 *bufcur++ = (objcrc >> 16) & 0xff;
810 *bufcur++ = (objcrc >> 24) & 0xff;
812 *bufcur++ = objlen & 0xff;
813 *bufcur++ = (objlen >> 8) & 0xff;
814 *bufcur++ = (objlen >> 16) & 0xff;
815 *bufcur++ = (objlen >> 24) & 0xff;
817 ofs.write(buffer, bufcur - buffer);
835 if (!obj || !cl || !filename || (*filename == 0))
838 Int_t compact = strstr(filename,
".json.gz") ? 3 : 0;
839 if (option && (*option >=
'0') && (*option <=
'3'))
844 std::ofstream ofs(filename);
846 if (strstr(filename,
".json.gz")) {
847 const char *objbuf = json.
Data();
850 unsigned long objcrc = R__crc32(0, NULL, 0);
851 objcrc = R__crc32(objcrc, (
const unsigned char *)objbuf, objlen);
854 Int_t buflen = 10 + objlen + 8;
858 char *buffer = (
char *)
malloc(buflen);
862 char *bufcur = buffer;
878 memcpy(dummy, bufcur - 6, 6);
881 unsigned long ziplen = R__memcompress(bufcur - 6, objlen + 6, (
char *)objbuf, objlen);
883 memcpy(bufcur - 6, dummy, 6);
885 bufcur += (ziplen - 6);
887 *bufcur++ = objcrc & 0xff;
888 *bufcur++ = (objcrc >> 8) & 0xff;
889 *bufcur++ = (objcrc >> 16) & 0xff;
890 *bufcur++ = (objcrc >> 24) & 0xff;
892 *bufcur++ = objlen & 0xff;
893 *bufcur++ = (objlen >> 8) & 0xff;
894 *bufcur++ = (objlen >> 16) & 0xff;
895 *bufcur++ = (objlen >> 24) & 0xff;
897 ofs.write(buffer, bufcur - buffer);
928 return (
TObject *)(((
char *)obj) + delta);
953 nlohmann::json docu = nlohmann::json::parse(json_str);
955 if (docu.is_null() || (!docu.is_object() && !docu.is_array()))
958 TClass *objClass =
nullptr;
988 if (!res || !resClass)
991 if (resClass == expectedClass)
996 ::Error(
"TBufferJSON::ConvertFromJSONChecked",
"expected class %s is not base for read class %s",
1002 return (
char *)res - offset;
1025 return (tid ==
kCharStar) ?
"\"\"" :
"null";
1036 if (indx.IsArray() && (tid ==
kChar_t))
1037 shift = indx.ReduceDimension();
1039 char *ppp = (
char *)ptr;
1082 }
while (!indx.IsDone());
1086 }
else if (memberClass == TString::Class()) {
1093 memberClass->
Streamer((
void *)ptr, *
this);
1102 if (arr && (arr->
GetSize() > 0)) {
1103 arr->Streamer(*
this);
1105 if (
Stack()->fValues.size() > 1) {
1106 Warning(
"TBufferJSON",
"When streaming TArray, more than 1 object in the stack, use second item");
1111 }
else if (memberClass && !strcmp(memberClass->
GetName(),
"string")) {
1113 memberClass->
Streamer((
void *)ptr, *
this);
1120 if (!memberClass || (member->
GetArrayDim() > 0) || (arraylen > 0))
1121 return "<not supported>";
1131 auto next =
new TJSONStackObj();
1132 next->fLevel = inclevel;
1134 next->fNode = (nlohmann::json *)readnode;
1135 }
else if (
fStack.size() > 0) {
1136 auto prev =
Stack();
1137 next->fLevel += prev->fLevel;
1138 next->fMemberPtr = prev->fMemberPtr;
1140 fStack.emplace_back(next);
1152 return fStack.size() > 0 ?
fStack.back().get() :
nullptr;
1167 if (strlen(line1) > 0) {
1169 if (
Stack()->fLevel > 0)
1185 stack->fMemberPtr = &stack->fMemberCnt;
1204 stack->fMemberCnt = 0;
1216 const char *elem_name =
nullptr;
1219 switch (special_kind) {
1246 nlohmann::json *json =
Stack()->fNode;
1248 if (json->count(elem_name) != 1) {
1249 Error(
"JsonStartElement",
"Missing JSON structure for element %s", elem_name);
1251 Stack()->fNode = &((*json)[elem_name]);
1254 Stack()->PushIntValue(len > 0 ? len : 0);
1256 Error(
"JsonStartElement",
"Missing array when reading TArray class for element %s", elem->
GetName());
1258 if ((
gDebug > 1) && base_class)
1259 Info(
"JsonStartElement",
"Reading baseclass %s from element %s", base_class->
GetName(), elem_name);
1288 isarray = (
const_cast<TClass *
>(cl))->GetBaseClassOffset(TArray::Class()) == 0;
1293 if ((
const_cast<TClass *
>(cl))->GetBaseClassOffset(TCollection::Class()) == 0)
1297 if (cl == TString::Class())
1308 if (isstd && !strcmp(cl->
GetName(),
"string"))
1325 Info(
"JsonWriteObject",
"Object %p class %s check_map %s", obj, cl ? cl->
GetName() :
"null",
1326 check_map ?
"true" :
"false");
1330 TString fObjectOutput, *fPrevOutput{
nullptr};
1332 TJSONStackObj *stack =
Stack();
1334 if (stack && stack->fAccObjects && ((
fValue.
Length() > 0) || (stack->fValues.size() > 0))) {
1338 stack->PushValue(
fValue);
1343 }
else if ((special_kind <= 0) || (special_kind >
json_TArray)) {
1349 if ((
fMapAsObject && (
fStack.size()==1)) || (stack && stack->fElem && strstr(stack->fElem->GetTitle(),
"JSON_object")))
1360 if (special_kind <= 0) {
1378 }
else if (map_convert == 2) {
1384 fValue.
Form(
"{\"$ref\":%u}", (
unsigned)(refid - 1));
1395 bool base64 = ((special_kind ==
TClassEdit::kVector) && stack && stack->fElem && strstr(stack->fElem->GetTitle(),
"JSON_base64"));
1401 stack->fBase64 = base64;
1405 Info(
"JsonWriteObject",
"Starting object %p write for class: %s", obj, cl->
GetName());
1412 (
const_cast<TClass *
>(cl))->Streamer((
void *)obj, *
this);
1415 Info(
"JsonWriteObject",
"Done object %p write for class: %s", obj, cl->
GetName());
1418 if (stack->fValues.size() != 1)
1419 Error(
"JsonWriteObject",
"Problem when writing array");
1420 stack->fValues.clear();
1422 if (stack->fValues.size() > 2)
1423 Error(
"JsonWriteObject",
"Problem when writing TString or std::string");
1424 stack->fValues.clear();
1427 }
else if ((special_kind > 0) && (special_kind <
ROOT::kSTLend)) {
1430 if (map_convert == 2) {
1434 stack->PushValue(
fValue);
1436 const char *separ = (
fCompact < 2) ?
", " :
",";
1437 const char *semi = (
fCompact < 2) ?
": " :
":";
1451 for (
Int_t k = 1; k < (
int)stack->fValues.size() - 1; k += 2) {
1460 stack->fValues.clear();
1461 }
else if (stack->fValues.empty()) {
1464 Error(
"JsonWriteObject",
"With empty stack fValue!=0");
1468 auto size = std::stoi(stack->fValues[0]);
1470 bool trivial_format =
false;
1472 if ((stack->fValues.size() == 1) && ((size > 1) || ((
fValue.
Length() > 1) && (
fValue[0]==
'[')))) {
1475 TClass *value_class = proxy ? proxy->GetValueClass() :
nullptr;
1477 trivial_format =
false;
1479 trivial_format =
true;
1482 if (trivial_format) {
1484 stack->fValues.clear();
1486 Error(
"JsonWriteObject",
"Empty value when it should contain something");
1491 const char *separ =
"[";
1494 stack->PushValue(
fValue);
1496 if ((size * 2 == (
int) stack->fValues.size() - 1) && (map_convert > 0)) {
1500 if (pairtype.
Index(
"unordered_map<") == 0)
1501 pairtype.
Replace(0, 14,
"pair<");
1502 else if (pairtype.
Index(
"unordered_multimap<") == 0)
1503 pairtype.
Replace(0, 19,
"pair<");
1504 else if (pairtype.
Index(
"multimap<") == 0)
1505 pairtype.
Replace(0, 9,
"pair<");
1506 else if (pairtype.
Index(
"map<") == 0)
1507 pairtype.
Replace(0, 4,
"pair<");
1514 for (
Int_t k = 1; k < (
int) stack->fValues.size() - 1; k += 2) {
1534 for (
Int_t k = 1; k < (
int) stack->fValues.size(); k++) {
1542 stack->fValues.clear();
1550 if ((special_kind == 0) && (!stack->fValues.empty() || (
fValue.
Length() > 0))) {
1552 Info(
"JsonWriteObject",
"Create blob value for class %s", cl->
GetName());
1557 const char *separ =
"[";
1559 for (
auto &elem: stack->fValues) {
1573 stack->fValues.clear();
1578 if ((special_kind <= 0))
1586 if ((special_kind <= 0) || (special_kind >
json_TArray))
1588 else if (fObjectOutput.
Length() != 0)
1589 Error(
"JsonWriteObject",
"Non-empty object output for special class %s", cl->
GetName());
1610 TMap *map =
nullptr;
1612 map =
dynamic_cast<TMap *
>(col);
1623 while ((obj = iter()) !=
nullptr) {
1675 TList *lst =
nullptr;
1676 TMap *map =
nullptr;
1679 lst =
dynamic_cast<TList *
>(col);
1681 map =
dynamic_cast<TMap *
>(col);
1685 nlohmann::json *json =
Stack()->fNode;
1687 std::string
name = json->at(
"name");
1690 nlohmann::json &arr = json->at(
"arr");
1691 int size = arr.size();
1693 for (
int n = 0;
n < size; ++
n) {
1694 nlohmann::json *subelem = &arr.at(
n);
1697 subelem = &subelem->at(
"first");
1701 TClass *readClass =
nullptr, *objClass =
nullptr;
1702 void *subobj =
nullptr;
1710 Error(
"JsonReadCollection",
1711 "Cannot detect class name for TClonesArray - typename tag not configured");
1714 }
else if (size > clones->
GetSize()) {
1715 Error(
"JsonReadCollection",
"TClonesArray size %d smaller than required %d", clones->
GetSize(), size);
1730 if (!subobj || !readClass) {
1733 Error(
"JsonReadCollection",
"Try to add object %s not derived from TObject", readClass->
GetName());
1742 readClass =
nullptr;
1747 if (!subobj2 || !readClass) {
1750 Error(
"JsonReadCollection",
"Try to add object %s not derived from TObject", readClass->
GetName());
1754 map->
Add(tobj,
static_cast<TObject *
>(subobj2));
1756 std::string opt = json->at(
"opt").at(
n).get<std::string>();
1757 lst->
Add(tobj, opt.c_str());
1771 *readClass =
nullptr;
1773 TJSONStackObj *stack =
Stack();
1775 Bool_t process_stl = stack->IsStl();
1776 nlohmann::json *json = stack->GetStlNode();
1779 if (json->is_null())
1785 if (json->is_object() && (json->size() == 1) && (json->find(
"$ref") != json->end())) {
1786 unsigned refid = json->at(
"$ref").get<
unsigned>();
1788 void *ref_obj =
nullptr;
1789 TClass *ref_cl =
nullptr;
1793 if (!ref_obj || !ref_cl) {
1794 Error(
"JsonReadObject",
"Fail to find object for reference %u", refid);
1799 *readClass = ref_cl;
1802 Info(
"JsonReadObject",
"Extract object reference %u %p cl:%s expects:%s", refid, ref_obj, ref_cl->
GetName(),
1803 (objClass ? objClass->
GetName() :
"---"));
1811 obj = objClass->
New();
1814 Info(
"JsonReadObject",
"Read string from %s", json->dump().c_str());
1817 *((std::string *)obj) = json->get<std::string>();
1819 *((
TString *)obj) = json->get<std::string>().c_str();
1822 *readClass =
const_cast<TClass *
>(objClass);
1827 Bool_t isBase = (stack->fElem && objClass) ? stack->fElem->IsBase() :
kFALSE;
1829 if (isBase && (!obj || !objClass)) {
1830 Error(
"JsonReadObject",
"No object when reading base class");
1834 Int_t map_convert = 0;
1837 map_convert = json->is_object() ? 2 : 1;
1845 TClass *jsonClass =
nullptr;
1846 Int_t jsonClassVersion = 0;
1850 jsonClass =
const_cast<TClass *
>(objClass);
1853 obj = jsonClass->
New();
1857 stack->PushIntValue(len > 0 ? len : 0);
1860 Error(
"JsonReadObject",
"Not array when expecting such %s", json->dump().c_str());
1863 Info(
"JsonReadObject",
"Reading special kind %d %s ptr %p", special_kind, objClass->
GetName(), obj);
1865 }
else if (isBase) {
1868 jsonClass =
const_cast<TClass *
>(objClass);
1871 Info(
"JsonReadObject",
"Reading baseclass %s ptr %p", objClass->
GetName(), obj);
1878 Error(
"JsonReadObject",
"Cannot find class %s", clname.c_str());
1881 jsonClass =
const_cast<TClass *
>(objClass);
1893 if (objClass && (jsonClass != objClass)) {
1896 Error(
"JsonReadObject",
"Not possible to read %s and casting to %s pointer as the two classes are unrelated",
1899 Error(
"JsonReadObject",
"Reading %s and casting to %s pointer is currently not supported",
1908 obj = jsonClass->
New();
1911 Info(
"JsonReadObject",
"Reading object of class %s refid %u ptr %p", jsonClass->
GetName(),
fJsonrCnt, obj);
1924 if ((jsonClass == TObject::Class()) || (jsonClass == TRef::Class())) {
1942 stack->fClVersion = jsonClassVersion ? jsonClassVersion : jsonClass->
GetClassVersion();
1945 Info(
"JsonReadObject",
"Calling streamer of class %s", jsonClass->
GetName());
1947 if (isBase && (special_kind == 0))
1948 Error(
"JsonReadObject",
"Should not be used for reading of base class %s", jsonClass->
GetName());
1951 jsonClass->
Streamer((
void *)obj, *
this);
1953 stack->fClVersion = 0;
1963 Info(
"JsonReadObject",
"Reading object of class %s done", jsonClass->
GetName());
1966 *readClass = jsonClass;
1977 nlohmann::json *json = node ? (nlohmann::json *)node :
Stack()->fNode;
1979 UInt_t uid = json->at(
"fUniqueID").get<
unsigned>();
1980 UInt_t bits = json->at(
"fBits").get<
unsigned>();
1985 static auto tobj_fbits_offset = TObject::Class()->GetDataMemberOffset(
"fBits");
1988 if (tobj_fbits_offset > 0) {
1989 UInt_t *fbits = (
UInt_t *) ((
char* ) tobj + tobj_fbits_offset);
2020 Info(
"WorkWithClass",
"Class: %s", cl->
GetName());
2022 TJSONStackObj *stack =
Stack();
2026 }
else if (stack && stack->IsStreamerElement() && !stack->fIsObjStarted &&
2030 stack->fIsObjStarted =
kTRUE;
2039 stack->fInfo = sinfo;
2040 stack->fIsStreamerInfo =
kTRUE;
2052 TJSONStackObj *stack =
Stack();
2054 if (stack->IsStreamerElement()) {
2058 Info(
"DecrementLevel",
" Perform post-processing elem: %s", stack->fElem->GetName());
2067 Error(
"DecrementLevel",
" Mismatch of streamer info");
2072 Info(
"DecrementLevel",
"Class: %s done", (info ? info->
GetClass()->
GetName() :
"custom"));
2080 return Stack()->fInfo;
2091 Info(
"SetStreamerElementNumber",
"Element name %s", elem->
GetName());
2103 TJSONStackObj *stack =
Stack();
2105 Error(
"WorkWithElement",
"stack is empty");
2110 Info(
"WorkWithElement",
" Start element %s type %d typename %s", elem ? elem->
GetName() :
"---",
2113 if (stack->IsStreamerElement()) {
2118 Info(
"WorkWithElement",
" Perform post-processing elem: %s", stack->fElem->GetName());
2128 Error(
"WorkWithElement",
"Lost of stack");
2133 if (!stack->IsStreamerInfo()) {
2134 Error(
"WorkWithElement",
"Problem in Inc/Dec level");
2141 Error(
"WorkWithElement",
"streamer info returns elem = nullptr");
2148 stack->fElem = elem;
2149 stack->fIsElemOwner = (number < 0);
2158 stack->fIndx = std::make_unique<TArrayIndexProducer>(elem, -1,
fArraySepar.
Data());
2166 stack->PushIntValue(stack->IsJsonString() || (stack->IsJsonArray() > 0) ? 1 : 0);
2236 if (!
name || (strlen(
name) == 0)) {
2237 Error(
"ClassMember",
"Invalid member name");
2245 if (strcmp(typeName,
"raw:data") == 0)
2255 if (strcmp(
name, typeName) == 0) {
2263 if (tname[tname.
Length() - 1] ==
'*') {
2269 Error(
"ClassMember",
"Invalid class specifier %s", typeName);
2278 if ((cl == TString::Class()) && !isptr)
2293 }
else if ((typ_id > 0) && (typ_id < 20)) {
2309 Error(
"ClassMember",
"Invalid combination name = %s type = %s",
name, typeName);
2329 if (stack->fIsPostProcessed)
2334 if (!elem && !obj_cl)
2337 stack->fIsPostProcessed =
kTRUE;
2340 if (stack->fIsObjStarted) {
2349 if (obj_cl == TObject::Class())
2351 else if (obj_cl == TRef::Class())
2361 isTArray = (strncmp(
"TArray", typname, 6) == 0);
2364 if (isTString || isSTLstring) {
2368 Info(
"PerformPostProcessing",
"reformat string value = '%s'",
fValue.
Data());
2370 stack->fValues.clear();
2371 }
else if (isOffsetPArray) {
2374 if (stack->fValues.empty() && (
fValue ==
"0")) {
2376 }
else if ((stack->fValues.size() == 1) && (stack->fValues[0] ==
"1")) {
2377 stack->fValues.clear();
2379 Error(
"PerformPostProcessing",
"Wrong values for kOffsetP element %s", (elem ? elem->
GetName() :
"---"));
2380 stack->fValues.clear();
2383 }
else if (isTObject || isTRef) {
2388 Int_t cnt = stack->fValues.size();
2392 if (cnt < 2 || cnt > 3) {
2394 Error(
"PerformPostProcessing",
"When storing TObject/TRef, strange number of items %d", cnt);
2395 AppendOutput(stack->NextMemberSeparator(),
"\"dummy\"");
2398 AppendOutput(stack->NextMemberSeparator(),
"\"fUniqueID\"");
2401 AppendOutput(stack->NextMemberSeparator(),
"\"fBits\"");
2403 auto tbits = std::atol((stack->fValues.size() > 1) ? stack->fValues[1].c_str() :
fValue.
Data());
2406 AppendOutput(stack->NextMemberSeparator(),
"\"fPID\"");
2411 stack->fValues.clear();
2416 }
else if (isTArray) {
2418 stack->fValues.clear();
2426 if (!stack->fValues.empty()) {
2429 for (
auto &blob: stack->fValues) {
2442 if (!stack->fValues.empty())
2471 if (!cl &&
Stack()->fClVersion) {
2472 res =
Stack()->fClVersion;
2473 Stack()->fClVersion = 0;
2477 Info(
"ReadVersion",
"Result: %d Class: %s", res, (cl ? cl->
GetName() :
"---"));
2496 Info(
"ReadObjectAny",
"From current JSON node");
2512 Info(
"WriteObjectClass",
"Class %s", (actualClass ? actualClass->
GetName() :
" null"));
2633template <
typename T>
2636 Info(
"ReadArray",
"Not implemented");
2637 return value ? 1 : 0;
2747template <
typename T>
2750 if (!arr || (arrsize <= 0))
2752 nlohmann::json *json =
Stack()->fNode;
2754 Info(
"ReadFastArray",
"Reading array sz %d from JSON %s", arrsize, json->dump().substr(0, 30).c_str());
2755 auto indexes =
Stack()->MakeReadIndexes();
2757 TArrayI &indx = indexes->GetIndices();
2759 if (indexes->TotalLength() != arrsize)
2760 Error(
"ReadFastArray",
"Mismatch %d-dim array sizes %d %d", lastdim + 1, arrsize, (
int)indexes->TotalLength());
2761 for (
int cnt = 0; cnt < arrsize; ++cnt) {
2762 nlohmann::json *elem = &(json->at(indx[0]));
2763 for (
int k = 1; k < lastdim; ++k)
2764 elem = &((*elem)[indx[k]]);
2765 arr[cnt] = (asstring && elem->is_string()) ? elem->get<std::string>()[indx[lastdim]] : (*elem)[indx[lastdim]].get<T>();
2766 indexes->NextSeparator();
2768 }
else if (asstring && json->is_string()) {
2769 std::string str = json->get<std::string>();
2770 for (
int cnt = 0; cnt < arrsize; ++cnt)
2771 arr[cnt] = (cnt < (
int)str.length()) ? str[cnt] : 0;
2772 }
else if (json->is_object() && (json->count(
"$arr") == 1)) {
2773 if (json->at(
"len").get<
int>() != arrsize)
2774 Error(
"ReadFastArray",
"Mismatch compressed array size %d %d", arrsize, json->at(
"len").get<
int>());
2776 for (
int cnt = 0; cnt < arrsize; ++cnt)
2779 if (json->count(
"b") == 1) {
2780 auto base64 = json->at(
"b").get<std::string>();
2782 int offset = (json->count(
"o") == 1) ? json->at(
"o").get<
int>() : 0;
2787 if (arrsize * (
long)
sizeof(T) < (offset +
decode.Length())) {
2788 Error(
"ReadFastArray",
"Base64 data %ld larger than target array size %ld", (
long)
decode.Length() + offset, (
long) (arrsize*
sizeof(T)));
2789 }
else if ((
sizeof(T) > 1) && (
decode.Length() %
sizeof(T) != 0)) {
2790 Error(
"ReadFastArray",
"Base64 data size %ld not matches with element size %ld", (
long)
decode.Length(), (
long)
sizeof(T));
2792 memcpy((
char *) arr + offset,
decode.Data(),
decode.Length());
2798 std::string
idname =
"", pname, vname, nname;
2799 while (p < arrsize) {
2800 pname = std::string(
"p") +
idname;
2801 if (json->count(pname) == 1)
2802 p = json->at(pname).get<
int>();
2803 vname = std::string(
"v") +
idname;
2804 if (json->count(vname) != 1)
2806 nlohmann::json &
v = json->at(vname);
2808 for (
unsigned sub = 0; sub <
v.size(); ++sub)
2809 arr[p++] =
v[sub].get<T>();
2811 nname = std::string(
"n") +
idname;
2812 unsigned ncopy = (json->count(nname) == 1) ? json->at(nname).get<
unsigned>() : 1;
2813 for (
unsigned sub = 0; sub < ncopy; ++sub)
2814 arr[p++] =
v.get<T>();
2816 idname = std::to_string(++
id);
2819 if ((
int)json->size() != arrsize)
2820 Error(
"ReadFastArray",
"Mismatch array sizes %d %d", arrsize, (
int)json->size());
2821 for (
int cnt = 0; cnt < arrsize; ++cnt)
2822 arr[cnt] = json->at(cnt).get<T>();
2948 Info(
"ReadFastArray",
"void* n:%d cl:%s",
n, cl->
GetName());
2957 int objectSize = cl->
Size();
2958 char *obj = (
char *)start;
2960 TJSONStackObj *stack =
Stack();
2961 nlohmann::json *topnode = stack->fNode, *subnode = topnode;
2963 subnode = stack->fIndx->ExtractNode(topnode);
2965 TArrayIndexProducer indexes(stack->fElem,
n,
"");
2968 Info(
"ReadFastArray",
"Indexes ndim:%d totallen:%d", indexes.NumDimensions(), indexes.TotalLength());
2970 for (
Int_t j = 0; j <
n; j++, obj += objectSize) {
2972 stack->fNode = indexes.ExtractNode(subnode);
2978 stack->fNode = topnode;
2988 Info(
"ReadFastArray",
"void** n:%d cl:%s prealloc:%s",
n, cl->
GetName(), (isPreAlloc ?
"true" :
"false"));
3003 TJSONStackObj *stack =
Stack();
3004 nlohmann::json *topnode = stack->fNode, *subnode = topnode;
3006 subnode = stack->fIndx->ExtractNode(topnode);
3008 TArrayIndexProducer indexes(stack->fElem,
n,
"");
3010 for (
Int_t j = 0; j <
n; j++) {
3012 stack->fNode = indexes.ExtractNode(subnode);
3015 void *old = start[j];
3021 start[j] = (
const_cast<TClass *
>(cl))->New();
3026 stack->fNode = topnode;
3029template <
typename T>
3034 if (!is_base64 && ((
fArrayCompact == 0) || (arrsize < 6))) {
3036 for (
Int_t indx = 0; indx < arrsize; indx++) {
3042 }
else if (is_base64 && !arrsize) {
3047 Int_t aindx(0), bindx(arrsize);
3048 while ((aindx < arrsize) && (vname[aindx] == 0))
3050 while ((aindx < bindx) && (vname[bindx - 1] == 0))
3055 if ((aindx *
sizeof(T) < 5) && (aindx < bindx))
3058 if ((aindx > 0) && (aindx < bindx))
3068 }
else if (aindx < bindx) {
3070 Int_t p(aindx), suffixcnt(-1), lastp(0);
3072 if (vname[p] == 0) {
3076 Int_t p0(p++), pp(0), nsame(1);
3082 for (; p <= bindx; ++p) {
3083 if ((p < bindx) && (vname[p] == vname[p - 1])) {
3087 if (vname[p - 1] == 0) {
3092 }
else if (nsame > 5) {
3105 if (++suffixcnt > 0)
3106 suffix.
Form(
"%d", suffixcnt);
3111 if ((nsame > 1) || (pp - p0 == 1)) {
3117 for (
Int_t indx = p0; indx < pp; indx++) {
3252template <
typename T>
3276 if (++cnt == indexes.
GetSize()) {
3277 (*this.*method)((arr + shift), len, typname);
3283 (*this.*method)(arr, arrsize, typname);
3304 Bool_t need_blob =
false;
3306 for (
int i=0;i<
n;++i) {
3309 }
else if (has_zero || !isprint(
c[i])) {
3315 if (need_blob && (
n >= 1000) && (!
Stack()->fElem || (
Stack()->fElem->GetArrayDim() < 2)))
3316 Stack()->fBase64 =
true;
3423 Info(
"WriteFastArray",
"void *start cl:%s n:%d", cl ? cl->
GetName() :
"---",
n);
3437 char *obj = (
char *)start;
3440 int size = cl->
Size();
3444 if (indexes.IsArray()) {
3449 for (
Int_t j = 0; j <
n; j++, obj += size) {
3462 if (indexes.IsArray())
3477 Info(
"WriteFastArray",
"void **startp cl:%s n:%d", cl->
GetName(),
n);
3492 if (indexes.IsArray()) {
3497 for (
Int_t j = 0; j <
n; j++) {
3506 start[j] = (
const_cast<TClass *
>(cl))->New();
3517 if (indexes.IsArray())
3532 Info(
"StreamObject",
"Class: %s", (cl ? cl->
GetName() :
"none"));
3543template <
typename T>
3546 value =
Stack()->GetStlNode()->get<T>();
3562 if (!
Stack()->fValues.empty())
3597 if (!
Stack()->fValues.empty())
3598 val =
Stack()->PopIntValue();
3648 nlohmann::json *json =
Stack()->GetStlNode();
3649 if (json->is_null())
3650 val = std::numeric_limits<Float_t>::quiet_NaN();
3660 nlohmann::json *json =
Stack()->GetStlNode();
3661 if (json->is_null())
3662 val = std::numeric_limits<Double_t>::quiet_NaN();
3672 Error(
"ReadCharP",
"Not implemented");
3706 std::size_t nch = str.length();
3708 s =
new char[nch + 1];
3709 memcpy(s, str.c_str(), nch);
3880 snprintf(buf,
sizeof(buf),
"%d", value);
3890 snprintf(buf,
sizeof(buf),
"%hd", value);
3900 snprintf(buf,
sizeof(buf),
"%d", value);
3910 snprintf(buf,
sizeof(buf),
"%ld", value);
3927 if (std::isinf(value)) {
3929 }
else if (std::isnan(value)) {
3943 if (std::isinf(value)) {
3945 }
else if (std::isnan(value)) {
3968 snprintf(buf,
sizeof(buf),
"%u", value);
3978 snprintf(buf,
sizeof(buf),
"%hu", value);
3988 snprintf(buf,
sizeof(buf),
"%u", value);
3998 snprintf(buf,
sizeof(buf),
"%lu", value);
4024 len = strlen(value);
4040 if ((
c > 31) && (
c < 127))
unsigned long long ULong64_t
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
char * Form(const char *fmt,...)
Array of integers (32 bits per element).
void Set(Int_t n)
Set size of this array to n ints.
Abstract array base class.
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.
Class for serializing object to and from JavaScript Object Notation (JSON) format.
R__ALWAYS_INLINE void JsonWriteArrayCompress(const T *vname, Int_t arrsize, const char *typname)
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 * 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.
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.
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...
R__ALWAYS_INLINE Int_t JsonReadArray(T *value)
Read static array from JSON - not used.
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 JsonReadCollection(TCollection *obj, const TClass *objClass)
read content of ROOT collection
virtual ~TBufferJSON()
destroy buffer
void JsonPushValue()
If value exists, push in the current stack for post-processing.
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...
void WriteFastArray(const Bool_t *b, Int_t n) final
Write array of Bool_t to buffer.
TVirtualStreamerInfo * GetInfo() final
Return current streamer info element.
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
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...
@ kBase64
all binary arrays will be compressed with base64 coding, supported by JSROOT
@ kNoSpaces
no new lines plus remove all spaces around "," and ":" symbols
@ kMapAsObject
store std::map, std::unodered_map as JSON object
@ kSameSuppression
zero suppression plus compress many similar values together
R__ALWAYS_INLINE void JsonWriteFastArray(const T *arr, Int_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 ReadUInt(UInt_t &i) final
Reads UInt_t value from buffer.
void ReadLong64(Long64_t &l) final
Reads Long64_t value from buffer.
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 Returns string with converted member.
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 ","
R__ALWAYS_INLINE void JsonReadFastArray(T *arr, Int_t arrsize, bool asstring=false)
Template method to read array from the JSON.
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 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 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 WriteFastArrayString(const Char_t *c, Int_t n) final
Write array of Char_t to 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 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.
R__ALWAYS_INLINE void JsonReadBasic(T &value)
Template function to read basic value from JSON.
void ReadTString(TString &s) final
Reads a TString.
Base class for text-based streamers like TBufferJSON or TBufferXML Special actions list will use meth...
static const char * ConvertFloat(Float_t v, char *buf, unsigned len, Bool_t not_optimize=kFALSE)
convert float to string with configured format
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.
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.
void Destructor(void *obj, Bool_t dtorOnly=kFALSE)
Explicitly call destructor for object.
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=0, bool isDerivedObject=true)
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
void Streamer(void *obj, TBuffer &b, const TClass *onfile_class=0) const
Version_t GetClassVersion() const
TClass * GetActualClass(const void *object) const
Return a pointer the 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.
virtual const char * GetName() const
Return name of this collection.
void SetName(const char *name)
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 full type description of data member, e,g.: "class TDirectory*".
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 type of data member, e,g.: "class TDirectory*" -> "TDirectory".
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).
Option_t * GetOption() const
virtual void Add(TObject *obj)
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection).
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
virtual void Clear(Option_t *option="")
Set name and title to empty strings ("").
virtual const char * GetName() const
Returns name of object.
Int_t IndexOf(const TObject *obj) const
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 SetUniqueID(UInt_t uid)
Set the unique object id.
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
virtual TClass * GetClassPointer() const
Returns a pointer to the TClass of this element.
virtual TClass * GetClassPointer() const
Returns a pointer to the TClass of this element.
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
Describe Streamer information for one class version.
TObjArray * GetElements() const
TClass * GetClass() const
Int_t GetClassVersion() const
Int_t Atoi() const
Return integer value of string.
void Clear()
Clear string without changing its capacity.
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
#define decode(ptr, otri)