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