41 #include "Compression.h" 67 #ifdef R__VISUAL_CPLUSPLUS 68 #define FLong64 "%I64d" 69 #define FULong64 "%I64u" 71 #define FLong64 "%lld" 72 #define FULong64 "%llu" 86 class TJSONStackObj :
public TObject {
115 virtual ~TJSONStackObj()
117 if (fIsElemOwner)
delete fElem;
120 Bool_t IsStreamerInfo()
const 122 return fIsStreamerInfo;
124 Bool_t IsStreamerElement()
const 126 return !fIsStreamerInfo && (fElem != 0);
167 char* loc = setlocale(LC_NUMERIC, 0);
168 if ((loc!=0) && (strcmp(loc,
"C")!=0)) {
170 setlocale(LC_NUMERIC,
"C");
191 void *ptr = (
void *) obj;
229 Int_t compact,
const char *member_name)
231 if ((member_name!=0) && (obj!=0)) {
233 if (rdata==0)
return TString();
235 if (member==0)
return TString();
242 arraylen = *((
int *) ((
char *) obj + idata->
GetThisOffset()));
247 if (member->
IsaPointer()) ptr = *((
char **) ptr);
270 if ((ptr == 0) || (member == 0))
return TString(
"null");
278 if ((mcl != 0) && (mcl !=
TString::Class()) && !stlstring && !isstl &&
296 if (!obj || !filename || (*filename==0))
return 0;
299 if (option && (*option >=
'0') && (*option <=
'3')) compact =
TString(option,1).
Atoi();
303 std::ofstream ofs (filename);
316 if (!obj || !cl || !filename || (*filename==0))
return 0;
319 if (option && (*option >=
'0') && (*option <=
'3')) compact =
TString(option,1).
Atoi();
323 std::ofstream ofs (filename);
337 if (member == 0)
return "null";
340 Info(
"JsonWriteMember",
"Write member %s type %s ndim %d",
352 }
else if ((member->
GetArrayDim() == 0) && (arraylen<0)) {
416 }
else if ((member->
GetArrayDim() == 1) || (arraylen>=0)) {
492 if (cnt >= 0) indexes[
cnt]++;
496 if (indexes[cnt] > 0)
501 if (++cnt == indexes.GetSize()) {
503 for (
Int_t k = 0; k < indexes.GetSize(); k++) {
504 shift = shift * member->
GetMaxIndex(k) + indexes[k];
594 ((
TClass *)memberClass)->Streamer((
void *)ptr, *
this);
602 if ((arr != 0) && (arr->
GetSize() > 0)) {
603 arr->Streamer(*
this);
605 if (
Stack()->fValues.GetLast() > 0) {
606 Warning(
"TBufferJSON",
"When streaming TArray, more than 1 object in the stack, use second item");
611 }
else if (memberClass && !strcmp(memberClass->
GetName(),
"string")) {
613 ((
TClass *)memberClass)->Streamer((
void *)ptr, *
this);
619 if ((memberClass == 0) || (member->
GetArrayDim() > 0))
return "\"not supported\"";
630 if (obj == 0)
return kTRUE;
640 if (ptr == 0)
return kTRUE;
654 Info(
"WriteObject",
"Object %p", obj);
664 TJSONStackObj *curr =
Stack();
665 TJSONStackObj *stack =
new TJSONStackObj();
666 stack->fLevel = (curr ? curr->fLevel : 0) + inclevel;
682 return dynamic_cast<TJSONStackObj *
>(
fStack.
Last());
690 TJSONStackObj *stack = 0;
706 if (strlen(line1) > 0) {
708 TJSONStackObj *stack =
Stack();
709 if ((stack != 0) && (stack->fLevel > 0))
721 const char *elem_name = 0;
723 if (base_class == 0) {
728 elem_name =
"fVector";
734 elem_name =
"fDeque";
740 elem_name =
"fMultiMap";
746 elem_name =
"fMultiSet";
749 elem_name =
"fBitSet";
752 elem_name =
"fArray";
756 elem_name =
"fString";
761 if (elem_name != 0) {
773 TJSONStackObj *stack =
Stack();
774 if (stack != 0) stack->fIsPostProcessed =
kTRUE;
783 if (cl == 0)
return 0;
787 if (isarray)
return 100;
798 if (isstlcont > 0)
return isstlcont;
801 if (isstd && !strcmp(cl->
GetName(),
"string"))
return 120;
820 Info(
"JsonWriteObject",
"Object %p class %s check_map %s", obj, cl ? cl->
GetName() :
"null", check_map ?
"true" :
"false");
824 TString fObjectOutput, *fPrevOutput(0);
826 TJSONStackObj *stack =
Stack();
828 if (stack && stack->fAccObjects && ((
fValue.
Length() > 0) || (stack->fValues.GetLast() >= 0))) {
839 }
else if ((special_kind <= 0) || (special_kind > 100)) {
849 if (special_kind <= 0) {
852 std::map<const void *, unsigned>::const_iterator iter =
fJsonrMap.find(obj);
878 Info(
"JsonWriteObject",
"Starting object %p write for class: %s",
881 stack->fAccObjects = special_kind < 10;
883 if (special_kind == -130)
886 ((
TClass *)cl)->Streamer((
void *)obj, *
this);
889 Info(
"JsonWriteObject",
"Done object %p write for class: %s",
892 if (special_kind == 100) {
893 if (stack->fValues.GetLast() != 0)
894 Error(
"JsonWriteObject",
"Problem when writing array");
895 stack->fValues.Delete();
896 }
else if ((special_kind == 110) || (special_kind == 120)) {
897 if (stack->fValues.GetLast() > 1)
898 Error(
"JsonWriteObject",
"Problem when writing TString or std::string");
899 stack->fValues.Delete();
905 if (stack->fValues.GetLast() < 0) {
907 if (
fValue !=
"0")
Error(
"JsonWriteObject",
"With empty stack fValue!=0");
909 }
else if (stack->fValues.GetLast() == 0) {
911 stack->fValues.Delete();
913 Error(
"JsonWriteObject",
"Empty value when it should contain something");
918 const char *separ =
"[";
925 Int_t size =
TString(stack->fValues.At(0)->GetName()).Atoi();
927 if ((size * 2 == stack->fValues.GetLast()) &&
930 for (
Int_t k = 1; k < stack->fValues.GetLast(); k += 2) {
946 for (
Int_t k = 1; k <= stack->fValues.GetLast(); k++) {
954 stack->fValues.Delete();
958 if ((special_kind == 0) &&
959 ((stack->fValues.GetLast() >= 0) || (
fValue.
Length() > 0))) {
961 Info(
"JsonWriteObject",
"Create blob value for class %s", cl->
GetName());
966 const char *separ =
"[";
968 for (
Int_t k = 0; k <= stack->fValues.GetLast(); k++) {
982 stack->fValues.Delete();
987 if (special_kind <= 0) {
993 if (fPrevOutput != 0) {
996 if ((special_kind <= 0) || (special_kind > 100))
998 else if (fObjectOutput.
Length() != 0)
999 Error(
"JsonWriteObject",
"Non-empty object output for special class %s", cl->
GetName());
1026 while ((obj = iter()) != 0) {
1077 if (sinfo != 0) cl = sinfo->
GetClass();
1079 if (cl == 0)
return;
1083 TJSONStackObj *stack =
Stack();
1085 if ((stack != 0) && stack->IsStreamerElement() && !stack->fIsObjStarted &&
1089 stack->fIsObjStarted =
kTRUE;
1103 stack->fInfo = sinfo;
1104 stack->fIsStreamerInfo =
kTRUE;
1116 Info(
"DecrementLevel",
"Class: %s",
1119 TJSONStackObj *stack =
Stack();
1121 if (stack->IsStreamerElement()) {
1123 Info(
"DecrementLevel",
" Perform post-processing elem: %s",
1124 stack->fElem->GetName());
1132 Error(
"DecrementLevel",
" Mismatch of streamer info");
1137 Info(
"DecrementLevel",
"Class: %s done",
1149 Info(
"SetStreamerElementNumber",
"Element name %s", elem->
GetName());
1163 TJSONStackObj *stack =
Stack();
1165 Error(
"WorkWithElement",
"stack is empty");
1170 Info(
"WorkWithElement",
" Start element %s type %d typename %s",
1173 if (stack->IsStreamerElement()) {
1177 Info(
"WorkWithElement",
" Perform post-processing elem: %s",
1178 stack->fElem->GetName());
1188 Error(
"WorkWithElement",
"Lost of stack");
1193 if (!stack->IsStreamerInfo()) {
1194 Error(
"WorkWithElement",
"Problem in Inc/Dec level");
1201 Error(
"WorkWithElement",
"streamer info returns elem = 0");
1210 Info(
"WorkWithElement",
" Expects chain for elem %s number %d",
1217 stack->fElemNumber = number;
1218 stack->fIsElemOwner = (number < 0);
1276 if (typeName == 0) typeName =
name;
1278 if ((name == 0) || (strlen(name) == 0)) {
1279 Error(
"ClassMember",
"Invalid member name");
1287 if (strcmp(typeName,
"raw:data") == 0)
1298 if (strcmp(name, typeName) == 0) {
1305 if (tname[tname.
Length() - 1] ==
'*') {
1311 Error(
"ClassMember",
"Invalid class specifier %s", typeName);
1335 }
else if ((typ_id > 0) && (typ_id < 20)) {
1352 Error(
"ClassMember",
"Invalid combination name = %s type = %s",
1374 if ((elem == 0) && stack->fIsPostProcessed)
return;
1375 if (elem == 0) elem = stack->fElem;
1376 if (elem == 0)
return;
1379 Info(
"PerformPostProcessing",
"Element %s type %s",
1382 stack->fIsPostProcessed =
kTRUE;
1385 if (stack->fIsObjStarted) {
1396 Bool_t isTArray = (strncmp(
"TArray", typname, 6) == 0);
1398 if (isTString || isSTLstring) {
1402 Info(
"PerformPostProcessing",
"reformat string value = '%s'",
fValue.
Data());
1404 stack->fValues.Delete();
1405 }
else if (isOffsetPArray) {
1408 if ((stack->fValues.GetLast() < 0) && (
fValue ==
"0")) {
1410 }
else if ((stack->fValues.GetLast() == 0) &&
1411 (strcmp(stack->fValues.Last()->GetName(),
"1") == 0)) {
1412 stack->fValues.Delete();
1414 Error(
"PerformPostProcessing",
"Wrong values for kOffsetP type %s name %s",
1415 typname, (elem ? elem->
GetName() :
"---"));
1416 stack->fValues.Delete();
1419 }
else if (isTObject) {
1420 if (stack->fValues.GetLast() != 0) {
1422 Error(
"PerformPostProcessing",
"When storing TObject, number of items %d not equal to 2", stack->fValues.GetLast());
1433 stack->fValues.Delete();
1434 }
else if (isTArray) {
1436 stack->fValues.Delete();
1444 if (stack->fValues.GetLast() >= 0) {
1447 for (
Int_t n = 0;
n <= stack->fValues.GetLast();
n++) {
1460 if (stack->fValues.GetLast() >= 0)
1519 if (start) *start = 0;
1520 if (bcnt) *bcnt = 0;
1522 if (
gDebug > 3)
Info(
"ReadVersion",
"Version = %d", res);
1554 const TClass *actualClass)
1557 Info(
"WriteObjectClass",
"Class %s", (actualClass ? actualClass->
GetName() :
" null"));
1562 #define TJSONPushValue() \ 1563 if (fValue.Length() > 0) Stack()->PushValue(fValue); 1567 #define TBufferJSON_ReadArray(tname, vname) \ 1569 if (!vname) return 0; \ 1770 #define TBufferJSON_ReadStaticArray(vname) \ 1772 if (!vname) return 0; \ 1899 #define TBufferJSON_ReadFastArray(vname) \ 1901 if (n <= 0) return; \ 1902 if (!vname) return; \ 2091 #define TJSONWriteArrayContent(vname, arrsize) \ 2093 fValue.Append("["); \ 2094 for (Int_t indx=0;indx<arrsize;indx++) { \ 2095 if (indx>0) fValue.Append(fArraySepar.Data()); \ 2096 JsonWriteBasic(vname[indx]); \ 2098 fValue.Append("]"); \ 2102 #define TBufferJSON_WriteArray(vname) \ 2105 TJSONWriteArrayContent(vname, n); \ 2233 #define TBufferJSON_WriteFastArray(vname) \ 2236 if (n <= 0) { fValue.Append("[]"); return; } \ 2237 TStreamerElement* elem = Stack(0)->fElem; \ 2238 if ((elem != 0) && (elem->GetType()>TStreamerInfo::kOffsetL) && \ 2239 (elem->GetType() < TStreamerInfo::kOffsetP) && \ 2240 (elem->GetArrayLength() != n)) fExpectedChain = kTRUE; \ 2241 if (fExpectedChain) { \ 2242 TStreamerInfo* info = Stack(1)->fInfo; \ 2243 Int_t startnumber = Stack(0)->fElemNumber; \ 2244 fExpectedChain = kFALSE; \ 2247 elem = (TStreamerElement*)info->GetElements()->At(startnumber++);\ 2248 if (index>0) JsonStartElement(elem); \ 2249 if (elem->GetType()<TStreamerInfo::kOffsetL) { \ 2250 JsonWriteBasic(vname[index]); \ 2253 TJSONWriteArrayContent((vname+index), elem->GetArrayLength());\ 2254 index+=elem->GetArrayLength(); \ 2256 PerformPostProcessing(Stack(0), elem); \ 2259 if ((elem!=0) && (elem->GetArrayDim()>1) && (elem->GetArrayLength()==n)) { \ 2260 TArrayI indexes(elem->GetArrayDim() - 1); \ 2263 while (cnt >= 0) { \ 2264 if (indexes[cnt] >= elem->GetMaxIndex(cnt)) { \ 2265 fValue.Append("]"); \ 2266 indexes[cnt--] = 0; \ 2267 if (cnt >= 0) indexes[cnt]++; \ 2270 fValue.Append(indexes[cnt] == 0 ? "[" : fArraySepar.Data()); \ 2271 if (++cnt == indexes.GetSize()) { \ 2273 for (Int_t k = 0; k < indexes.GetSize(); k++) \ 2274 shift = shift * elem->GetMaxIndex(k) + indexes[k]; \ 2275 Int_t len = elem->GetMaxIndex(indexes.GetSize()); \ 2277 TJSONWriteArrayContent((vname+shift), len); \ 2282 TJSONWriteArrayContent(vname, n); \ 2302 if (
Stack(0)->fElem != 0)
2435 Info(
"WriteFastArray",
"void *start cl %s n %d streamer %p",
2436 cl ? cl->
GetName() :
"---",
n, streamer);
2440 (*streamer)(*
this, start, 0);
2444 char *obj = (
char *)start;
2446 int size = cl->
Size();
2454 for (
Int_t j = 0; j <
n; j++, obj += size) {
2473 Info(
"WriteFastArray",
"void **startp cl %s n %d streamer %p",
2478 (*streamer)(*
this, (
void *)start, 0);
2492 for (
Int_t j = 0; j <
n; j++) {
2500 for (
Int_t j = 0; j <
n; j++) {
2503 if (!start[j]) start[j] = ((
TClass *)cl)->New();
2548 Info(
"StreamObject",
"Class: %s", (cl ? cl->
GetName() :
"none"));
2833 snprintf(buf,
sizeof(buf),
"%d", value);
2843 snprintf(buf,
sizeof(buf),
"%hd", value);
2853 snprintf(buf,
sizeof(buf),
"%d", value);
2863 snprintf(buf,
sizeof(buf),
"%ld", value);
2887 char* pnt = 0, *
exp = 0, *lastdecimal = 0, *s = sbuf;
2888 bool negative_exp =
false;
2890 while(*s && --len) {
2892 case '.': pnt = s;
break;
2894 case 'e':
exp = s;
break;
2895 case '-':
if (
exp) negative_exp =
true;
break;
2898 if ((*s <
'0') || (*s >
'9'))
return;
2899 if (
exp) power = power*10 + (*s -
'0');
else 2900 if (pnt && *s!=
'0') lastdecimal = s;
2910 if (lastdecimal) *(lastdecimal+1) = 0;
2915 if (lastdecimal) *(lastdecimal+1) = 0;
else 2918 if (!negative_exp && pnt &&
exp && (
exp-pnt > power)) {
2926 if (lastdecimal && (pnt<lastdecimal)) *(lastdecimal+1) = 0;
2929 if (negative_exp && pnt &&
exp && (power < (s-
exp))) {
2931 if (!lastdecimal) lastdecimal = pnt;
2932 *(lastdecimal+1) = 0;
2936 for (
char* pos = lastdecimal+1; pos>=pnt; --pos)
2937 *(pos+power) = *pos;
2945 if (lastdecimal) pnt = lastdecimal+1;
2948 if (*
exp==
'+') ++
exp;
else 2949 if (*
exp==
'-') *pnt++ = *
exp++;
2952 while (*
exp) *pnt++ = *
exp++;
2963 if (value ==
floor(value)) {
2964 snprintf(buf,
sizeof(buf),
"%1.0f", value);
2978 if (value ==
floor(value)) {
2979 snprintf(buf,
sizeof(buf),
"%1.0f", value);
3001 snprintf(buf,
sizeof(buf),
"%u", value);
3011 snprintf(buf,
sizeof(buf),
"%hu", value);
3021 snprintf(buf,
sizeof(buf),
"%u", value);
3031 snprintf(buf,
sizeof(buf),
"%lu", value);
3053 if (len<0) len = strlen(value);
3083 if ((c > 31) && (c < 127))
3101 if (fmt == 0) fmt =
"%e";
3120 if (fmt == 0) fmt =
"%.14e";
3144 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3145 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3146 iter != end; ++iter) {
3149 (*iter).PrintDebug(*
this, obj);
3150 (*iter)(*
this, obj);
3154 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3155 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3156 iter != end; ++iter) {
3159 (*iter)(*
this, obj);
3171 void *start_collection,
void *end_collection)
3178 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3179 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3180 iter != end; ++iter) {
3183 (*iter).PrintDebug(*
this, *(
char **)start_collection);
3184 (*iter)(*
this, start_collection, end_collection);
3188 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3189 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3190 iter != end; ++iter) {
3193 (*iter)(*
this, start_collection, end_collection);
3204 void *start_collection,
void *end_collection)
3215 void *arr0 = loopconfig->
GetFirstAddress(start_collection, end_collection);
3217 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3218 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3219 iter != end; ++iter) {
3222 (*iter).PrintDebug(*
this, arr0);
3223 (*iter)(*
this, start_collection, end_collection, loopconfig);
3227 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3228 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3229 iter != end; ++iter) {
3232 (*iter)(*
this, start_collection, end_collection, loopconfig);
3245 Info(
"WriteClones",
"Not yet tested");
3254 struct DynamicType {
3258 virtual ~DynamicType() {}
3280 Error(
"WriteObjectAny",
"ptrClass argument may not be 0");
3286 if (clActual == 0) {
3290 DynamicType *d_ptr = (DynamicType *)obj;
3292 "An object of type %s (from type_info) passed through a %s pointer was truncated (due a missing dictionary)!!!",
3293 typeid(*d_ptr).name(), ptrClass->
GetName());
3296 }
else if (clActual && (clActual != ptrClass)) {
3297 const char *temp = (
const char *) obj;
3322 sinfo = (
TStreamerInfo *)const_cast<TClass *>(cl)->GetCurrentStreamerInfo();
3324 const_cast<TClass *
>(cl)->BuildRealData(pointer);
3326 const_cast<TClass *
>(cl)->SetCurrentStreamerInfo(sinfo);
3327 const_cast<TClass *
>(cl)->RegisterStreamerInfo(sinfo);
3329 printf(
"Creating StreamerInfo for class: %s, version: %d\n",
3337 const_cast<TClass *
>(cl)->BuildRealData(pointer);
Abstract array base class.
Describe Streamer information for one class version.
virtual const char * GetName() const
Returns name of object.
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)
Ignored in TBufferJSON.
TStreamerInfoActions::TActionSequence * GetWriteObjectWiseActions()
TString JsonWriteMember(const void *ptr, TDataMember *member, TClass *memberClass, Int_t arraylen)
Convert single data member to JSON structures Returns string with converted member.
virtual void WriteUChar(UChar_t c)
Writes UChar_t value to buffer.
virtual void WriteArrayFloat16(const Float_t *f, Int_t n, TStreamerElement *ele=0)
Write array of Float16_t to buffer.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
virtual Int_t WriteClones(TClonesArray *a, Int_t nobjects)
Interface to TStreamerInfo::WriteBufferClones.
void WorkWithElement(TStreamerElement *elem, Int_t comp_type)
This is call-back from streamer which indicates that class member will be streamed Name of element us...
virtual TClass * ReadClass(const TClass *cl=0, UInt_t *objTag=0)
suppressed function of TBuffer
virtual Int_t ReadStaticArray(Bool_t *b)
Read array of Bool_t from buffer.
ActionContainer_t fActions
virtual Int_t ReadArray(Bool_t *&b)
Read array of Bool_t from buffer.
void JsonDisablePostprocessing()
virtual void ReadShort(Short_t &s)
Reads Short_t value from buffer.
virtual Int_t WriteObjectAny(const void *obj, const TClass *ptrClass)
Write object to I/O buffer.
virtual Int_t ReadStaticArrayFloat16(Float_t *f, TStreamerElement *ele=0)
Read array of Float16_t from buffer.
virtual void WriteLong64(Long64_t l)
Writes Long64_t value to buffer.
#define TBufferJSON_ReadArray(tname, vname)
virtual TClass * GetClass() const =0
TLoopConfiguration * fLoopConfig
If this is a bundle of memberwise streaming action, this configures the looping.
#define TBufferJSON_WriteFastArray(vname)
Collectable string class.
virtual void ReadFloat(Float_t &f)
Reads Float_t value from buffer.
virtual void ReadWithFactor(Float_t *ptr, Double_t factor, Double_t minvalue)
Read a Double32_t from the buffer when the factor and minimun value have been specified see comments ...
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
All ROOT classes may have RTTI (run time type identification) support added.
R__EXTERN TVirtualMutex * gInterpreterMutex
virtual void ReadWithNbits(Float_t *ptr, Int_t nbits)
Read a Float16_t from the buffer when the number of bits is specified (explicitly or not) see comment...
TString fSemicolon
0 - no any compression, 1 - no spaces in the begin, 2 - no new lines, 3 - no spaces at all ...
virtual void SkipObjectAny()
Skip any kind of object from buffer.
virtual void ReadCharP(Char_t *c)
Reads array of characters from buffer.
virtual TClass * GetClassPointer() const
Returns a pointer to the TClass of this element.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual void DecrementLevel(TVirtualStreamerInfo *)
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and decrease level in json...
TString fArraySepar
depending from compression level, " : " or ":"
virtual void ReadFastArrayWithFactor(Float_t *ptr, Int_t n, Double_t factor, Double_t minvalue)
read array of Float16_t from buffer
const char * GetTypeName() const
Get type of data member, e,g.: "class TDirectory*" -> "TDirectory".
virtual void ReadBool(Bool_t &b)
Reads Bool_t value from buffer.
Int_t fCompact
flag to resolve situation when several elements of same basic type stored as FastArray ...
virtual void WriteDouble(Double_t d)
Writes Double_t value to buffer.
virtual void ReadLong64(Long64_t &l)
Reads Long64_t value from buffer.
virtual void ReadStdString(std::string *s)
Reads a std::string.
Buffer base class used for serializing objects.
void JsonWriteBasic(Char_t value)
converts Char_t to string and add to json value buffer
virtual TObject * Remove(TObject *obj)
Remove object from array.
static void SetDoubleFormat(const char *fmt="%.14e")
set printf format for double members, default "%.14e" use it after SetFloatFormat, which also overwrites format for doubles
virtual void ReadFastArrayFloat16(Float_t *f, Int_t n, TStreamerElement *ele=0)
read array of Float16_t from buffer
virtual void WriteULong64(ULong64_t l)
Writes ULong64_t value to buffer.
Int_t JsonSpecialClass(const TClass *cl) const
return non-zero value when class has special handling in JSON it is TCollection (-130), TArray (100), TString (110), std::string (120) and STL containers (1..6)
virtual void ReadFastArray(Bool_t *b, Int_t n)
read array of Bool_t from buffer
static const char * fgDoubleFmt
printf argument for floats, either "%f" or "%e" or "%10f" and so on
virtual void ReadLong(Long_t &l)
Reads Long_t value from buffer.
virtual void WriteLong(Long_t l)
Writes Long_t value to buffer.
virtual Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *object)
Read one collection of objects from the buffer using the StreamerInfoLoopAction.
void SetParent(TObject *parent)
Set parent owning this buffer.
Option_t * GetOption() const
virtual void SetArrayDim(Int_t dim)
Set number of array dimensions.
TObject * At(Int_t idx) const
virtual void WriteFastArrayString(const Char_t *c, Int_t n)
Write array of Char_t to buffer.
virtual void SetMaxIndex(Int_t dim, Int_t max)
set maximum index for array with dimension dim
Array of integers (32 bits per element).
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void WriteInt(Int_t i)
Writes Int_t value to buffer.
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)
suppressed function of TBuffer
#define TBufferJSON_WriteArray(vname)
Int_t GetBaseClassOffset(const TClass *toBase, void *address=0, bool isDerivedObject=true)
TObject * Last() const
Return the object in the last filled slot. Returns 0 if no entries.
virtual void ReadChar(Char_t &c)
Reads Char_t value from buffer.
Bool_t IsBasic() const
Return true if data member is a basic type, e.g. char, int, long...
virtual void ReadFastArrayDouble32(Double_t *d, Int_t n, TStreamerElement *ele=0)
read array of Double32_t from buffer
virtual void * GetFirstAddress(void *start, const void *end) const =0
virtual void WriteFastArray(const Bool_t *b, Int_t n)
Write array of Bool_t to buffer.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
virtual void ReadUShort(UShort_t &s)
Reads UShort_t value from buffer.
void Clear()
Clear string without changing its capacity.
virtual void ReadDouble(Double_t &d)
Reads Double_t value from buffer.
virtual void WriteObject(const TObject *obj)
Convert object into json structures.
TJSONStackObj * Stack(Int_t depth=0)
return stack object of specified depth
TString & Append(const char *cs)
std::map< const void *, unsigned > fJsonrMap
buffer for current value
Long_t GetThisOffset() const
unsigned fJsonrCnt
map of recorded objects, used in JsonR to restore references
TDataType * GetDataType() const
TObjArray fStack
counter for all objects and arrays
virtual void ReadUChar(UChar_t &c)
Reads UChar_t value from buffer.
#define TBufferJSON_ReadStaticArray(vname)
Base class of the Configurations for the member wise looping routines.
TObject()
TObject constructor.
void SetCompact(int level)
Set level of space/newline compression 0 - no any compression 1 - exclude spaces in the begin 2 - rem...
virtual void WriteFastArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=0)
Write array of Double32_t to buffer.
void JsonWriteConstChar(const char *value, Int_t len=-1)
writes string value, processing all kind of special characters
Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
virtual Int_t ReadStaticArrayDouble32(Double_t *d, TStreamerElement *ele=0)
Read array of Double32_t from buffer.
TString fNumericLocale
depending from compression level, ", " or ","
virtual void ReadInt(Int_t &i)
Reads Int_t value from buffer.
TString fValue
current output buffer for json code
virtual void SetStreamerElementNumber(TStreamerElement *elem, Int_t comp_type)
Function is called from TStreamerInfo WriteBuffer and Readbuffer functions and add/verify next elemen...
virtual void WriteStdString(const std::string *s)
Writes a std::string.
Bool_t IsCompiled() const
Int_t GetLast() const
Return index of last object in array.
virtual void IncrementLevel(TVirtualStreamerInfo *)
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and indent new level in js...
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)
suppressed function of TBuffer
static Int_t ExportToFile(const char *filename, const TObject *obj, const char *option=0)
Convert object into JSON and store in text file Returns size of the produce file Used in TObject::Sav...
TClass * GetClass() const
void BuildOld()
rebuild the TStreamerInfo structure
virtual void TagStreamerInfo(TVirtualStreamerInfo *)
virtual void ReadULong(ULong_t &l)
Reads ULong_t value from buffer.
virtual void WriteObjectClass(const void *actualObjStart, const TClass *actualClass)
Write object to buffer. Only used from TBuffer.
Basic data type descriptor (datatype information is obtained from CINT).
TClass * GetActualClass(const void *object) const
Return a pointer the the real class of the object.
static const char * GetDoubleFormat()
return current printf format for double members, default "%.14e"
virtual void ClassBegin(const TClass *, Version_t=-1)
Should be called in the beginning of custom class streamer.
virtual Int_t ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection)
Read one collection of objects from the buffer using the StreamerInfoLoopAction.
TString * fOutput
main output buffer for json code
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
TDataMember * GetDataMember() const
Collection abstract base class.
void AppendOutput(const char *line0, const char *line1=0)
Info("AppendOutput"," '%s' '%s'", line0, line1?line1 : "---");.
virtual void ReadDouble32(Double_t *d, TStreamerElement *ele=0)
read a Double32_t from the buffer
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
char * Form(const char *fmt,...)
virtual void SkipVersion(const TClass *cl=0)
Skip class version from I/O buffer.
Int_t Size() const
Return size of object of this class.
The TRealData class manages the effective list of all data members for a given class.
Int_t GetArrayDim() const
Return number of array dimensions.
The ROOT global object gROOT contains a list of all defined classes.
ROOT::ESTLType GetCollectionType() const
Return the 'type' of the STL the TClass is representing.
static const char * fgFloatFmt
stored value of setlocale(LC_NUMERIC), which should be recovered at the end
virtual void WriteUShort(UShort_t s)
Writes UShort_t value to buffer.
virtual void WriteBool(Bool_t b)
Writes Bool_t value to buffer.
virtual void WriteDouble32(Double_t *d, TStreamerElement *ele=0)
write a Double32_t to the buffer
void WorkWithClass(TStreamerInfo *info, const TClass *cl=0)
Prepares buffer to stream data of specified class.
bool IsStdClass(const char *type)
return true if the class belongs to the std namespace
void JsonStartElement(const TStreamerElement *elem, const TClass *base_class=0)
virtual void ReadTString(TString &s)
Reads a TString.
virtual void WriteFloat(Float_t f)
Writes Float_t value to buffer.
void PerformPostProcessing(TJSONStackObj *stack, const TStreamerElement *elem=0)
Function is converts TObject and TString structures to more compact representation.
const char * GetTrueTypeName() const
Get full type description of data member, e,g.: "class TDirectory*".
virtual void WriteFastArrayFloat16(const Float_t *d, Int_t n, TStreamerElement *ele=0)
Write array of Float16_t to buffer.
Version_t GetClassVersion() const
virtual void WriteTString(const TString &s)
Writes a TString.
void Build()
Build the I/O data structure for the current class version.
static const char * GetFloatFormat()
return current printf format for float members, default "%e"
virtual void WriteShort(Short_t s)
Writes Short_t value to buffer.
virtual void ReadFloat16(Float_t *f, TStreamerElement *ele=0)
read a Float16_t from the buffer
virtual Bool_t CheckObject(const TObject *)
Check that object already stored in the buffer.
virtual void WriteUInt(UInt_t i)
Writes UInt_t value to buffer.
virtual void WriteFloat16(Float_t *f, TStreamerElement *ele=0)
write a Float16_t to the buffer
virtual void WriteULong(ULong_t l)
Writes ULong_t value to buffer.
virtual void WriteArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=0)
Write array of Double32_t to buffer.
Int_t IndexOf(const TObject *obj) const
unsigned long long ULong64_t
Bool_t fExpectedChain
stack of streamer infos
virtual Bool_t IsBase() const
Return kTRUE if the element represent a base class.
static TString ConvertToJSON(const TObject *obj, Int_t compact=0, const char *member_name=0)
converts object, inherited from TObject class, to JSON string
virtual void * ReadObjectAny(const TClass *clCast)
Read object from buffer. Only used from TBuffer.
#define R__LOCKGUARD(mutex)
TBufferJSON()
Creates buffer object to serialize data into json.
void JsonWriteObject(const void *obj, const TClass *objClass, Bool_t check_map=kTRUE)
Write object to buffer If object was written before, only pointer will be stored If check_map==kFALSE...
virtual void ReadULong64(ULong64_t &l)
Reads ULong64_t value from buffer.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
virtual void ClassEnd(const TClass *)
Should be called at the end of custom streamer See TBufferJSON::ClassBegin for more details...
virtual Int_t ReadArrayDouble32(Double_t *&d, TStreamerElement *ele=0)
Read array of Double32_t from buffer.
Mother of all ROOT objects.
TObjArray * GetElements() const
static void SetFloatFormat(const char *fmt="%e")
set printf format for float/double members, default "%e" to change format only for doubles...
Int_t IsSTLContainer()
The return type is defined in TDictionary (kVector, kList, etc.)
TJSONStackObj * PopStack()
remove one level from stack
virtual void StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass=0)
stream object to/from buffer
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
virtual void WriteChar(Char_t c)
Writes Char_t value to buffer.
An array of clone (identical) objects.
const char * GetTypeName() const
virtual Int_t ReadArrayFloat16(Float_t *&f, TStreamerElement *ele=0)
Read array of Float16_t from buffer.
virtual void WriteCharP(const Char_t *c)
Writes array of characters to buffer.
const char * GetArrayIndex() const
If the data member is pointer and has a valid array size in its comments GetArrayIndex returns a stri...
static void CompactFloatString(char *buf, unsigned len)
method compress float string, excluding exp and/or move float point 1.000000e-01 -> 0...
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
TJSONStackObj * PushStack(Int_t inclevel=0)
add new level to the structures stack
#define TBufferJSON_ReadFastArray(vname)
Int_t Atoi() const
Return integer value of string.
void SetBaseVersion(Int_t v)
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)
Function called by the Streamer functions to serialize object at p to buffer b.
void JsonStreamCollection(TCollection *obj, const TClass *objClass)
store content of collection
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)
read version value from buffer
virtual ~TBufferJSON()
destroy buffer
virtual void WriteClass(const TClass *cl)
suppressed function of TBuffer
virtual void ReadFastArrayString(Char_t *c, Int_t n)
read array of Char_t from buffer
virtual void Compress()
Remove empty slots from array.
Abstract Interface class describing Streamer information for one class.
Bool_t IsaPointer() const
Return true if data member is a pointer.
virtual void WriteArray(const Bool_t *b, Int_t n)
Write array of Bool_t to buffer.
TRealData * GetRealData(const char *name) const
Return pointer to TRealData element with name "name".
virtual void ReadFastArrayWithNbits(Float_t *ptr, Int_t n, Int_t nbits)
read array of Float16_t from buffer
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual const char * GetName() const
Return name of this collection.
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
virtual void ReadUInt(UInt_t &i)
Reads UInt_t value from buffer.
virtual void ClassMember(const char *name, const char *typeName=0, Int_t arrsize1=-1, Int_t arrsize2=-1)
Method indicates name and typename of class member, which should be now streamed in custom streamer F...
const char * Data() const
TVirtualStreamerInfo * fStreamerInfo
StreamerInfo used to derive these actions.