Logo ROOT  
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 "TBufferText.h"
16 #include "TString.h"
17 
18 #include <deque>
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
24 class TStreamerInfo;
25 class TStreamerElement;
26 class TMemberStreamer;
27 class TDataMember;
28 class TJSONStackObj;
29 
30 class TBufferJSON final : public TBufferText {
31 
32 public:
33 
34  enum {
35  // values 0..3 are exclusive, define text formating, JSON data are same
36  kNoCompress = 0, ///< no any compression, maximal size of JSON (default)
37  kNoIndent = 1, ///< remove spaces in the beginning showing JSON indentation level
38  kNoNewLine = 2, ///< no indent plus skip newline symbols
39  kNoSpaces = 3, ///< no new lines plus remove all spaces around "," and ":" symbols
40 
41  kMapAsObject = 5, ///< store std::map, std::unodered_map as JSON object
42 
43  // algorithms for array compression - exclusive
44  kZeroSuppression = 10, ///< if array has much zeros in begin and/or end, they will be removed
45  kSameSuppression = 20, ///< zero suppression plus compress many similar values together
46  kBase64 = 30, ///< all binary arrays will be compressed with base64 coding, supported by JSROOT
47 
48  kSkipTypeInfo = 100 // do not store typenames in JSON
49  };
50 
52  virtual ~TBufferJSON();
53 
54  void SetCompact(int level);
55  void SetTypenameTag(const char *tag = "_typename");
56  void SetTypeversionTag(const char *tag = nullptr);
57  void SetSkipClassInfo(const TClass *cl);
58  Bool_t IsSkipClassInfo(const TClass *cl) const;
59 
60  TString StoreObject(const void *obj, const TClass *cl);
61  void *RestoreObject(const char *str, TClass **cl);
62 
63  static TString ConvertToJSON(const TObject *obj, Int_t compact = 0, const char *member_name = nullptr);
64  static TString
65  ConvertToJSON(const void *obj, const TClass *cl, Int_t compact = 0, const char *member_name = nullptr);
66  static TString ConvertToJSON(const void *obj, TDataMember *member, Int_t compact = 0, Int_t arraylen = -1);
67 
68  static Int_t ExportToFile(const char *filename, const TObject *obj, const char *option = nullptr);
69  static Int_t ExportToFile(const char *filename, const void *obj, const TClass *cl, const char *option = nullptr);
70 
71  static TObject *ConvertFromJSON(const char *str);
72  static void *ConvertFromJSONAny(const char *str, TClass **cl = nullptr);
73 
74  template <class T>
75  static TString ToJSON(const T *obj, Int_t compact = 0, const char *member_name = nullptr)
76  {
77  return ConvertToJSON(obj, TClass::GetClass<T>(), compact, member_name);
78  }
79 
80  template <class T>
81  static Bool_t FromJSON(T *&obj, const char *json)
82  {
83  if (obj)
84  return kFALSE;
85  obj = (T *)ConvertFromJSONChecked(json, TClass::GetClass<T>());
86  return obj != nullptr;
87  }
88 
89  template <class T>
90  static std::unique_ptr<T> FromJSON(const std::string &json)
91  {
92  T *obj = (T *)ConvertFromJSONChecked(json.c_str(), TClass::GetClass<T>());
93  return std::unique_ptr<T>(obj);
94  }
95 
96  // suppress class writing/reading
97 
98  TClass *ReadClass(const TClass *cl = nullptr, UInt_t *objTag = nullptr) final;
99  void WriteClass(const TClass *cl) final;
100 
101  // redefined virtual functions of TBuffer
102 
103  Version_t ReadVersion(UInt_t *start = nullptr, UInt_t *bcnt = nullptr, const TClass *cl = nullptr) final;
104  UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt = kFALSE) final;
105 
106  void *ReadObjectAny(const TClass *clCast) final;
107  void SkipObjectAny() final;
108 
109  // these methods used in streamer info to indicate currently streamed element,
110  void IncrementLevel(TVirtualStreamerInfo *) final;
111  void SetStreamerElementNumber(TStreamerElement *elem, Int_t comp_type) final;
112  void DecrementLevel(TVirtualStreamerInfo *) final;
113 
114  void ClassBegin(const TClass *, Version_t = -1) final;
115  void ClassEnd(const TClass *) final;
116  void ClassMember(const char *name, const char *typeName = nullptr, Int_t arrsize1 = -1, Int_t arrsize2 = -1) final;
117 
118  Int_t ReadArray(Bool_t *&b) final;
119  Int_t ReadArray(Char_t *&c) final;
120  Int_t ReadArray(UChar_t *&c) final;
121  Int_t ReadArray(Short_t *&h) final;
122  Int_t ReadArray(UShort_t *&h) final;
123  Int_t ReadArray(Int_t *&i) final;
124  Int_t ReadArray(UInt_t *&i) final;
125  Int_t ReadArray(Long_t *&l) final;
126  Int_t ReadArray(ULong_t *&l) final;
127  Int_t ReadArray(Long64_t *&l) final;
128  Int_t ReadArray(ULong64_t *&l) final;
129  Int_t ReadArray(Float_t *&f) final;
130  Int_t ReadArray(Double_t *&d) final;
131 
132  Int_t ReadStaticArray(Bool_t *b) final;
133  Int_t ReadStaticArray(Char_t *c) final;
134  Int_t ReadStaticArray(UChar_t *c) final;
135  Int_t ReadStaticArray(Short_t *h) final;
137  Int_t ReadStaticArray(Int_t *i) final;
138  Int_t ReadStaticArray(UInt_t *i) final;
139  Int_t ReadStaticArray(Long_t *l) final;
140  Int_t ReadStaticArray(ULong_t *l) final;
143  Int_t ReadStaticArray(Float_t *f) final;
145 
146  void ReadFastArray(Bool_t *b, Int_t n) final;
147  void ReadFastArray(Char_t *c, Int_t n) final;
148  void ReadFastArrayString(Char_t *c, Int_t n) final;
149  void ReadFastArray(UChar_t *c, Int_t n) final;
150  void ReadFastArray(Short_t *h, Int_t n) final;
151  void ReadFastArray(UShort_t *h, Int_t n) final;
152  void ReadFastArray(Int_t *i, Int_t n) final;
153  void ReadFastArray(UInt_t *i, Int_t n) final;
154  void ReadFastArray(Long_t *l, Int_t n) final;
155  void ReadFastArray(ULong_t *l, Int_t n) final;
156  void ReadFastArray(Long64_t *l, Int_t n) final;
157  void ReadFastArray(ULong64_t *l, Int_t n) final;
158  void ReadFastArray(Float_t *f, Int_t n) final;
159  void ReadFastArray(Double_t *d, Int_t n) final;
160  void ReadFastArray(void *start, const TClass *cl, Int_t n = 1, TMemberStreamer *s = nullptr,
161  const TClass *onFileClass = nullptr) final;
162  void ReadFastArray(void **startp, const TClass *cl, Int_t n = 1, Bool_t isPreAlloc = kFALSE,
163  TMemberStreamer *s = nullptr, const TClass *onFileClass = nullptr) final;
164 
165  void WriteArray(const Bool_t *b, Int_t n) final;
166  void WriteArray(const Char_t *c, Int_t n) final;
167  void WriteArray(const UChar_t *c, Int_t n) final;
168  void WriteArray(const Short_t *h, Int_t n) final;
169  void WriteArray(const UShort_t *h, Int_t n) final;
170  void WriteArray(const Int_t *i, Int_t n) final;
171  void WriteArray(const UInt_t *i, Int_t n) final;
172  void WriteArray(const Long_t *l, Int_t n) final;
173  void WriteArray(const ULong_t *l, Int_t n) final;
174  void WriteArray(const Long64_t *l, Int_t n) final;
175  void WriteArray(const ULong64_t *l, Int_t n) final;
176  void WriteArray(const Float_t *f, Int_t n) final;
177  void WriteArray(const Double_t *d, Int_t n) final;
178 
179  void WriteFastArray(const Bool_t *b, Int_t n) final;
180  void WriteFastArray(const Char_t *c, Int_t n) final;
181  void WriteFastArrayString(const Char_t *c, Int_t n) final;
182  void WriteFastArray(const UChar_t *c, Int_t n) final;
183  void WriteFastArray(const Short_t *h, Int_t n) final;
184  void WriteFastArray(const UShort_t *h, Int_t n) final;
185  void WriteFastArray(const Int_t *i, Int_t n) final;
186  void WriteFastArray(const UInt_t *i, Int_t n) final;
187  void WriteFastArray(const Long_t *l, Int_t n) final;
188  void WriteFastArray(const ULong_t *l, Int_t n) final;
189  void WriteFastArray(const Long64_t *l, Int_t n) final;
190  void WriteFastArray(const ULong64_t *l, Int_t n) final;
191  void WriteFastArray(const Float_t *f, Int_t n) final;
192  void WriteFastArray(const Double_t *d, Int_t n) final;
193  void WriteFastArray(void *start, const TClass *cl, Int_t n = 1, TMemberStreamer *s = nullptr) final;
194  Int_t WriteFastArray(void **startp, const TClass *cl, Int_t n = 1, Bool_t isPreAlloc = kFALSE,
195  TMemberStreamer *s = nullptr) final;
196 
197  void StreamObject(void *obj, const TClass *cl, const TClass *onFileClass = nullptr) final;
198  using TBufferText::StreamObject;
199 
200  void ReadBool(Bool_t &b) final;
201  void ReadChar(Char_t &c) final;
202  void ReadUChar(UChar_t &c) final;
203  void ReadShort(Short_t &s) final;
204  void ReadUShort(UShort_t &s) final;
205  void ReadInt(Int_t &i) final;
206  void ReadUInt(UInt_t &i) final;
207  void ReadLong(Long_t &l) final;
208  void ReadULong(ULong_t &l) final;
209  void ReadLong64(Long64_t &l) final;
210  void ReadULong64(ULong64_t &l) final;
211  void ReadFloat(Float_t &f) final;
212  void ReadDouble(Double_t &d) final;
213  void ReadCharP(Char_t *c) final;
214  void ReadTString(TString &s) final;
215  void ReadStdString(std::string *s) final;
216  using TBuffer::ReadStdString;
217  void ReadCharStar(char *&s) final;
218 
219  void WriteBool(Bool_t b) final;
220  void WriteChar(Char_t c) final;
221  void WriteUChar(UChar_t c) final;
222  void WriteShort(Short_t s) final;
223  void WriteUShort(UShort_t s) final;
224  void WriteInt(Int_t i) final;
225  void WriteUInt(UInt_t i) final;
226  void WriteLong(Long_t l) final;
227  void WriteULong(ULong_t l) final;
228  void WriteLong64(Long64_t l) final;
229  void WriteULong64(ULong64_t l) final;
230  void WriteFloat(Float_t f) final;
231  void WriteDouble(Double_t d) final;
232  void WriteCharP(const Char_t *c) final;
233  void WriteTString(const TString &s) final;
234  void WriteStdString(const std::string *s) final;
235  using TBuffer::WriteStdString;
236  void WriteCharStar(char *s) final;
237 
238  TVirtualStreamerInfo *GetInfo() final;
239 
240  // end of redefined virtual functions
241 
242  void ReadBaseClass(void *start, TStreamerBase *elem) final;
243 
244 protected:
245  // redefined protected virtual functions
246 
247  void WriteObjectClass(const void *actualObjStart, const TClass *actualClass, Bool_t cacheReuse) final;
248 
249  // end redefined protected virtual functions
250 
251  static void *ConvertFromJSONChecked(const char *str, const TClass *expectedClass);
252 
253  TString JsonWriteMember(const void *ptr, TDataMember *member, TClass *memberClass, Int_t arraylen);
254 
255  TJSONStackObj *PushStack(Int_t inclevel = 0, void *readnode = nullptr);
256  TJSONStackObj *PopStack();
257  TJSONStackObj *Stack() { return fStack.back().get(); }
258 
259  void WorkWithClass(TStreamerInfo *info, const TClass *cl = nullptr);
261 
263  Int_t JsonSpecialClass(const TClass *cl) const;
264 
265  TJSONStackObj *JsonStartObjectWrite(const TClass *obj_class, TStreamerInfo *info = nullptr);
266 
267  void JsonStartElement(const TStreamerElement *elem, const TClass *base_class);
268 
269  void PerformPostProcessing(TJSONStackObj *stack, const TClass *obj_cl = nullptr);
270 
271  void JsonWriteBasic(Char_t value);
272  void JsonWriteBasic(Short_t value);
273  void JsonWriteBasic(Int_t value);
274  void JsonWriteBasic(Long_t value);
275  void JsonWriteBasic(Long64_t value);
276  void JsonWriteBasic(Float_t value);
277  void JsonWriteBasic(Double_t value);
278  void JsonWriteBasic(Bool_t value);
279  void JsonWriteBasic(UChar_t value);
280  void JsonWriteBasic(UShort_t value);
281  void JsonWriteBasic(UInt_t value);
282  void JsonWriteBasic(ULong_t value);
283  void JsonWriteBasic(ULong64_t value);
284 
285  void JsonWriteConstChar(const char *value, Int_t len = -1, const char * /*typname*/ = nullptr);
286 
287  void JsonWriteObject(const void *obj, const TClass *objClass, Bool_t check_map = kTRUE);
288 
289  void JsonWriteCollection(TCollection *obj, const TClass *objClass);
290 
291  void JsonReadCollection(TCollection *obj, const TClass *objClass);
292 
293  void JsonReadTObjectMembers(TObject *obj, void *node = nullptr);
294 
295  void *JsonReadObject(void *obj, const TClass *objClass = nullptr, TClass **readClass = nullptr);
296 
297  void AppendOutput(const char *line0, const char *line1 = nullptr);
298 
299  void JsonPushValue();
300 
301  template <typename T>
302  R__ALWAYS_INLINE void JsonWriteArrayCompress(const T *vname, Int_t arrsize, const char *typname);
303 
304  template <typename T>
305  R__ALWAYS_INLINE void JsonReadBasic(T &value);
306 
307  template <typename T>
309 
310  template <typename T>
311  R__ALWAYS_INLINE void JsonReadFastArray(T *arr, Int_t arrsize, bool asstring = false);
312 
313  template <typename T>
314  R__ALWAYS_INLINE void JsonWriteFastArray(const T *arr, Int_t arrsize, const char *typname,
315  void (TBufferJSON::*method)(const T *, Int_t, const char *));
316 
317  TString fOutBuffer; ///<! main output buffer for json code
318  TString *fOutput{nullptr}; ///<! current output buffer for json code
319  TString fValue; ///<! buffer for current value
320  unsigned fJsonrCnt{0}; ///<! counter for all objects, used for referencing
321  std::deque<std::unique_ptr<TJSONStackObj>> fStack; ///<! hierarchy of currently streamed element
322  Int_t fCompact{0}; ///<! 0 - no any compression, 1 - no spaces in the begin, 2 - no new lines, 3 - no spaces at all
323  Bool_t fMapAsObject{kFALSE}; ///<! when true, std::map will be converted into JSON object
324  TString fSemicolon; ///<! depending from compression level, " : " or ":"
325  Int_t fArrayCompact{0}; ///<! 0 - no array compression, 1 - exclude leading/trailing zeros, 2 - check value repetition
326  TString fArraySepar; ///<! depending from compression level, ", " or ","
327  TString fNumericLocale; ///<! stored value of setlocale(LC_NUMERIC), which should be recovered at the end
328  TString fTypeNameTag; ///<! JSON member used for storing class name, when empty - no class name will be stored
329  TString fTypeVersionTag; ///<! JSON member used to store class version, default empty
330  std::vector<const TClass *> fSkipClasses; ///<! list of classes, which class info is not stored
331 
332  ClassDefOverride(TBufferJSON, 0) // a specialized TBuffer to only write objects into JSON format
333 };
334 
335 #endif
c
#define c(i)
Definition: RSha256.hxx:101
l
auto * l
Definition: textangle.C:4
TBufferJSON::WriteFastArrayString
void WriteFastArrayString(const Char_t *c, Int_t n) final
Write array of Char_t to buffer.
Definition: TBufferJSON.cxx:3324
TBufferJSON::fArrayCompact
Int_t fArrayCompact
! 0 - no array compression, 1 - exclude leading/trailing zeros, 2 - check value repetition
Definition: TBufferJSON.h:325
TBufferJSON::WriteTString
void WriteTString(const TString &s) final
Writes a TString.
Definition: TBufferJSON.cxx:3844
n
const Int_t n
Definition: legend1.C:16
TBufferJSON::WriteChar
void WriteChar(Char_t c) final
Writes Char_t value to buffer.
Definition: TBufferJSON.cxx:3726
TBufferJSON::fTypeNameTag
TString fTypeNameTag
! JSON member used for storing class name, when empty - no class name will be stored
Definition: TBufferJSON.h:328
TBufferJSON::ReadClass
TClass * ReadClass(const TClass *cl=nullptr, UInt_t *objTag=nullptr) final
suppressed function of TBuffer
Definition: TBufferJSON.cxx:2449
TBufferJSON::TBufferJSON
TBufferJSON(TBuffer::EMode mode=TBuffer::kWrite)
Creates buffer object to serialize data into json.
Definition: TBufferJSON.cxx:478
TBufferJSON::WriteLong64
void WriteLong64(Long64_t l) final
Writes Long64_t value to buffer.
Definition: TBufferJSON.cxx:3798
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TBufferJSON::ReadBool
void ReadBool(Bool_t &b) final
Reads Bool_t value from buffer.
Definition: TBufferJSON.cxx:3552
TBufferJSON::WorkWithClass
void WorkWithClass(TStreamerInfo *info, const TClass *cl=nullptr)
Prepares buffer to stream data of specified class.
Definition: TBufferJSON.cxx:2011
TBufferJSON::ClassBegin
void ClassBegin(const TClass *, Version_t=-1) final
Should be called in the beginning of custom class streamer.
Definition: TBufferJSON.cxx:2180
TBufferJSON::kNoIndent
@ kNoIndent
remove spaces in the beginning showing JSON indentation level
Definition: TBufferJSON.h:37
TBufferJSON::kBase64
@ kBase64
all binary arrays will be compressed with base64 coding, supported by JSROOT
Definition: TBufferJSON.h:46
Version_t
short Version_t
Definition: RtypesCore.h:65
TBufferJSON::ReadCharStar
void ReadCharStar(char *&s) final
Reads a char* string.
Definition: TBufferJSON.cxx:3696
TBufferJSON::fSkipClasses
std::vector< const TClass * > fSkipClasses
! list of classes, which class info is not stored
Definition: TBufferJSON.h:330
f
#define f(i)
Definition: RSha256.hxx:104
TBufferJSON::FromJSON
static std::unique_ptr< T > FromJSON(const std::string &json)
Definition: TBufferJSON.h:90
TBufferJSON::ConvertFromJSON
static TObject * ConvertFromJSON(const char *str)
Read TObject-based class from JSON, produced by ConvertToJSON() method.
Definition: TBufferJSON.cxx:913
UShort_t
unsigned short UShort_t
Definition: RtypesCore.h:40
TBufferJSON::ReadULong64
void ReadULong64(ULong64_t &l) final
Reads ULong64_t value from buffer.
Definition: TBufferJSON.cxx:3638
TBufferJSON::JsonSpecialClass
Int_t JsonSpecialClass(const TClass *cl) const
return non-zero value when class has special handling in JSON it is TCollection (-130),...
Definition: TBufferJSON.cxx:1281
TBufferJSON::ReadChar
void ReadChar(Char_t &c) final
Reads Char_t value from buffer.
Definition: TBufferJSON.cxx:3560
TBufferJSON::ReadFloat
void ReadFloat(Float_t &f) final
Reads Float_t value from buffer.
Definition: TBufferJSON.cxx:3646
TBufferJSON::SetStreamerElementNumber
void SetStreamerElementNumber(TStreamerElement *elem, Int_t comp_type) final
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and add/verify next elemen...
Definition: TBufferJSON.cxx:2088
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TBufferJSON::ReadStdString
virtual void ReadStdString(std::string *s)=0
TBufferJSON::kSameSuppression
@ kSameSuppression
zero suppression plus compress many similar values together
Definition: TBufferJSON.h:45
TBufferJSON::ExportToFile
static Int_t ExportToFile(const char *filename, const TObject *obj, const char *option=nullptr)
Convert object into JSON and store in text file Returns size of the produce file Used in TObject::Sav...
Definition: TBufferJSON.cxx:753
Float_t
float Float_t
Definition: RtypesCore.h:57
TBufferJSON::fCompact
Int_t fCompact
! 0 - no any compression, 1 - no spaces in the begin, 2 - no new lines, 3 - no spaces at all
Definition: TBufferJSON.h:322
TBufferText::ClassDefOverride
ClassDefOverride(TBufferText, 0)
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:162
Int_t
int Int_t
Definition: RtypesCore.h:45
TDataMember
All ROOT classes may have RTTI (run time type identification) support added.
Definition: TDataMember.h:31
TBufferJSON::JsonWriteCollection
void JsonWriteCollection(TCollection *obj, const TClass *objClass)
store content of ROOT collection
Definition: TBufferJSON.cxx:1596
TBufferJSON::JsonWriteArrayCompress
R__ALWAYS_INLINE void JsonWriteArrayCompress(const T *vname, Int_t arrsize, const char *typname)
Definition: TBufferJSON.cxx:3030
TBufferJSON::FromJSON
static Bool_t FromJSON(T *&obj, const char *json)
Definition: TBufferJSON.h:81
TBufferJSON::kNoNewLine
@ kNoNewLine
no indent plus skip newline symbols
Definition: TBufferJSON.h:38
TBufferJSON::kZeroSuppression
@ kZeroSuppression
if array has much zeros in begin and/or end, they will be removed
Definition: TBufferJSON.h:44
TBuffer
Buffer base class used for serializing objects.
Definition: TBuffer.h:43
TBufferJSON::kNoSpaces
@ kNoSpaces
no new lines plus remove all spaces around "," and ":" symbols
Definition: TBufferJSON.h:39
TBufferJSON::fArraySepar
TString fArraySepar
! depending from compression level, ", " or ","
Definition: TBufferJSON.h:326
TString
Basic string class.
Definition: TString.h:136
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TBufferJSON::fMapAsObject
Bool_t fMapAsObject
! when true, std::map will be converted into JSON object
Definition: TBufferJSON.h:323
TBufferJSON::JsonWriteBasic
void JsonWriteBasic(Char_t value)
converts Char_t to string and add to json value buffer
Definition: TBufferJSON.cxx:3877
b
#define b(i)
Definition: RSha256.hxx:100
TString.h
TBufferJSON::ReadFastArray
void ReadFastArray(Bool_t *b, Int_t n) final
read array of Bool_t from buffer
Definition: TBufferJSON.cxx:2829
TBufferJSON::ConvertFromJSONChecked
static void * ConvertFromJSONChecked(const char *str, const TClass *expectedClass)
Read objects from JSON, one can reuse existing object.
Definition: TBufferJSON.cxx:979
TBufferJSON::SkipObjectAny
void SkipObjectAny() final
Skip any kind of object from buffer.
Definition: TBufferJSON.cxx:2504
TVirtualStreamerInfo
Abstract Interface class describing Streamer information for one class.
Definition: TVirtualStreamerInfo.h:37
bool
TBufferJSON::fStack
std::deque< std::unique_ptr< TJSONStackObj > > fStack
! hierarchy of currently streamed element
Definition: TBufferJSON.h:321
TBufferJSON::WriteUChar
void WriteUChar(UChar_t c) final
Writes UChar_t value to buffer.
Definition: TBufferJSON.cxx:3735
TBufferJSON::JsonReadFastArray
R__ALWAYS_INLINE void JsonReadFastArray(T *arr, Int_t arrsize, bool asstring=false)
Template method to read array from the JSON.
Definition: TBufferJSON.cxx:2748
TBufferJSON::ReadFastArrayString
void ReadFastArrayString(Char_t *c, Int_t n) final
read array of Char_t from buffer
Definition: TBufferJSON.cxx:2845
TBufferJSON::ReadULong
void ReadULong(ULong_t &l) final
Reads ULong_t value from buffer.
Definition: TBufferJSON.cxx:3622
TBufferText
Base class for text-based streamers like TBufferJSON or TBufferXML Special actions list will use meth...
Definition: TBufferText.h:20
TBufferJSON::WriteArray
void WriteArray(const Bool_t *b, Int_t n) final
Write array of Bool_t to buffer.
Definition: TBufferJSON.cxx:3133
TBufferJSON::fOutBuffer
TString fOutBuffer
! main output buffer for json code
Definition: TBufferJSON.h:317
TBufferJSON::ClassMember
void ClassMember(const char *name, const char *typeName=nullptr, Int_t arrsize1=-1, Int_t arrsize2=-1) final
Method indicates name and typename of class member, which should be now streamed in custom streamer F...
Definition: TBufferJSON.cxx:2231
TBufferJSON::fNumericLocale
TString fNumericLocale
! stored value of setlocale(LC_NUMERIC), which should be recovered at the end
Definition: TBufferJSON.h:327
TBufferJSON::WriteCharStar
void WriteCharStar(char *s) final
Writes a char*.
Definition: TBufferJSON.cxx:3867
TBufferJSON::fValue
TString fValue
! buffer for current value
Definition: TBufferJSON.h:319
TBufferJSON::ReadUShort
void ReadUShort(UShort_t &s) final
Reads UShort_t value from buffer.
Definition: TBufferJSON.cxx:3587
TBufferJSON::DecrementLevel
void DecrementLevel(TVirtualStreamerInfo *) final
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and decrease level in json...
Definition: TBufferJSON.cxx:2047
TBufferJSON::WriteULong64
void WriteULong64(ULong64_t l) final
Writes ULong64_t value to buffer.
Definition: TBufferJSON.cxx:3807
TBufferJSON::fJsonrCnt
unsigned fJsonrCnt
! counter for all objects, used for referencing
Definition: TBufferJSON.h:320
TBufferJSON::JsonStartObjectWrite
TJSONStackObj * JsonStartObjectWrite(const TClass *obj_class, TStreamerInfo *info=nullptr)
Start object element with typeinfo.
Definition: TBufferJSON.cxx:1180
TBufferJSON::kSkipTypeInfo
@ kSkipTypeInfo
Definition: TBufferJSON.h:48
TBuffer::EMode
EMode
Definition: TBuffer.h:73
TStreamerInfo
Describe Streamer information for one class version.
Definition: TStreamerInfo.h:44
TBufferJSON::IsSkipClassInfo
Bool_t IsSkipClassInfo(const TClass *cl) const
Returns true if class info will be skipped from JSON.
Definition: TBufferJSON.cxx:616
TBufferJSON::WriteULong
void WriteULong(ULong_t l) final
Writes ULong_t value to buffer.
Definition: TBufferJSON.cxx:3789
h
#define h(i)
Definition: RSha256.hxx:106
TBufferJSON::kMapAsObject
@ kMapAsObject
store std::map, std::unodered_map as JSON object
Definition: TBufferJSON.h:41
TBufferJSON::WriteStdString
virtual void WriteStdString(const std::string *s)=0
TBufferJSON::WriteObjectClass
void WriteObjectClass(const void *actualObjStart, const TClass *actualClass, Bool_t cacheReuse) final
Write object to buffer. Only used from TBuffer.
Definition: TBufferJSON.cxx:2509
TBufferJSON::ReadUChar
void ReadUChar(UChar_t &c) final
Reads UChar_t value from buffer.
Definition: TBufferJSON.cxx:3571
TBufferJSON::SetTypenameTag
void SetTypenameTag(const char *tag="_typename")
Configures _typename tag in JSON structures By default "_typename" field in JSON structures used to s...
Definition: TBufferJSON.cxx:580
TBufferJSON::JsonReadTObjectMembers
void JsonReadTObjectMembers(TObject *obj, void *node=nullptr)
Read TObject data members from JSON.
Definition: TBufferJSON.cxx:1975
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TBufferJSON::RestoreObject
void * RestoreObject(const char *str, TClass **cl)
Read object from JSON In class pointer (if specified) read class is returned One must specify expecte...
Definition: TBufferJSON.cxx:948
TBufferJSON::AppendOutput
void AppendOutput(const char *line0, const char *line1=nullptr)
Append two string to the output JSON, normally separate by line break.
Definition: TBufferJSON.cxx:1158
Long_t
long Long_t
Definition: RtypesCore.h:54
TBufferJSON::WriteFastArray
void WriteFastArray(const Bool_t *b, Int_t n) final
Write array of Bool_t to buffer.
Definition: TBufferJSON.cxx:3290
TBufferJSON::ReadVersion
Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr) final
read version value from buffer
Definition: TBufferJSON.cxx:2462
TBufferJSON::ReadTString
void ReadTString(TString &s) final
Reads a TString.
Definition: TBufferJSON.cxx:3678
TBufferJSON::WorkWithElement
void WorkWithElement(TStreamerElement *elem, Int_t)
This is call-back from streamer which indicates that class member will be streamed Name of element us...
Definition: TBufferJSON.cxx:2101
TBufferJSON::WriteLong
void WriteLong(Long_t l) final
Writes Long_t value to buffer.
Definition: TBufferJSON.cxx:3780
TBufferJSON::PushStack
TJSONStackObj * PushStack(Int_t inclevel=0, void *readnode=nullptr)
add new level to the structures stack
Definition: TBufferJSON.cxx:1129
TBufferJSON::ReadLong
void ReadLong(Long_t &l) final
Reads Long_t value from buffer.
Definition: TBufferJSON.cxx:3614
TBufferJSON::ReadArray
Int_t ReadArray(Bool_t *&b) final
Read array of Bool_t from buffer.
Definition: TBufferJSON.cxx:2529
TBufferJSON
Class for serializing object to and from JavaScript Object Notation (JSON) format.
Definition: TBufferJSON.h:30
TBufferJSON::JsonWriteObject
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...
Definition: TBufferJSON.cxx:1319
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TBufferJSON::SetCompact
void SetCompact(int level)
Set level of space/newline/array compression Lower digit of compact parameter define formatting rules...
Definition: TBufferJSON.cxx:556
TBufferJSON::WriteInt
void WriteInt(Int_t i) final
Writes Int_t value to buffer.
Definition: TBufferJSON.cxx:3762
ULong_t
unsigned long ULong_t
Definition: RtypesCore.h:55
Short_t
short Short_t
Definition: RtypesCore.h:39
TBufferJSON::ReadCharP
void ReadCharP(Char_t *c) final
Reads array of characters from buffer.
Definition: TBufferJSON.cxx:3670
TBufferJSON::StoreObject
TString StoreObject(const void *obj, const TClass *cl)
Store provided object as JSON structure Allows to configure different TBufferJSON properties before c...
Definition: TBufferJSON.cxx:702
TBufferJSON::WriteFloat
void WriteFloat(Float_t f) final
Writes Float_t value to buffer.
Definition: TBufferJSON.cxx:3816
TBufferJSON::WriteClass
void WriteClass(const TClass *cl) final
suppressed function of TBuffer
Definition: TBufferJSON.cxx:2457
TBufferJSON::ToJSON
static TString ToJSON(const T *obj, Int_t compact=0, const char *member_name=nullptr)
Definition: TBufferJSON.h:75
TBufferJSON::ReadLong64
void ReadLong64(Long64_t &l) final
Reads Long64_t value from buffer.
Definition: TBufferJSON.cxx:3630
TBufferJSON::Stack
TJSONStackObj * Stack()
Definition: TBufferJSON.h:257
ULong64_t
unsigned long long ULong64_t
Definition: RtypesCore.h:74
TBufferJSON::JsonReadCollection
void JsonReadCollection(TCollection *obj, const TClass *objClass)
read content of ROOT collection
Definition: TBufferJSON.cxx:1670
TBufferJSON::fOutput
TString * fOutput
! current output buffer for json code
Definition: TBufferJSON.h:318
TBufferText.h
Double_t
double Double_t
Definition: RtypesCore.h:59
TBufferJSON::JsonPushValue
void JsonPushValue()
If value exists, push in the current stack for post-processing.
Definition: TBufferJSON.cxx:2520
TBufferJSON::JsonWriteConstChar
void JsonWriteConstChar(const char *value, Int_t len=-1, const char *=nullptr)
writes string value, processing all kind of special characters
Definition: TBufferJSON.cxx:4013
TBufferJSON::WriteCharP
void WriteCharP(const Char_t *c) final
Writes array of characters to buffer.
Definition: TBufferJSON.cxx:3834
TBufferJSON::~TBufferJSON
virtual ~TBufferJSON()
destroy buffer
Definition: TBufferJSON.cxx:499
TBufferJSON::JsonReadArray
R__ALWAYS_INLINE Int_t JsonReadArray(T *value)
Read static array from JSON - not used.
Definition: TBufferJSON.cxx:2634
TBufferJSON::fTypeVersionTag
TString fTypeVersionTag
! JSON member used to store class version, default empty
Definition: TBufferJSON.h:329
TBufferJSON::StreamObject
void StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass=nullptr) override
stream object to/from buffer
Definition: TBufferText.cxx:465
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
TBufferJSON::GetInfo
TVirtualStreamerInfo * GetInfo() final
Return current streamer info element.
Definition: TBufferJSON.cxx:2078
TBufferJSON::WriteVersion
UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE) final
Ignored in TBufferJSON.
Definition: TBufferJSON.cxx:2485
TBufferJSON::JsonWriteFastArray
R__ALWAYS_INLINE void JsonWriteFastArray(const T *arr, Int_t arrsize, const char *typname, void(TBufferJSON::*method)(const T *, Int_t, const char *))
Template method to write array of arbitrary dimensions Different methods can be used for store last a...
Definition: TBufferJSON.cxx:3253
UChar_t
unsigned char UChar_t
Definition: RtypesCore.h:38
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TBufferJSON::ReadObjectAny
void * ReadObjectAny(const TClass *clCast) final
Read object from buffer. Only used from TBuffer.
Definition: TBufferJSON.cxx:2493
TBufferJSON::ReadUInt
void ReadUInt(UInt_t &i) final
Reads UInt_t value from buffer.
Definition: TBufferJSON.cxx:3606
TBufferJSON::kNoCompress
@ kNoCompress
no any compression, maximal size of JSON (default)
Definition: TBufferJSON.h:36
name
char name[80]
Definition: TGX11.cxx:110
TBufferJSON::JsonStartElement
void JsonStartElement(const TStreamerElement *elem, const TClass *base_class)
Start new class member in JSON structures.
Definition: TBufferJSON.cxx:1214
TBufferJSON::JsonReadObject
void * JsonReadObject(void *obj, const TClass *objClass=nullptr, TClass **readClass=nullptr)
Read object from current JSON node.
Definition: TBufferJSON.cxx:1768
ROOT::Math::Chebyshev::T
double T(double x)
Definition: ChebyshevPol.h:34
d
#define d(i)
Definition: RSha256.hxx:102
TBufferJSON::ReadBaseClass
void ReadBaseClass(void *start, TStreamerBase *elem) final
Read data of base class.
Definition: TBufferJSON.cxx:4054
TBufferJSON::ConvertToJSON
static TString ConvertToJSON(const TObject *obj, Int_t compact=0, const char *member_name=nullptr)
Converts object, inherited from TObject class, to JSON string Lower digit of compact parameter define...
Definition: TBufferJSON.cxx:524
TBufferJSON::ReadStaticArray
Int_t ReadStaticArray(Bool_t *b) final
Read array of Bool_t from buffer.
Definition: TBufferJSON.cxx:2643
TBufferJSON::WriteDouble
void WriteDouble(Double_t d) final
Writes Double_t value to buffer.
Definition: TBufferJSON.cxx:3825
TBufferJSON::ConvertFromJSONAny
static void * ConvertFromJSONAny(const char *str, TClass **cl=nullptr)
Read object from JSON In class pointer (if specified) read class is returned One must specify expecte...
Definition: TBufferJSON.cxx:936
TBufferJSON::WriteShort
void WriteShort(Short_t s) final
Writes Short_t value to buffer.
Definition: TBufferJSON.cxx:3744
TCollection
Collection abstract base class.
Definition: TCollection.h:63
TMemberStreamer
Definition: TMemberStreamer.h:26
TBufferJSON::ReadDouble
void ReadDouble(Double_t &d) final
Reads Double_t value from buffer.
Definition: TBufferJSON.cxx:3658
TBufferJSON::PerformPostProcessing
void PerformPostProcessing(TJSONStackObj *stack, const TClass *obj_cl=nullptr)
Function is converts TObject and TString structures to more compact representation.
Definition: TBufferJSON.cxx:2327
TBufferJSON::WriteUInt
void WriteUInt(UInt_t i) final
Writes UInt_t value to buffer.
Definition: TBufferJSON.cxx:3771
TBufferJSON::WriteUShort
void WriteUShort(UShort_t s) final
Writes UShort_t value to buffer.
Definition: TBufferJSON.cxx:3753
TBufferJSON::JsonDisablePostprocessing
void JsonDisablePostprocessing()
disable post-processing of the code
Definition: TBufferJSON.cxx:1272
Char_t
char Char_t
Definition: RtypesCore.h:33
TBufferJSON::ReadShort
void ReadShort(Short_t &s) final
Reads Short_t value from buffer.
Definition: TBufferJSON.cxx:3579
TBufferJSON::ClassEnd
void ClassEnd(const TClass *) final
Should be called at the end of custom streamer See TBufferJSON::ClassBegin for more details.
Definition: TBufferJSON.cxx:2189
TBufferJSON::IncrementLevel
void IncrementLevel(TVirtualStreamerInfo *) final
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and indent new level in js...
Definition: TBufferJSON.cxx:2000
TStreamerElement
Definition: TStreamerElement.h:33
TBufferJSON::SetSkipClassInfo
void SetSkipClassInfo(const TClass *cl)
Specify class which typename will not be stored in JSON Several classes can be configured To exclude ...
Definition: TBufferJSON.cxx:607
TStreamerBase
Definition: TStreamerElement.h:151
TBufferJSON::WriteBool
void WriteBool(Bool_t b) final
Writes Bool_t value to buffer.
Definition: TBufferJSON.cxx:3717
TBufferJSON::PopStack
TJSONStackObj * PopStack()
remove one level from stack
Definition: TBufferJSON.cxx:1147
TBuffer::kWrite
@ kWrite
Definition: TBuffer.h:73
TBufferJSON::fSemicolon
TString fSemicolon
! depending from compression level, " : " or ":"
Definition: TBufferJSON.h:324
TBufferJSON::SetTypeversionTag
void SetTypeversionTag(const char *tag=nullptr)
Configures _typeversion tag in JSON One can specify name of the JSON tag like "_typeversion" or "$tv"...
Definition: TBufferJSON.cxx:594
int
TBufferJSON::ReadInt
void ReadInt(Int_t &i) final
Reads Int_t value from buffer.
Definition: TBufferJSON.cxx:3595
R__ALWAYS_INLINE
#define R__ALWAYS_INLINE
Definition: RConfig.hxx:570
TBufferJSON::JsonWriteMember
TString JsonWriteMember(const void *ptr, TDataMember *member, TClass *memberClass, Int_t arraylen)
Convert single data member to JSON structures Returns string with converted member.
Definition: TBufferJSON.cxx:1009
TBufferJSON::JsonReadBasic
R__ALWAYS_INLINE void JsonReadBasic(T &value)
Template function to read basic value from JSON.
Definition: TBufferJSON.cxx:3544