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" 85 class TJSONStackObj : public
TObject {
114 virtual ~TJSONStackObj()
116 if (fIsElemOwner)
delete fElem;
119 Bool_t IsStreamerInfo()
const 121 return fIsStreamerInfo;
123 Bool_t IsStreamerElement()
const 125 return !fIsStreamerInfo && (fElem != 0);
166 char* loc = setlocale(LC_NUMERIC, 0);
167 if ((loc!=0) && (strcmp(loc,
"C")!=0)) {
169 setlocale(LC_NUMERIC,
"C");
190 void *ptr = (
void *) obj;
228 Int_t compact,
const char *member_name)
230 if ((member_name!=0) && (obj!=0)) {
232 if (rdata==0)
return TString();
234 if (member==0)
return TString();
241 arraylen = *((
int *) ((
char *) obj + idata->
GetThisOffset()));
246 if (member->
IsaPointer()) ptr = *((
char **) ptr);
269 if ((ptr == 0) || (member == 0))
return TString(
"null");
277 if ((mcl != 0) && (mcl !=
TString::Class()) && !stlstring && !isstl &&
295 if (!obj || !filename || (*filename==0))
return 0;
298 if (option && (*option >=
'0') && (*option <=
'3')) compact =
TString(option,1).
Atoi();
302 std::ofstream ofs (filename);
315 if (!obj || !cl || !filename || (*filename==0))
return 0;
318 if (option && (*option >=
'0') && (*option <=
'3')) compact =
TString(option,1).
Atoi();
322 std::ofstream ofs (filename);
336 if (member == 0)
return "null";
339 Info(
"JsonWriteMember",
"Write member %s type %s ndim %d",
351 }
else if ((member->
GetArrayDim() == 0) && (arraylen<0)) {
415 }
else if ((member->
GetArrayDim() == 1) || (arraylen>=0)) {
491 if (cnt >= 0) indexes[
cnt]++;
495 if (indexes[cnt] > 0)
500 if (++cnt == indexes.GetSize()) {
502 for (
Int_t k = 0; k < indexes.GetSize(); k++) {
503 shift = shift * member->
GetMaxIndex(k) + indexes[k];
593 ((
TClass *)memberClass)->Streamer((
void *)ptr, *
this);
601 if ((arr != 0) && (arr->
GetSize() > 0)) {
602 arr->Streamer(*
this);
604 if (
Stack()->fValues.GetLast() > 0) {
605 Warning(
"TBufferJSON",
"When streaming TArray, more than 1 object in the stack, use second item");
610 }
else if (memberClass && !strcmp(memberClass->
GetName(),
"string")) {
612 ((
TClass *)memberClass)->Streamer((
void *)ptr, *
this);
618 if ((memberClass == 0) || (member->
GetArrayDim() > 0))
return "\"not supported\"";
629 if (obj == 0)
return kTRUE;
639 if (ptr == 0)
return kTRUE;
653 Info(
"WriteObject",
"Object %p", obj);
663 TJSONStackObj *curr =
Stack();
664 TJSONStackObj *stack =
new TJSONStackObj();
665 stack->fLevel = (curr ? curr->fLevel : 0) + inclevel;
681 return dynamic_cast<TJSONStackObj *
>(
fStack.
Last());
689 TJSONStackObj *stack = 0;
705 if (strlen(line1) > 0) {
707 TJSONStackObj *stack =
Stack();
708 if ((stack != 0) && (stack->fLevel > 0))
720 const char *elem_name = 0;
722 if (base_class == 0) {
727 elem_name =
"fVector";
733 elem_name =
"fDeque";
739 elem_name =
"fMultiMap";
745 elem_name =
"fMultiSet";
748 elem_name =
"fBitSet";
751 elem_name =
"fArray";
755 elem_name =
"fString";
760 if (elem_name != 0) {
772 TJSONStackObj *stack =
Stack();
773 if (stack != 0) stack->fIsPostProcessed =
kTRUE;
782 if (cl == 0)
return 0;
786 if (isarray)
return 100;
797 if (isstlcont > 0)
return isstlcont;
800 if (isstd && !strcmp(cl->
GetName(),
"string"))
return 120;
819 Info(
"JsonWriteObject",
"Object %p class %s check_map %s", obj, cl ? cl->
GetName() :
"null", check_map ?
"true" :
"false");
823 TString fObjectOutput, *fPrevOutput(0);
825 TJSONStackObj *stack =
Stack();
827 if (stack && stack->fAccObjects && ((
fValue.
Length() > 0) || (stack->fValues.GetLast() >= 0))) {
838 }
else if ((special_kind <= 0) || (special_kind > 100)) {
848 if (special_kind <= 0) {
851 std::map<const void *, unsigned>::const_iterator iter =
fJsonrMap.find(obj);
874 Info(
"JsonWriteObject",
"Starting object %p write for class: %s",
877 stack->fAccObjects = special_kind < 10;
879 if (special_kind == -130)
882 ((
TClass *)cl)->Streamer((
void *)obj, *
this);
885 Info(
"JsonWriteObject",
"Done object %p write for class: %s",
888 if (special_kind == 100) {
889 if (stack->fValues.GetLast() != 0)
890 Error(
"JsonWriteObject",
"Problem when writing array");
891 stack->fValues.Delete();
892 }
else if ((special_kind == 110) || (special_kind == 120)) {
893 if (stack->fValues.GetLast() > 1)
894 Error(
"JsonWriteObject",
"Problem when writing TString or std::string");
895 stack->fValues.Delete();
901 if (stack->fValues.GetLast() < 0) {
903 if (
fValue !=
"0")
Error(
"JsonWriteObject",
"With empty stack fValue!=0");
905 }
else if (stack->fValues.GetLast() == 0) {
907 stack->fValues.Delete();
909 Error(
"JsonWriteObject",
"Empty value when it should contain something");
914 const char *separ =
"[";
921 Int_t size =
TString(stack->fValues.At(0)->GetName()).Atoi();
923 if ((size * 2 == stack->fValues.GetLast()) &&
926 for (
Int_t k = 1; k < stack->fValues.GetLast(); k += 2) {
942 for (
Int_t k = 1; k <= stack->fValues.GetLast(); k++) {
950 stack->fValues.Delete();
954 if ((special_kind == 0) &&
955 ((stack->fValues.GetLast() >= 0) || (
fValue.
Length() > 0))) {
957 Info(
"JsonWriteObject",
"Create blob value for class %s", cl->
GetName());
962 const char *separ =
"[";
964 for (
Int_t k = 0; k <= stack->fValues.GetLast(); k++) {
978 stack->fValues.Delete();
983 if (special_kind <= 0) {
989 if (fPrevOutput != 0) {
992 if ((special_kind <= 0) || (special_kind > 100))
994 else if (fObjectOutput.
Length() != 0)
995 Error(
"JsonWriteObject",
"Non-empty object output for special class %s", cl->
GetName());
1022 while ((obj = iter()) != 0) {
1073 if (sinfo != 0) cl = sinfo->
GetClass();
1075 if (cl == 0)
return;
1079 TJSONStackObj *stack =
Stack();
1081 if ((stack != 0) && stack->IsStreamerElement() && !stack->fIsObjStarted &&
1085 stack->fIsObjStarted =
kTRUE;
1099 stack->fInfo = sinfo;
1100 stack->fIsStreamerInfo =
kTRUE;
1112 Info(
"DecrementLevel",
"Class: %s",
1115 TJSONStackObj *stack =
Stack();
1117 if (stack->IsStreamerElement()) {
1119 Info(
"DecrementLevel",
" Perform post-processing elem: %s",
1120 stack->fElem->GetName());
1128 Error(
"DecrementLevel",
" Mismatch of streamer info");
1133 Info(
"DecrementLevel",
"Class: %s done",
1145 Info(
"SetStreamerElementNumber",
"Element name %s", elem->
GetName());
1159 TJSONStackObj *stack =
Stack();
1161 Error(
"WorkWithElement",
"stack is empty");
1166 Info(
"WorkWithElement",
" Start element %s type %d typename %s",
1169 if (stack->IsStreamerElement()) {
1173 Info(
"WorkWithElement",
" Perform post-processing elem: %s",
1174 stack->fElem->GetName());
1184 Error(
"WorkWithElement",
"Lost of stack");
1189 if (!stack->IsStreamerInfo()) {
1190 Error(
"WorkWithElement",
"Problem in Inc/Dec level");
1197 Error(
"WorkWithElement",
"streamer info returns elem = 0");
1206 Info(
"WorkWithElement",
" Expects chain for elem %s number %d",
1213 stack->fElemNumber = number;
1214 stack->fIsElemOwner = (number < 0);
1272 if (typeName == 0) typeName =
name;
1274 if ((name == 0) || (strlen(name) == 0)) {
1275 Error(
"ClassMember",
"Invalid member name");
1283 if (strcmp(typeName,
"raw:data") == 0)
1294 if (strcmp(name, typeName) == 0) {
1301 if (tname[tname.
Length() - 1] ==
'*') {
1307 Error(
"ClassMember",
"Invalid class specifier %s", typeName);
1331 }
else if ((typ_id > 0) && (typ_id < 20)) {
1348 Error(
"ClassMember",
"Invalid combination name = %s type = %s",
1370 if ((elem == 0) && stack->fIsPostProcessed)
return;
1371 if (elem == 0) elem = stack->fElem;
1372 if (elem == 0)
return;
1375 Info(
"PerformPostProcessing",
"Element %s type %s",
1378 stack->fIsPostProcessed =
kTRUE;
1381 if (stack->fIsObjStarted) {
1392 Bool_t isTArray = (strncmp(
"TArray", typname, 6) == 0);
1394 if (isTString || isSTLstring) {
1398 Info(
"PerformPostProcessing",
"reformat string value = '%s'",
fValue.
Data());
1400 stack->fValues.Delete();
1401 }
else if (isOffsetPArray) {
1404 if ((stack->fValues.GetLast() < 0) && (
fValue ==
"0")) {
1406 }
else if ((stack->fValues.GetLast() == 0) &&
1407 (strcmp(stack->fValues.Last()->GetName(),
"1") == 0)) {
1408 stack->fValues.Delete();
1410 Error(
"PerformPostProcessing",
"Wrong values for kOffsetP type %s name %s",
1411 typname, (elem ? elem->
GetName() :
"---"));
1412 stack->fValues.Delete();
1415 }
else if (isTObject) {
1416 if (stack->fValues.GetLast() != 0) {
1418 Error(
"PerformPostProcessing",
"When storing TObject, number of items %d not equal to 2", stack->fValues.GetLast());
1429 stack->fValues.Delete();
1430 }
else if (isTArray) {
1432 stack->fValues.Delete();
1440 if (stack->fValues.GetLast() >= 0) {
1443 for (
Int_t n = 0;
n <= stack->fValues.GetLast();
n++) {
1456 if (stack->fValues.GetLast() >= 0)
1515 if (start) *start = 0;
1516 if (bcnt) *bcnt = 0;
1518 if (
gDebug > 3)
Info(
"ReadVersion",
"Version = %d", res);
1550 const TClass *actualClass)
1553 Info(
"WriteObjectClass",
"Class %s", (actualClass ? actualClass->
GetName() :
" null"));
1558 #define TJSONPushValue() \ 1559 if (fValue.Length() > 0) Stack()->PushValue(fValue); 1563 #define TBufferJSON_ReadArray(tname, vname) \ 1565 if (!vname) return 0; \ 1766 #define TBufferJSON_ReadStaticArray(vname) \ 1768 if (!vname) return 0; \ 1895 #define TBufferJSON_ReadFastArray(vname) \ 1897 if (n <= 0) return; \ 1898 if (!vname) return; \ 2087 #define TJSONWriteArrayContent(vname, arrsize) \ 2089 fValue.Append("["); \ 2090 for (Int_t indx=0;indx<arrsize;indx++) { \ 2091 if (indx>0) fValue.Append(fArraySepar.Data()); \ 2092 JsonWriteBasic(vname[indx]); \ 2094 fValue.Append("]"); \ 2098 #define TBufferJSON_WriteArray(vname) \ 2101 TJSONWriteArrayContent(vname, n); \ 2229 #define TBufferJSON_WriteFastArray(vname) \ 2232 if (n <= 0) { fValue.Append("[]"); return; } \ 2233 TStreamerElement* elem = Stack(0)->fElem; \ 2234 if ((elem != 0) && (elem->GetType()>TStreamerInfo::kOffsetL) && \ 2235 (elem->GetType() < TStreamerInfo::kOffsetP) && \ 2236 (elem->GetArrayLength() != n)) fExpectedChain = kTRUE; \ 2237 if (fExpectedChain) { \ 2238 TStreamerInfo* info = Stack(1)->fInfo; \ 2239 Int_t startnumber = Stack(0)->fElemNumber; \ 2240 fExpectedChain = kFALSE; \ 2243 elem = (TStreamerElement*)info->GetElements()->At(startnumber++);\ 2244 if (index>0) JsonStartElement(elem); \ 2245 if (elem->GetType()<TStreamerInfo::kOffsetL) { \ 2246 JsonWriteBasic(vname[index]); \ 2249 TJSONWriteArrayContent((vname+index), elem->GetArrayLength());\ 2250 index+=elem->GetArrayLength(); \ 2252 PerformPostProcessing(Stack(0), elem); \ 2255 if ((elem!=0) && (elem->GetArrayDim()>1) && (elem->GetArrayLength()==n)) { \ 2256 TArrayI indexes(elem->GetArrayDim() - 1); \ 2259 while (cnt >= 0) { \ 2260 if (indexes[cnt] >= elem->GetMaxIndex(cnt)) { \ 2261 fValue.Append("]"); \ 2262 indexes[cnt--] = 0; \ 2263 if (cnt >= 0) indexes[cnt]++; \ 2266 fValue.Append(indexes[cnt] == 0 ? "[" : fArraySepar.Data()); \ 2267 if (++cnt == indexes.GetSize()) { \ 2269 for (Int_t k = 0; k < indexes.GetSize(); k++) \ 2270 shift = shift * elem->GetMaxIndex(k) + indexes[k]; \ 2271 Int_t len = elem->GetMaxIndex(indexes.GetSize()); \ 2273 TJSONWriteArrayContent((vname+shift), len); \ 2278 TJSONWriteArrayContent(vname, n); \ 2298 if (
Stack(0)->fElem != 0)
2431 Info(
"WriteFastArray",
"void *start cl %s n %d streamer %p",
2432 cl ? cl->
GetName() :
"---",
n, streamer);
2436 (*streamer)(*
this, start, 0);
2440 char *obj = (
char *)start;
2442 int size = cl->
Size();
2450 for (
Int_t j = 0; j <
n; j++, obj += size) {
2469 Info(
"WriteFastArray",
"void **startp cl %s n %d streamer %p",
2474 (*streamer)(*
this, (
void *)start, 0);
2488 for (
Int_t j = 0; j <
n; j++) {
2496 for (
Int_t j = 0; j <
n; j++) {
2499 if (!start[j]) start[j] = ((
TClass *)cl)->New();
2544 Info(
"StreamObject",
"Class: %s", (cl ? cl->
GetName() :
"none"));
2827 snprintf(buf,
sizeof(buf),
"%d", value);
2837 snprintf(buf,
sizeof(buf),
"%hd", value);
2847 snprintf(buf,
sizeof(buf),
"%d", value);
2857 snprintf(buf,
sizeof(buf),
"%ld", value);
2877 if (value ==
floor(value))
2878 snprintf(buf,
sizeof(buf),
"%1.0f", value);
2890 if (value ==
floor(value))
2891 snprintf(buf,
sizeof(buf),
"%1.0f", value);
2911 snprintf(buf,
sizeof(buf),
"%u", value);
2921 snprintf(buf,
sizeof(buf),
"%hu", value);
2931 snprintf(buf,
sizeof(buf),
"%u", value);
2941 snprintf(buf,
sizeof(buf),
"%lu", value);
2963 if (len<0) len = strlen(value);
2993 if ((c > 31) && (c < 127))
3010 if (fmt == 0) fmt =
"%e";
3034 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3035 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3036 iter != end; ++iter) {
3039 (*iter).PrintDebug(*
this, obj);
3040 (*iter)(*
this, obj);
3044 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3045 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3046 iter != end; ++iter) {
3049 (*iter)(*
this, obj);
3061 void *start_collection,
void *end_collection)
3068 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3069 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3070 iter != end; ++iter) {
3073 (*iter).PrintDebug(*
this, *(
char **)start_collection);
3074 (*iter)(*
this, start_collection, end_collection);
3078 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3079 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3080 iter != end; ++iter) {
3083 (*iter)(*
this, start_collection, end_collection);
3094 void *start_collection,
void *end_collection)
3105 void *arr0 = loopconfig->
GetFirstAddress(start_collection, end_collection);
3107 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3108 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3109 iter != end; ++iter) {
3112 (*iter).PrintDebug(*
this, arr0);
3113 (*iter)(*
this, start_collection, end_collection, loopconfig);
3117 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.
fActions.end();
3118 for (TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.
fActions.begin();
3119 iter != end; ++iter) {
3122 (*iter)(*
this, start_collection, end_collection, loopconfig);
3135 Info(
"WriteClones",
"Not yet tested");
3144 struct DynamicType {
3148 virtual ~DynamicType() {}
3170 Error(
"WriteObjectAny",
"ptrClass argument may not be 0");
3176 if (clActual == 0) {
3180 DynamicType *d_ptr = (DynamicType *)obj;
3182 "An object of type %s (from type_info) passed through a %s pointer was truncated (due a missing dictionary)!!!",
3183 typeid(*d_ptr).name(), ptrClass->
GetName());
3186 }
else if (clActual && (clActual != ptrClass)) {
3187 const char *temp = (
const char *) obj;
3212 sinfo = (
TStreamerInfo *)const_cast<TClass *>(cl)->GetCurrentStreamerInfo();
3214 const_cast<TClass *
>(cl)->BuildRealData(pointer);
3216 const_cast<TClass *
>(cl)->SetCurrentStreamerInfo(sinfo);
3217 const_cast<TClass *
>(cl)->RegisterStreamerInfo(sinfo);
3219 printf(
"Creating StreamerInfo for class: %s, version: %d\n",
3227 const_cast<TClass *
>(cl)->BuildRealData(pointer);
Abstract array base class.
Describe Streamer information for one class version.
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)
Ignored in TBufferJSON.
TStreamerInfoActions::TActionSequence * GetWriteObjectWiseActions()
#define TBufferJSON_ReadFastArray(vname)
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 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()
const char * GetTypeName() const
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 const char * GetName() const
Return name of this collection.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void WriteLong64(Long64_t l)
Writes Long64_t value to buffer.
TLoopConfiguration * fLoopConfig
If this is a bundle of memberwise streaming action, this configures the looping.
Collectable string class.
Int_t GetLast() const
Return index of last object in array.
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 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...
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
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
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.
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.
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.
virtual void ReadFastArray(Bool_t *b, Int_t n)
read array of Bool_t from buffer
virtual void ReadStdString(std::string &s)
Reads a std::string.
TDataType * GetDataType() const
Bool_t IsaPointer() const
Return true if data member is a pointer.
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.
virtual Bool_t IsBase() const
Return kTRUE if the element represent a base class.
virtual void SetArrayDim(Int_t dim)
Set number of array dimensions.
virtual void WriteFastArrayString(const Char_t *c, Int_t n)
Write array of Char_t to buffer.
Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
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.
const char * GetArrayIndex() const
If the data member is pointer and has a valid array size in its comments GetArrayIndex returns a stri...
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
const char * Data() const
Int_t GetBaseClassOffset(const TClass *toBase, void *address=0, bool isDerivedObject=true)
virtual void ReadChar(Char_t &c)
Reads Char_t value from buffer.
const char * GetTrueTypeName() const
Get full type description of data member, e,g.: "class TDirectory*".
virtual void ReadFastArrayDouble32(Double_t *d, Int_t n, TStreamerElement *ele=0)
read array of Double32_t from buffer
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...
Bool_t IsCompiled() const
virtual void ReadUShort(UShort_t &s)
Reads UShort_t value from buffer.
TClass * GetActualClass(const void *object) const
Return a pointer the the real class of the object.
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.
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)
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
unsigned fJsonrCnt
map of recorded objects, used in JsonR to restore references
Int_t Atoi() const
Return integer value of string.
TObjArray fStack
counter for all objects and arrays
virtual void ReadUChar(UChar_t &c)
Reads UChar_t value from buffer.
TClass * GetClass() const
#define TBufferJSON_ReadStaticArray(vname)
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Base class of the Configurations for the member wise looping routines.
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
#define TBufferJSON_WriteArray(vname)
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...
TRealData * GetRealData(const char *name) const
Return pointer to TRealData element with name "name".
virtual void * GetFirstAddress(void *start, const void *end) const =0
const char * GetTypeName() const
Get type of data member, e,g.: "class TDirectory*" -> "TDirectory".
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...
Int_t IndexOf(const TObject *obj) const
TObjArray * GetElements() 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).
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
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
char * Form(const char *fmt,...)
virtual void SkipVersion(const TClass *cl=0)
Skip class version from I/O buffer.
The TRealData class manages the effective list of all data members for a given class.
virtual const char * GetName() const
Returns name of object.
The ROOT global object gROOT contains a list of all defined classes.
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.
Version_t GetClassVersion() const
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.
Option_t * GetOption() const
virtual void WriteFastArrayFloat16(const Float_t *d, Int_t n, TStreamerElement *ele=0)
Write array of Float16_t to buffer.
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/double 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 TClass * GetClassPointer() const
Returns a pointer to the TClass of this element.
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.
unsigned long long ULong64_t
Bool_t fExpectedChain
stack of streamer infos
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.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
#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.
static void SetFloatFormat(const char *fmt="%e")
set printf format for float/double members, default "%e"
Int_t GetArrayDim() const
Return number of array dimensions.
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
virtual void WriteStdString(const std::string &s)
Writes a std::string.
virtual void WriteChar(Char_t c)
Writes Char_t value to buffer.
TObject * Last() const
Return the object in the last filled slot. Returns 0 if no entries.
An array of clone (identical) objects.
virtual Int_t ReadArrayFloat16(Float_t *&f, TStreamerElement *ele=0)
Read array of Float16_t from buffer.
virtual TClass * GetClass() const =0
virtual void WriteCharP(const Char_t *c)
Writes array of characters to buffer.
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_ReadArray(tname, vname)
ROOT::ESTLType GetCollectionType() const
Return the 'type' of the STL the TClass is representing.
Bool_t IsBasic() const
Return true if data member is a basic type, e.g. char, int, long...
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
TDataMember * GetDataMember() const
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
TObject * At(Int_t idx) const
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.
Long_t GetThisOffset() const
#define TBufferJSON_WriteFastArray(vname)
virtual void WriteArray(const Bool_t *b, Int_t n)
Write array of Bool_t to buffer.
virtual void ReadFastArrayWithNbits(Float_t *ptr, Int_t n, Int_t nbits)
read array of Float16_t from buffer
Int_t Size() const
Return size of object of this class.
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...
TVirtualStreamerInfo * fStreamerInfo
StreamerInfo used to derive these actions.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.