Logo ROOT   6.12/07
Reference Guide
TBufferJSON.h
Go to the documentation of this file.
1 // $Id$
2 // Author: Sergey Linev 4.03.2014
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TBufferJSON
13 #define ROOT_TBufferJSON
14 
15 #include "TBuffer.h"
16 #include "TString.h"
17 #include "TObjArray.h"
18 
19 #include <map>
20 
22 class TStreamerInfo;
23 class TStreamerElement;
24 class TObjArray;
25 class TMemberStreamer;
26 class TDataMember;
27 class TJSONStackObj;
28 
29 
30 class TBufferJSON : public TBuffer {
31 
32 public:
33 
34  TBufferJSON();
35  virtual ~TBufferJSON();
36 
37  void SetCompact(int level);
38 
39  static TString ConvertToJSON(const TObject *obj, Int_t compact = 0, const char *member_name = 0);
40  static TString ConvertToJSON(const void *obj, const TClass *cl, Int_t compact = 0, const char *member_name = 0);
41  static TString ConvertToJSON(const void *obj, TDataMember *member, Int_t compact = 0, Int_t arraylen = -1);
42 
43  static Int_t ExportToFile(const char* filename, const TObject *obj, const char* option = 0);
44  static Int_t ExportToFile(const char* filename, const void *obj, const TClass *cl, const char* option = 0);
45 
46  // suppress class writing/reading
47 
48  virtual TClass *ReadClass(const TClass *cl = 0, UInt_t *objTag = 0);
49  virtual void WriteClass(const TClass *cl);
50 
51  // redefined virtual functions of TBuffer
52 
53  virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss); // SL
54  virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const char *classname); // SL
55  virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion = kFALSE); // SL
56 
57  virtual void SkipVersion(const TClass *cl = 0);
58  virtual Version_t ReadVersion(UInt_t *start = 0, UInt_t *bcnt = 0, const TClass *cl = 0); // SL
60  {
61  return 0;
62  }
63  virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt = kFALSE); // SL
64 
65  virtual void *ReadObjectAny(const TClass *clCast);
66  virtual void SkipObjectAny();
67 
68  // these methods used in streamer info to indicate currently streamed element,
69  virtual void IncrementLevel(TVirtualStreamerInfo *);
70  virtual void SetStreamerElementNumber(TStreamerElement *elem, Int_t comp_type);
71  virtual void DecrementLevel(TVirtualStreamerInfo *);
72 
73  virtual void ClassBegin(const TClass *, Version_t = -1);
74  virtual void ClassEnd(const TClass *);
75  virtual void ClassMember(const char *name, const char *typeName = 0, Int_t arrsize1 = -1, Int_t arrsize2 = -1);
76 
77  virtual void WriteObject(const TObject *obj, Bool_t cacheReuse = kTRUE);
78 
80 
81  virtual void ReadFloat16(Float_t *f, TStreamerElement *ele = 0);
82  virtual void WriteFloat16(Float_t *f, TStreamerElement *ele = 0);
83  virtual void ReadDouble32(Double_t *d, TStreamerElement *ele = 0);
84  virtual void WriteDouble32(Double_t *d, TStreamerElement *ele = 0);
85  virtual void ReadWithFactor(Float_t *ptr, Double_t factor, Double_t minvalue);
86  virtual void ReadWithNbits(Float_t *ptr, Int_t nbits);
87  virtual void ReadWithFactor(Double_t *ptr, Double_t factor, Double_t minvalue);
88  virtual void ReadWithNbits(Double_t *ptr, Int_t nbits);
89 
90  virtual Int_t ReadArray(Bool_t *&b);
91  virtual Int_t ReadArray(Char_t *&c);
92  virtual Int_t ReadArray(UChar_t *&c);
93  virtual Int_t ReadArray(Short_t *&h);
94  virtual Int_t ReadArray(UShort_t *&h);
95  virtual Int_t ReadArray(Int_t *&i);
96  virtual Int_t ReadArray(UInt_t *&i);
97  virtual Int_t ReadArray(Long_t *&l);
98  virtual Int_t ReadArray(ULong_t *&l);
99  virtual Int_t ReadArray(Long64_t *&l);
100  virtual Int_t ReadArray(ULong64_t *&l);
101  virtual Int_t ReadArray(Float_t *&f);
102  virtual Int_t ReadArray(Double_t *&d);
103  virtual Int_t ReadArrayFloat16(Float_t *&f, TStreamerElement *ele = 0);
104  virtual Int_t ReadArrayDouble32(Double_t *&d, TStreamerElement *ele = 0);
105 
106  virtual Int_t ReadStaticArray(Bool_t *b);
107  virtual Int_t ReadStaticArray(Char_t *c);
108  virtual Int_t ReadStaticArray(UChar_t *c);
109  virtual Int_t ReadStaticArray(Short_t *h);
110  virtual Int_t ReadStaticArray(UShort_t *h);
111  virtual Int_t ReadStaticArray(Int_t *i);
112  virtual Int_t ReadStaticArray(UInt_t *i);
113  virtual Int_t ReadStaticArray(Long_t *l);
114  virtual Int_t ReadStaticArray(ULong_t *l);
115  virtual Int_t ReadStaticArray(Long64_t *l);
116  virtual Int_t ReadStaticArray(ULong64_t *l);
117  virtual Int_t ReadStaticArray(Float_t *f);
118  virtual Int_t ReadStaticArray(Double_t *d);
121 
122  virtual void ReadFastArray(Bool_t *b, Int_t n);
123  virtual void ReadFastArray(Char_t *c, Int_t n);
124  virtual void ReadFastArrayString(Char_t *c, Int_t n);
125  virtual void ReadFastArray(UChar_t *c, Int_t n);
126  virtual void ReadFastArray(Short_t *h, Int_t n);
127  virtual void ReadFastArray(UShort_t *h, Int_t n);
128  virtual void ReadFastArray(Int_t *i, Int_t n);
129  virtual void ReadFastArray(UInt_t *i, Int_t n);
130  virtual void ReadFastArray(Long_t *l, Int_t n);
131  virtual void ReadFastArray(ULong_t *l, Int_t n);
132  virtual void ReadFastArray(Long64_t *l, Int_t n);
133  virtual void ReadFastArray(ULong64_t *l, Int_t n);
134  virtual void ReadFastArray(Float_t *f, Int_t n);
135  virtual void ReadFastArray(Double_t *d, Int_t n);
136  virtual void ReadFastArrayFloat16(Float_t *f, Int_t n, TStreamerElement *ele = 0);
137  virtual void ReadFastArrayDouble32(Double_t *d, Int_t n, TStreamerElement *ele = 0);
138  virtual void ReadFastArrayWithFactor(Float_t *ptr, Int_t n, Double_t factor, Double_t minvalue) ;
139  virtual void ReadFastArrayWithNbits(Float_t *ptr, Int_t n, Int_t nbits);
140  virtual void ReadFastArrayWithFactor(Double_t *ptr, Int_t n, Double_t factor, Double_t minvalue);
141  virtual void ReadFastArrayWithNbits(Double_t *ptr, Int_t n, Int_t nbits) ;
142 
143  virtual void WriteArray(const Bool_t *b, Int_t n);
144  virtual void WriteArray(const Char_t *c, Int_t n);
145  virtual void WriteArray(const UChar_t *c, Int_t n);
146  virtual void WriteArray(const Short_t *h, Int_t n);
147  virtual void WriteArray(const UShort_t *h, Int_t n);
148  virtual void WriteArray(const Int_t *i, Int_t n);
149  virtual void WriteArray(const UInt_t *i, Int_t n);
150  virtual void WriteArray(const Long_t *l, Int_t n);
151  virtual void WriteArray(const ULong_t *l, Int_t n);
152  virtual void WriteArray(const Long64_t *l, Int_t n);
153  virtual void WriteArray(const ULong64_t *l, Int_t n);
154  virtual void WriteArray(const Float_t *f, Int_t n);
155  virtual void WriteArray(const Double_t *d, Int_t n);
156  virtual void WriteArrayFloat16(const Float_t *f, Int_t n, TStreamerElement *ele = 0);
157  virtual void WriteArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele = 0);
158  virtual void ReadFastArray(void *start , const TClass *cl, Int_t n = 1, TMemberStreamer *s = 0, const TClass *onFileClass = 0);
159  virtual void ReadFastArray(void **startp, const TClass *cl, Int_t n = 1, Bool_t isPreAlloc = kFALSE, TMemberStreamer *s = 0, const TClass *onFileClass = 0);
160 
161  virtual void WriteFastArray(const Bool_t *b, Int_t n);
162  virtual void WriteFastArray(const Char_t *c, Int_t n);
163  virtual void WriteFastArrayString(const Char_t *c, Int_t n);
164  virtual void WriteFastArray(const UChar_t *c, Int_t n);
165  virtual void WriteFastArray(const Short_t *h, Int_t n);
166  virtual void WriteFastArray(const UShort_t *h, Int_t n);
167  virtual void WriteFastArray(const Int_t *i, Int_t n);
168  virtual void WriteFastArray(const UInt_t *i, Int_t n);
169  virtual void WriteFastArray(const Long_t *l, Int_t n);
170  virtual void WriteFastArray(const ULong_t *l, Int_t n);
171  virtual void WriteFastArray(const Long64_t *l, Int_t n);
172  virtual void WriteFastArray(const ULong64_t *l, Int_t n);
173  virtual void WriteFastArray(const Float_t *f, Int_t n);
174  virtual void WriteFastArray(const Double_t *d, Int_t n);
175  virtual void WriteFastArrayFloat16(const Float_t *d, Int_t n, TStreamerElement *ele = 0);
176  virtual void WriteFastArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele = 0);
177  virtual void WriteFastArray(void *start, const TClass *cl, Int_t n = 1, TMemberStreamer *s = 0);
178  virtual Int_t WriteFastArray(void **startp, const TClass *cl, Int_t n = 1, Bool_t isPreAlloc = kFALSE, TMemberStreamer *s = 0);
179 
180  virtual void StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass = 0);
181  virtual void StreamObject(void *obj, const char *className, const TClass *onFileClass = 0);
182  virtual void StreamObject(void *obj, const TClass *cl, const TClass *onFileClass = 0);
183  virtual void StreamObject(TObject *obj);
184 
185  virtual void ReadBool(Bool_t &b);
186  virtual void ReadChar(Char_t &c);
187  virtual void ReadUChar(UChar_t &c);
188  virtual void ReadShort(Short_t &s);
189  virtual void ReadUShort(UShort_t &s);
190  virtual void ReadInt(Int_t &i);
191  virtual void ReadUInt(UInt_t &i);
192  virtual void ReadLong(Long_t &l);
193  virtual void ReadULong(ULong_t &l);
194  virtual void ReadLong64(Long64_t &l);
195  virtual void ReadULong64(ULong64_t &l);
196  virtual void ReadFloat(Float_t &f);
197  virtual void ReadDouble(Double_t &d);
198  virtual void ReadCharP(Char_t *c);
199  virtual void ReadTString(TString &s);
200  virtual void ReadStdString(std::string *s);
202  virtual void ReadCharStar(char* &s);
203 
204  virtual void WriteBool(Bool_t b);
205  virtual void WriteChar(Char_t c);
206  virtual void WriteUChar(UChar_t c);
207  virtual void WriteShort(Short_t s);
208  virtual void WriteUShort(UShort_t s);
209  virtual void WriteInt(Int_t i);
210  virtual void WriteUInt(UInt_t i);
211  virtual void WriteLong(Long_t l);
212  virtual void WriteULong(ULong_t l);
213  virtual void WriteLong64(Long64_t l);
214  virtual void WriteULong64(ULong64_t l);
215  virtual void WriteFloat(Float_t f);
216  virtual void WriteDouble(Double_t d);
217  virtual void WriteCharP(const Char_t *c);
218  virtual void WriteTString(const TString &s);
219  virtual void WriteStdString(const std::string *s);
221  virtual void WriteCharStar(char *s);
222 
223  virtual Int_t WriteClones(TClonesArray *a, Int_t nobjects);
224 
225  virtual Int_t WriteObjectAny(const void *obj, const TClass *ptrClass, Bool_t cacheReuse = kTRUE);
226  virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer);
227 
228  virtual Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *object);
229  virtual Int_t ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection);
230  virtual Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection);
231 
232  virtual void TagStreamerInfo(TVirtualStreamerInfo * /*info*/) {}
233 
234  virtual Bool_t CheckObject(const TObject * /*obj*/);
235 
236  virtual Bool_t CheckObject(const void * /*ptr*/, const TClass * /*cl*/);
237 
238  // abstract virtual methods from TBuffer, which should be redefined
239 
240  virtual Int_t ReadBuf(void * /*buf*/, Int_t /*max*/)
241  {
242  Error("ReadBuf", "useless");
243  return 0;
244  }
245  virtual void WriteBuf(const void * /*buf*/, Int_t /*max*/)
246  {
247  Error("WriteBuf", "useless");
248  }
249 
250  virtual char *ReadString(char * /*s*/, Int_t /*max*/)
251  {
252  Error("ReadString", "useless");
253  return 0;
254  }
255  virtual void WriteString(const char * /*s*/)
256  {
257  Error("WriteString", "useless");
258  }
259 
260  virtual Int_t GetVersionOwner() const
261  {
262  Error("GetVersionOwner", "useless");
263  return 0;
264  }
265  virtual Int_t GetMapCount() const
266  {
267  Error("GetMapCount", "useless");
268  return 0;
269  }
270  virtual void GetMappedObject(UInt_t /*tag*/, void *&/*ptr*/, TClass *&/*ClassPtr*/) const
271  {
272  Error("GetMappedObject", "useless");
273  }
274  virtual void MapObject(const TObject * /*obj*/, UInt_t /*offset*/ = 1)
275  {
276  Error("MapObject", "useless");
277  }
278  virtual void MapObject(const void * /*obj*/, const TClass * /*cl*/, UInt_t /*offset*/ = 1)
279  {
280  Error("MapObject", "useless");
281  }
282  virtual void Reset()
283  {
284  Error("Reset", "useless");
285  }
286  virtual void InitMap()
287  {
288  Error("InitMap", "useless");
289  }
290  virtual void ResetMap()
291  {
292  Error("ResetMap", "useless");
293  }
294  virtual void SetReadParam(Int_t /*mapsize*/)
295  {
296  Error("SetReadParam", "useless");
297  }
298  virtual void SetWriteParam(Int_t /*mapsize*/)
299  {
300  Error("SetWriteParam", "useless");
301  }
302 
303  virtual Version_t ReadVersionForMemberWise(const TClass * /*cl*/ = 0)
304  {
305  Error("ReadVersionForMemberWise", "useless");
306  return 0;
307  }
308  virtual UInt_t WriteVersionMemberWise(const TClass * /*cl*/, Bool_t /*useBcnt*/ = kFALSE)
309  {
310  Error("WriteVersionMemberWise", "useless");
311  return 0;
312  }
313 
315  {
316  Error("GetInfo", "useless");
317  return 0;
318  }
319 
320  virtual TObject *ReadObject(const TClass * /*cl*/)
321  {
322  Error("ReadObject", "useless");
323  return 0;
324  }
325 
326  virtual UShort_t GetPidOffset() const
327  {
328  Error("GetPidOffset", "useless");
329  return 0;
330  }
331  virtual void SetPidOffset(UShort_t /*offset*/)
332  {
333  Error("SetPidOffset", "useless");
334  }
335  virtual Int_t GetBufferDisplacement() const
336  {
337  Error("GetBufferDisplacement", "useless");
338  return 0;
339  }
340  virtual void SetBufferDisplacement()
341  {
342  Error("SetBufferDisplacement", "useless");
343  }
344  virtual void SetBufferDisplacement(Int_t /*skipped*/)
345  {
346  Error("SetBufferDisplacement", "useless");
347  }
348 
349  virtual TProcessID *GetLastProcessID(TRefTable * /*reftable*/) const
350  {
351  Error("GetLastProcessID", "useless");
352  return 0;
353  }
355  {
356  Error("GetTRefExecId", "useless");
357  return 0;
358  }
359  virtual TProcessID *ReadProcessID(UShort_t /*pidf*/)
360  {
361  Error("ReadProcessID", "useless");
362  return 0;
363  }
364  virtual UShort_t WriteProcessID(TProcessID * /*pid*/)
365  {
366  // Error("WriteProcessID", "useless");
367  return 0;
368  }
369 
370  // Utilities for TStreamerInfo
371  virtual void ForceWriteInfo(TVirtualStreamerInfo * /*info*/, Bool_t /*force*/)
372  {
373  Error("ForceWriteInfo", "useless");
374  }
375  virtual void ForceWriteInfoClones(TClonesArray * /*a*/)
376  {
377  Error("ForceWriteInfoClones", "useless");
378  }
379  virtual Int_t ReadClones(TClonesArray * /*a*/, Int_t /*nobjects*/, Version_t /*objvers*/)
380  {
381  Error("ReadClones", "useless");
382  return 0;
383  }
384 
385  // Utilities for TClass
386  virtual Int_t ReadClassEmulated(const TClass * /*cl*/, void * /*object*/, const TClass * /*onfile_class*/ = 0)
387  {
388  Error("ReadClassEmulated", "useless");
389  return 0;
390  }
391  virtual Int_t ReadClassBuffer(const TClass * /*cl*/, void * /*pointer*/, const TClass * /*onfile_class*/ = 0)
392  {
393  Error("ReadClassBuffer", "useless");
394  return 0;
395  }
396  virtual Int_t ReadClassBuffer(const TClass * /*cl*/, void * /*pointer*/, Int_t /*version*/, UInt_t /*start*/, UInt_t /*count*/, const TClass * /*onfile_class*/ = 0)
397  {
398  Error("ReadClassBuffer", "useless");
399  return 0;
400  }
401 
402  // end of redefined virtual functions
403 
404  static void SetFloatFormat(const char *fmt = "%e");
405  static const char *GetFloatFormat();
406  static void SetDoubleFormat(const char *fmt = "%.14e");
407  static const char *GetDoubleFormat();
408 
409  static void CompactFloatString(char* buf, unsigned len);
410 
411 
412 protected:
413  // redefined protected virtual functions
414 
415  virtual void WriteObjectClass(const void *actualObjStart, const TClass *actualClass, Bool_t cacheReuse);
416 
417  // end redefined protected virtual functions
418 
419  TString JsonWriteMember(const void *ptr, TDataMember *member, TClass *memberClass, Int_t arraylen);
420 
421  TJSONStackObj *PushStack(Int_t inclevel = 0);
422  TJSONStackObj *PopStack();
423  TJSONStackObj *Stack(Int_t depth = 0);
424 
425  void WorkWithClass(TStreamerInfo *info, const TClass *cl = 0);
427 
429  Int_t JsonSpecialClass(const TClass *cl) const;
430 
431  void JsonStartElement(const TStreamerElement *elem, const TClass *base_class = 0);
432 
433  void PerformPostProcessing(TJSONStackObj *stack, const TClass *obj_cl = 0);
434 
435  void JsonWriteBasic(Char_t value);
436  void JsonWriteBasic(Short_t value);
437  void JsonWriteBasic(Int_t value);
438  void JsonWriteBasic(Long_t value);
439  void JsonWriteBasic(Long64_t value);
440  void JsonWriteBasic(Float_t value);
441  void JsonWriteBasic(Double_t value);
442  void JsonWriteBasic(Bool_t value);
443  void JsonWriteBasic(UChar_t value);
444  void JsonWriteBasic(UShort_t value);
445  void JsonWriteBasic(UInt_t value);
446  void JsonWriteBasic(ULong_t value);
447  void JsonWriteBasic(ULong64_t value);
448 
449  void JsonWriteConstChar(const char* value, Int_t len = -1);
450 
451  void JsonWriteObject(const void *obj, const TClass *objClass, Bool_t check_map = kTRUE);
452 
453  void JsonStreamCollection(TCollection *obj, const TClass *objClass);
454 
455  void AppendOutput(const char *line0, const char *line1 = 0);
456 
457  TString fOutBuffer; //! main output buffer for json code
458  TString *fOutput; //! current output buffer for json code
459  TString fValue; //! buffer for current value
460  std::map<const void *, unsigned> fJsonrMap; //! map of recorded objects, used in JsonR to restore references
461  unsigned fJsonrCnt; //! counter for all objects and arrays
462  TObjArray fStack; //! stack of streamer infos
463  Int_t fCompact; //! 0 - no any compression, 1 - no spaces in the begin, 2 - no new lines, 3 - no spaces at all
464  TString fSemicolon; //! depending from compression level, " : " or ":"
465  TString fArraySepar; //! depending from compression level, ", " or ","
466  TString fNumericLocale; //! stored value of setlocale(LC_NUMERIC), which should be recovered at the end
467 
468  static const char *fgFloatFmt; //! printf argument for floats, either "%f" or "%e" or "%10f" and so on
469  static const char *fgDoubleFmt; //! printf argument for doubles, either "%f" or "%e" or "%10f" and so on
470 
471  ClassDef(TBufferJSON, 1) //a specialized TBuffer to only write objects into JSON format
472 };
473 
474 #endif
Describe Streamer information for one class version.
Definition: TStreamerInfo.h:43
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)
Ignored in TBufferJSON.
An array of TObjects.
Definition: TObjArray.h:37
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.
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.
long long Long64_t
Definition: RtypesCore.h:69
virtual UShort_t GetPidOffset() const
Definition: TBufferJSON.h:326
virtual TProcessID * ReadProcessID(UShort_t)
Return the current Process-ID.
Definition: TBufferJSON.h:359
virtual Int_t ReadArray(Bool_t *&b)
Read array of Bool_t from buffer.
void JsonDisablePostprocessing()
virtual void ReadShort(Short_t &s)
Reads Short_t value from buffer.
virtual Int_t ReadStaticArrayFloat16(Float_t *f, TStreamerElement *ele=0)
Read array of Float16_t from buffer.
short Version_t
Definition: RtypesCore.h:61
virtual void WriteLong64(Long64_t l)
Writes Long64_t value to buffer.
float Float_t
Definition: RtypesCore.h:53
virtual void ReadFloat(Float_t &f)
Reads Float_t value from buffer.
virtual void WriteBuf(const void *, Int_t)
Definition: TBufferJSON.h:245
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 Int_t WriteObjectAny(const void *obj, const TClass *ptrClass, Bool_t cacheReuse=kTRUE)
Write object to I/O buffer.
All ROOT classes may have RTTI (run time type identification) support added.
Definition: TDataMember.h:31
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 ...
Definition: TBufferJSON.h:464
virtual void SkipObjectAny()
Skip any kind of object from buffer.
unsigned short UShort_t
Definition: RtypesCore.h:36
virtual void ReadCharP(Char_t *c)
Reads array of characters from buffer.
TH1 * h
Definition: legend2.C:5
virtual void DecrementLevel(TVirtualStreamerInfo *)
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and decrease level in json...
virtual void ForceWriteInfo(TVirtualStreamerInfo *, Bool_t)
Definition: TBufferJSON.h:371
TString fArraySepar
depending from compression level, " : " or ":"
Definition: TBufferJSON.h:465
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
stack of streamer infos
Definition: TBufferJSON.h:463
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.
Definition: TBuffer.h:40
void JsonWriteBasic(Char_t value)
converts Char_t to string and add to json value buffer
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.
Basic string class.
Definition: TString.h:125
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
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
static const char * fgDoubleFmt
printf argument for floats, either "%f" or "%e" or "%10f" and so on
Definition: TBufferJSON.h:469
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.
virtual void WriteFastArrayString(const Char_t *c, Int_t n)
Write array of Char_t to buffer.
virtual Int_t ReadBuf(void *, Int_t)
Definition: TBufferJSON.h:240
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
virtual void WriteString(const char *)
Definition: TBufferJSON.h:255
virtual void ReadChar(Char_t &c)
Reads Char_t value from buffer.
virtual void ReadFastArrayDouble32(Double_t *d, Int_t n, TStreamerElement *ele=0)
read array of Double32_t from buffer
virtual Int_t GetBufferDisplacement() const
Definition: TBufferJSON.h:335
#define ClassDef(name, id)
Definition: Rtypes.h:320
virtual void WriteFastArray(const Bool_t *b, Int_t n)
Write array of Bool_t to buffer.
virtual void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE)
Convert object into json structures.
TString fOutBuffer
Definition: TBufferJSON.h:457
virtual void ReadUShort(UShort_t &s)
Reads UShort_t value from buffer.
virtual void ReadDouble(Double_t &d)
Reads Double_t value from buffer.
virtual TObject * ReadObject(const TClass *)
Definition: TBufferJSON.h:320
TJSONStackObj * Stack(Int_t depth=0)
return stack object of specified depth
virtual void ReadStdString(std::string *s)=0
virtual UInt_t WriteVersionMemberWise(const TClass *, Bool_t=kFALSE)
Definition: TBufferJSON.h:308
std::map< const void *, unsigned > fJsonrMap
buffer for current value
Definition: TBufferJSON.h:460
unsigned fJsonrCnt
map of recorded objects, used in JsonR to restore references
Definition: TBufferJSON.h:461
virtual void ReadCharStar(char *&s)
Reads a char* string.
virtual void SetWriteParam(Int_t)
Definition: TBufferJSON.h:298
TObjArray fStack
counter for all objects and arrays
Definition: TBufferJSON.h:462
virtual void ReadUChar(UChar_t &c)
Reads UChar_t value from buffer.
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition: TProcessID.h:69
virtual TVirtualStreamerInfo * GetInfo()
Definition: TBufferJSON.h:314
void SetCompact(int level)
virtual void WriteFastArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=0)
Write array of Double32_t to buffer.
virtual Version_t ReadVersionForMemberWise(const TClass *=0)
Definition: TBufferJSON.h:303
void JsonWriteConstChar(const char *value, Int_t len=-1)
writes string value, processing all kind of special characters
virtual void ForceWriteInfoClones(TClonesArray *)
Definition: TBufferJSON.h:375
virtual Int_t ReadStaticArrayDouble32(Double_t *d, TStreamerElement *ele=0)
Read array of Double32_t from buffer.
TString fNumericLocale
depending from compression level, ", " or ","
Definition: TBufferJSON.h:466
virtual void ReadInt(Int_t &i)
Reads Int_t value from buffer.
TString fValue
current output buffer for json code
Definition: TBufferJSON.h:459
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.
virtual void ResetMap()
Definition: TBufferJSON.h:290
virtual void IncrementLevel(TVirtualStreamerInfo *)
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and indent new level in js...
virtual void WriteObjectClass(const void *actualObjStart, const TClass *actualClass, Bool_t cacheReuse)
Write object to buffer. Only used from TBuffer.
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)
suppressed function of TBuffer
static Int_t ExportToFile(const char *filename, const TObject *obj, const char *option=0)
Convert object into JSON and store in text file Returns size of the produce file Used in TObject::Sav...
virtual char * ReadString(char *, Int_t)
Definition: TBufferJSON.h:250
virtual void TagStreamerInfo(TVirtualStreamerInfo *)
Definition: TBufferJSON.h:232
virtual void ReadULong(ULong_t &l)
Reads ULong_t value from buffer.
auto * a
Definition: textangle.C:12
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
Definition: TBufferJSON.h:458
Collection abstract base class.
Definition: TCollection.h:63
void AppendOutput(const char *line0, const char *line1=0)
Info("AppendOutput"," &#39;%s&#39; &#39;%s&#39;", line0, line1?line1 : "---");.
virtual void ReadDouble32(Double_t *d, TStreamerElement *ele=0)
read a Double32_t from the buffer
virtual Int_t ReadClassBuffer(const TClass *, void *, const TClass *=0)
Definition: TBufferJSON.h:391
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void MapObject(const TObject *, UInt_t=1)
Definition: TBufferJSON.h:274
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
virtual void SkipVersion(const TClass *cl=0)
Skip class version from I/O buffer.
short Short_t
Definition: RtypesCore.h:35
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
virtual void SetBufferDisplacement()
Definition: TBufferJSON.h:340
static const char * fgFloatFmt
stored value of setlocale(LC_NUMERIC), which should be recovered at the end
Definition: TBufferJSON.h:468
virtual void WriteUShort(UShort_t s)
Writes UShort_t value to buffer.
void WorkWithElement(TStreamerElement *elem, Int_t)
This is call-back from streamer which indicates that class member will be streamed Name of element us...
virtual void WriteBool(Bool_t b)
Writes Bool_t value to buffer.
virtual void WriteDouble32(Double_t *d, TStreamerElement *ele=0)
write a Double32_t to the buffer
void WorkWithClass(TStreamerInfo *info, const TClass *cl=0)
Prepares buffer to stream data of specified class.
void JsonStartElement(const TStreamerElement *elem, const TClass *base_class=0)
virtual void ReadTString(TString &s)
Reads a TString.
virtual void WriteFloat(Float_t f)
Writes Float_t value to buffer.
const Bool_t kFALSE
Definition: RtypesCore.h:88
long Long_t
Definition: RtypesCore.h:50
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.
static const char * GetFloatFormat()
return current printf format for float members, default "%e"
virtual void WriteShort(Short_t s)
Writes Short_t value to buffer.
Class for serializing object into JavaScript Object Notation (JSON) format.
Definition: TBufferJSON.h:30
virtual void ReadFloat16(Float_t *f, TStreamerElement *ele=0)
read a Float16_t from the buffer
double Double_t
Definition: RtypesCore.h:55
virtual Bool_t CheckObject(const TObject *)
Check that object already stored in the buffer.
virtual void WriteObject(const TObject *obj, Bool_t cacheReuse)=0
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 UShort_t WriteProcessID(TProcessID *)
Always return 0 (current processID).
Definition: TBufferJSON.h:364
virtual void WriteArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=0)
Write array of Double32_t to buffer.
virtual void SetReadParam(Int_t)
Definition: TBufferJSON.h:294
unsigned long long ULong64_t
Definition: RtypesCore.h:70
virtual void InitMap()
Definition: TBufferJSON.h:286
unsigned long ULong_t
Definition: RtypesCore.h:51
A TRefTable maintains the association between a referenced object and the parent object supporting th...
Definition: TRefTable.h:35
virtual void SetPidOffset(UShort_t)
Definition: TBufferJSON.h:331
static TString ConvertToJSON(const TObject *obj, Int_t compact=0, const char *member_name=0)
Converts object, inherited from TObject class, to JSON string Lower digit of compact parameter define...
virtual void * ReadObjectAny(const TClass *clCast)
Read object from buffer. Only used from TBuffer.
static constexpr double s
virtual void WriteCharStar(char *s)
Writes a char*.
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.
virtual TProcessID * GetLastProcessID(TRefTable *) const
Definition: TBufferJSON.h:349
virtual void Reset()
Definition: TBufferJSON.h:282
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.
virtual Int_t GetVersionOwner() const
Definition: TBufferJSON.h:260
virtual Version_t ReadVersionNoCheckSum(UInt_t *, UInt_t *)
Definition: TBufferJSON.h:59
Mother of all ROOT objects.
Definition: TObject.h:37
static void SetFloatFormat(const char *fmt="%e")
set printf format for float/double members, default "%e" to change format only for doubles...
TJSONStackObj * PopStack()
remove one level from stack
char Char_t
Definition: RtypesCore.h:29
virtual void StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass=0)
stream object to/from buffer
virtual void WriteChar(Char_t c)
Writes Char_t value to buffer.
An array of clone (identical) objects.
Definition: TClonesArray.h:32
virtual Int_t ReadArrayFloat16(Float_t *&f, TStreamerElement *ele=0)
Read array of Float16_t from buffer.
auto * l
Definition: textangle.C:4
virtual void WriteCharP(const Char_t *c)
Writes array of characters to buffer.
static void CompactFloatString(char *buf, unsigned len)
method compress float string, excluding exp and/or move float point
void PerformPostProcessing(TJSONStackObj *stack, const TClass *obj_cl=0)
Function is converts TObject and TString structures to more compact representation.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
TJSONStackObj * PushStack(Int_t inclevel=0)
add new level to the structures stack
virtual Int_t GetMapCount() const
Definition: TBufferJSON.h:265
virtual void MapObject(const void *, const TClass *, UInt_t=1)
Definition: TBufferJSON.h:278
virtual void SetBufferDisplacement(Int_t)
Definition: TBufferJSON.h:344
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
unsigned char UChar_t
Definition: RtypesCore.h:34
virtual void GetMappedObject(UInt_t, void *&, TClass *&) const
Definition: TBufferJSON.h:270
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 Int_t ReadClassEmulated(const TClass *, void *, const TClass *=0)
Definition: TBufferJSON.h:386
virtual void ReadFastArrayString(Char_t *c, Int_t n)
read array of Char_t from buffer
Abstract Interface class describing Streamer information for one class.
virtual void WriteStdString(const std::string *s)=0
const Bool_t kTRUE
Definition: RtypesCore.h:87
const Int_t n
Definition: legend1.C:16
virtual Int_t ReadClones(TClonesArray *, Int_t, Version_t)
Definition: TBufferJSON.h:379
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
char name[80]
Definition: TGX11.cxx:109
virtual UInt_t GetTRefExecId()
Definition: TBufferJSON.h:354
virtual Int_t ReadClassBuffer(const TClass *, void *, Int_t, UInt_t, UInt_t, const TClass *=0)
Definition: TBufferJSON.h:396
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...