12 #ifndef ROOT_TBufferJSON 13 #define ROOT_TBufferJSON 41 static Int_t ExportToFile(
const char *filename,
const void *obj,
const TClass *cl,
const char *option =
nullptr);
58 return obj !=
nullptr;
126 const TClass *onFileClass =
nullptr);
220 TJSONStackObj *
PushStack(
Int_t inclevel = 0,
void *readnode =
nullptr);
260 void AppendOutput(
const char *line0,
const char *line1 =
nullptr);
264 template <
typename T>
267 template <
typename T>
270 template <
typename T>
273 template <
typename T>
276 template <
typename T>
Describe Streamer information for one class version.
void WorkWithClass(TStreamerInfo *info, const TClass *cl=nullptr)
Prepares buffer to stream data of specified class.
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)
Ignored in TBufferJSON.
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 Int_t ReadStaticArray(Bool_t *b)
Read array of Bool_t from buffer.
static TObject * ConvertFromJSON(const char *str)
Read TObject-based class from JSON, produced by ConvertToJSON() method.
virtual Int_t ReadArray(Bool_t *&b)
Read array of Bool_t from buffer.
void JsonDisablePostprocessing()
disable post-processing of the code
virtual void ReadShort(Short_t &s)
Reads Short_t value from buffer.
virtual void WriteLong64(Long64_t l)
Writes Long64_t value to buffer.
virtual void ReadFloat(Float_t &f)
Reads Float_t value from buffer.
All ROOT classes may have RTTI (run time type identification) support added.
static Bool_t FromJSON(T *&obj, const char *json)
TString fSemicolon
! depending from compression level, " : " or ":"
virtual void SkipObjectAny()
Skip any kind of object from buffer.
R__ALWAYS_INLINE void JsonReadBasic(T &value)
Template function to read basic value from JSON.
virtual void ReadCharP(Char_t *c)
Reads array of characters from buffer.
virtual void DecrementLevel(TVirtualStreamerInfo *)
Function is called from TStreamerInfo WriteBuffer and ReadBuffer functions and decrease level in json...
TString fArraySepar
! depending from compression level, ", " or ","
virtual void ReadBool(Bool_t &b)
Reads Bool_t value from buffer.
Int_t fCompact
! 0 - no any compression, 1 - no spaces in the begin, 2 - no new lines, 3 - no spaces at all ...
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.
void JsonWriteBasic(Char_t value)
converts Char_t to string and add to json value buffer
virtual void WriteULong64(ULong64_t l)
Writes ULong64_t value to buffer.
Int_t JsonSpecialClass(const TClass *cl) const
return non-zero value when class has special handling in JSON it is TCollection (-130), TArray (100), TString (110), std::string (120) and STL containers (1..6)
virtual void ReadFastArray(Bool_t *b, Int_t n)
read array of Bool_t from buffer
R__ALWAYS_INLINE void JsonReadFastArray(T *arr, Int_t arrsize, bool asstring=false)
Template method to read array from the JSON.
virtual void ReadLong(Long_t &l)
Reads Long_t value from buffer.
virtual void WriteLong(Long_t l)
Writes Long_t value to 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...
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)
read version value from buffer
virtual void WriteFastArrayString(const Char_t *c, Int_t n)
Write array of Char_t to buffer.
virtual void WriteInt(Int_t i)
Writes Int_t value to buffer.
virtual TVirtualStreamerInfo * GetInfo()
Return current streamer info element.
virtual void StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass=nullptr)
stream object to/from buffer
virtual TClass * ReadClass(const TClass *cl=nullptr, UInt_t *objTag=nullptr)
suppressed function of TBuffer
virtual void ReadChar(Char_t &c)
Reads Char_t value from buffer.
#define ClassDef(name, id)
virtual void WriteFastArray(const Bool_t *b, Int_t n)
Write array of Bool_t to buffer.
TString fOutBuffer
! main output buffer for json code
virtual void ReadUShort(UShort_t &s)
Reads UShort_t value from buffer.
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 ReadDouble(Double_t &d)
Reads Double_t value from buffer.
void JsonReadTObjectMembers(TObject *obj, void *node=nullptr)
static TClass * GetClass(const std::type_info &typeinfo)
Forward to TROOT::GetClass().
void JsonWriteCollection(TCollection *obj, const TClass *objClass)
store content of ROOT collection
virtual void ReadStdString(std::string *s)=0
static void * ConvertFromJSONChecked(const char *str, const TClass *expectedClass)
Read objects from JSON, one can reuse existing object.
unsigned fJsonrCnt
! counter for all objects, used for referencing
virtual void ReadCharStar(char *&s)
Reads a char* string.
R__ALWAYS_INLINE void JsonWriteArrayCompress(const T *vname, Int_t arrsize, const char *typname)
virtual void ReadUChar(UChar_t &c)
Reads UChar_t value from buffer.
void SetCompact(int level)
TString fNumericLocale
! stored value of setlocale(LC_NUMERIC), which should be recovered at the end
virtual void ReadInt(Int_t &i)
Reads Int_t value from buffer.
TString fValue
! buffer for current value
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.
std::deque< TJSONStackObj * > fStack
! hierarchy of currently streamed element
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 ReadULong(ULong_t &l)
Reads ULong_t value from buffer.
virtual void ClassBegin(const TClass *, Version_t=-1)
Should be called in the beginning of custom class streamer.
TString * fOutput
! current output buffer for json code
Collection abstract base class.
void JsonWriteConstChar(const char *value, Int_t len=-1, const char *=nullptr)
writes string value, processing all kind of special characters
void AppendOutput(const char *line0, const char *line1=nullptr)
Append two string to the output JSON, normally separate by line break.
The ROOT global object gROOT contains a list of all defined classes.
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...
TJSONStackObj * PushStack(Int_t inclevel=0, void *readnode=nullptr)
add new level to the structures stack
virtual void WriteBool(Bool_t b)
Writes Bool_t value to buffer.
virtual void ReadTString(TString &s)
Reads a TString.
virtual void WriteFloat(Float_t f)
Writes Float_t value to buffer.
void * JsonReadObject(void *obj, const TClass *objClass=nullptr, TClass **readClass=nullptr)
Read object from current JSON node.
void JsonPushValue()
If value exists, push in the current stack for post-processing.
virtual void WriteTString(const TString &s)
Writes a TString.
Base class for text-based streamers like TBufferJSON or TBufferXML Special actions list will use meth...
virtual void WriteShort(Short_t s)
Writes Short_t value to buffer.
Class for serializing object to and from JavaScript Object Notation (JSON) format.
virtual void WriteUInt(UInt_t i)
Writes UInt_t value to 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...
virtual void WriteULong(ULong_t l)
Writes ULong_t value to buffer.
unsigned long long ULong64_t
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*.
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 void StreamObject(void *obj, const TClass *cl, const TClass *onFileClass=nullptr)
stream object to/from buffer
virtual void ClassEnd(const TClass *)
Should be called at the end of custom streamer See TBufferJSON::ClassBegin for more details...
void JsonStartElement(const TStreamerElement *elem, const TClass *base_class=nullptr)
Start new class member in JSON structures.
Mother of all ROOT objects.
TJSONStackObj * PopStack()
remove one level from stack
R__ALWAYS_INLINE Int_t JsonReadArray(T *value)
Read static array from JSON - not used.
virtual void WriteChar(Char_t c)
Writes Char_t value to buffer.
virtual void WriteCharP(const Char_t *c)
Writes array of characters to buffer.
basic_json<> json
default JSON class
static TString ToJSON(const T *obj, Int_t compact=0, const char *member_name=nullptr)
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
void PerformPostProcessing(TJSONStackObj *stack, const TClass *obj_cl=nullptr)
Function is converts TObject and TString structures to more compact representation.
void JsonReadCollection(TCollection *obj, const TClass *objClass)
read content of ROOT collection
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...
static void * ConvertFromJSONAny(const char *str, TClass **cl=nullptr)
Read object from JSON, produced by ConvertToJSON() method.
virtual ~TBufferJSON()
destroy buffer
virtual void WriteClass(const TClass *cl)
suppressed function of TBuffer
virtual void ReadFastArrayString(Char_t *c, Int_t n)
read array of Char_t from buffer
Abstract Interface class describing Streamer information for one class.
virtual void WriteStdString(const std::string *s)=0
virtual void ReadBaseClass(void *start, TStreamerBase *elem)
Read data of base class.
virtual void WriteArray(const Bool_t *b, Int_t n)
Write array of Bool_t to buffer.
virtual void ReadUInt(UInt_t &i)
Reads UInt_t value from buffer.
TBufferJSON(TBuffer::EMode mode=TBuffer::kWrite)
Creates buffer object to serialize data into json.