Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TBufferText.h
Go to the documentation of this file.
1// $Id$
2// Author: Sergey Linev 21.12.2017
3
4/*************************************************************************
5 * Copyright (C) 1995-2017, 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_TBufferText
13#define ROOT_TBufferText
14
15#include "TBufferIO.h"
16
17class TStreamerBase;
18class TExMap;
19
20class TBufferText : public TBufferIO {
21
22protected:
24 TBufferText(TBuffer::EMode mode, TObject *parent = nullptr);
25
26public:
27 ~TBufferText() override;
28
29 // virtual TBuffer methods, which are generic for all text-based streamers
30
31 void StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass = nullptr) override;
32 void StreamObject(void *obj, const char *className, const TClass *onFileClass = nullptr) override;
33 void StreamObject(TObject *obj) override;
35
36 Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *object) final;
37 Int_t ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection,
38 void *end_collection) final;
39 Int_t
40 ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection) final;
41
42 void ReadFloat16(Float_t *f, TStreamerElement *ele = nullptr) final;
43 void WriteFloat16(Float_t *f, TStreamerElement *ele = nullptr) final;
44 void ReadDouble32(Double_t *d, TStreamerElement *ele = nullptr) final;
45 void WriteDouble32(Double_t *d, TStreamerElement *ele = nullptr) final;
46 void ReadWithFactor(Float_t *ptr, Double_t factor, Double_t minvalue) final;
47 void ReadWithNbits(Float_t *ptr, Int_t nbits) final;
48 void ReadWithFactor(Double_t *ptr, Double_t factor, Double_t minvalue) final;
49 void ReadWithNbits(Double_t *ptr, Int_t nbits) final;
50
51 Int_t ReadArrayFloat16(Float_t *&f, TStreamerElement *ele = nullptr) override;
52 Int_t ReadArrayDouble32(Double_t *&d, TStreamerElement *ele = nullptr) override;
53
56
57 void ReadFastArrayFloat16(Float_t *f, Int_t n, TStreamerElement *ele = nullptr) final;
58 void ReadFastArrayDouble32(Double_t *d, Int_t n, TStreamerElement *ele = nullptr) final;
59 void ReadFastArrayWithFactor(Float_t *ptr, Int_t n, Double_t factor, Double_t minvalue) final;
60 void ReadFastArrayWithNbits(Float_t *ptr, Int_t n, Int_t nbits) final;
61 void ReadFastArrayWithFactor(Double_t *ptr, Int_t n, Double_t factor, Double_t minvalue) final;
62 void ReadFastArrayWithNbits(Double_t *ptr, Int_t n, Int_t nbits) final;
63
64 void WriteArrayFloat16(const Float_t *f, Int_t n, TStreamerElement *ele = nullptr) final;
65 void WriteArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele = nullptr) final;
66
67 void WriteFastArrayFloat16(const Float_t *d, Long64_t n, TStreamerElement *ele = nullptr) final;
68 void WriteFastArrayDouble32(const Double_t *d, Long64_t n, TStreamerElement *ele = nullptr) final;
69
70 // Utilities for TClass
71 Int_t ReadClassBuffer(const TClass * /*cl*/, void * /*pointer*/, const TClass * /*onfile_class*/ = nullptr) override;
72 Int_t ReadClassBuffer(const TClass * /*cl*/, void * /*pointer*/, Int_t /*version*/, UInt_t /*start*/,
73 UInt_t /*count*/, const TClass * /*onfile_class*/ = nullptr) override;
74 Int_t WriteClassBuffer(const TClass *cl, void *pointer) override;
75
76 // virtual abstract TBuffer methods, which are not used in text streaming
77
78 Int_t CheckByteCount(UInt_t /* startpos */, UInt_t /* bcnt */, const TClass * /* clss */) final { return 0; }
79 Int_t CheckByteCount(UInt_t /* startpos */, UInt_t /* bcnt */, const char * /* classname */) final { return 0; }
80 void SetByteCount(UInt_t /* cntpos */, Bool_t /* packInVersion */ = kFALSE) final {}
81 void SkipVersion(const TClass *cl = nullptr) final;
82 Version_t ReadVersionNoCheckSum(UInt_t *, UInt_t *) final { return 0; }
83
84 Int_t ReadBuf(void * /*buf*/, Int_t /*max*/) final
85 {
86 Error("ReadBuf", "useless in text streamers");
87 return 0;
88 }
89 void WriteBuf(const void * /*buf*/, Int_t /*max*/) final { Error("WriteBuf", "useless in text streamers"); }
90
91 char *ReadString(char * /*s*/, Int_t /*max*/) final
92 {
93 Error("ReadString", "useless");
94 return nullptr;
95 }
96 void WriteString(const char * /*s*/) final { Error("WriteString", "useless"); }
97
98 Version_t ReadVersionForMemberWise(const TClass * /*cl*/ = nullptr) final
99 {
100 Error("ReadVersionForMemberWise", "not defined in text-based streamers");
101 return 0;
102 }
103 UInt_t WriteVersionMemberWise(const TClass * /*cl*/, Bool_t /*useBcnt*/ = kFALSE) final
104 {
105 Error("WriteVersionMemberWise", "not defined in text-based streamers");
106 return 0;
107 }
108
109 TObject *ReadObject(const TClass * /*cl*/) final
110 {
111 Error("ReadObject", "not yet implemented for text-based streamers");
112 return nullptr;
113 }
114
115 // Utilities for TClass
116 Int_t ReadClassEmulated(const TClass * /*cl*/, void * /*object*/, const TClass * /*onfile_class*/ = nullptr) final
117 {
118 Error("ReadClassEmulated", "not defined in text-based streamers");
119 return 0;
120 }
121
122 virtual void WriteBaseClass(void *start, TStreamerBase *elem);
123
124 virtual void ReadBaseClass(void *start, TStreamerBase *elem);
125
126 static void SetFloatFormat(const char *fmt = "%e");
127 static const char *GetFloatFormat();
128 static void SetDoubleFormat(const char *fmt = "%.14e");
129 static const char *GetDoubleFormat();
130
131 static void CompactFloatString(char *buf, unsigned len);
132 static const char *ConvertFloat(Float_t v, char *buf, unsigned len, Bool_t not_optimize = kFALSE);
133 static const char *ConvertDouble(Double_t v, char *buf, unsigned len, Bool_t not_optimize = kFALSE);
134
135protected:
136 static const char *fgFloatFmt; ///<! printf argument for floats, either "%f" or "%e" or "%10f" and so on
137 static const char *fgDoubleFmt; ///<! printf argument for doubles, either "%f" or "%e" or "%10f" and so on
138
139 ClassDefOverride(TBufferText, 0); // a TBuffer subclass for all text-based streamers
140};
141
142#endif
#define d(i)
Definition RSha256.hxx:102
#define f(i)
Definition RSha256.hxx:104
bool Bool_t
Definition RtypesCore.h:63
short Version_t
Definition RtypesCore.h:65
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:80
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
Direct subclass of TBuffer, implements common methods for TBufferFile and TBufferText classes.
Definition TBufferIO.h:30
Base class for text-based streamers like TBufferJSON or TBufferXML Special actions list will use meth...
Definition TBufferText.h:20
Int_t CheckByteCount(UInt_t, UInt_t, const TClass *) final
Definition TBufferText.h:78
static const char * ConvertFloat(Float_t v, char *buf, unsigned len, Bool_t not_optimize=kFALSE)
convert float to string with configured format
void WriteFastArrayDouble32(const Double_t *d, Long64_t n, TStreamerElement *ele=nullptr) final
Write array of Double32_t to buffer.
TObject * ReadObject(const TClass *) final
char * ReadString(char *, Int_t) final
Definition TBufferText.h:91
static const char * GetFloatFormat()
return current printf format for float members, default "%e"
Int_t ReadArrayDouble32(Double_t *&d, TStreamerElement *ele=nullptr) override
Read array of Double32_t from buffer.
void WriteBuf(const void *, Int_t) final
Definition TBufferText.h:89
void ReadFastArrayFloat16(Float_t *f, Int_t n, TStreamerElement *ele=nullptr) final
read array of Float16_t from buffer
void ReadFastArrayDouble32(Double_t *d, Int_t n, TStreamerElement *ele=nullptr) final
read array of Double32_t from buffer
Int_t ReadArrayFloat16(Float_t *&f, TStreamerElement *ele=nullptr) override
Read array of Float16_t from buffer.
Version_t ReadVersionForMemberWise(const TClass *=nullptr) final
Definition TBufferText.h:98
void ReadWithNbits(Float_t *ptr, Int_t nbits) final
Read a Float16_t from the buffer when the number of bits is specified (explicitly or not) see comment...
TBufferText()
Default constructor.
void WriteArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=nullptr) final
Write array of Double32_t to buffer.
Int_t WriteClassBuffer(const TClass *cl, void *pointer) override
Function called by the Streamer functions to serialize object at p to buffer b.
static void CompactFloatString(char *buf, unsigned len)
method compress float string, excluding exp and/or move float point
void ReadFastArrayWithFactor(Float_t *ptr, Int_t n, Double_t factor, Double_t minvalue) final
read array of Float16_t from buffer
static const char * ConvertDouble(Double_t v, char *buf, unsigned len, Bool_t not_optimize=kFALSE)
convert float to string with configured format
void StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass=nullptr) override
stream object to/from buffer
Int_t ReadBuf(void *, Int_t) final
Definition TBufferText.h:84
Int_t ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection) final
Read one collection of objects from the buffer using the StreamerInfoLoopAction.
void WriteArrayFloat16(const Float_t *f, Int_t n, TStreamerElement *ele=nullptr) final
Write array of Float16_t to buffer.
void ReadFastArrayWithNbits(Float_t *ptr, Int_t n, Int_t nbits) final
read array of Float16_t from buffer
Int_t CheckByteCount(UInt_t, UInt_t, const char *) final
Definition TBufferText.h:79
void ReadFloat16(Float_t *f, TStreamerElement *ele=nullptr) final
read a Float16_t from the buffer
Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *object) final
Read one collection of objects from the buffer using the StreamerInfoLoopAction.
void SkipVersion(const TClass *cl=nullptr) final
Skip class version from I/O buffer.
Int_t ReadClassEmulated(const TClass *, void *, const TClass *=nullptr) final
virtual void WriteBaseClass(void *start, TStreamerBase *elem)
Write data of base class.
~TBufferText() override
destructor
void SetByteCount(UInt_t, Bool_t=kFALSE) final
Definition TBufferText.h:80
void WriteString(const char *) final
Definition TBufferText.h:96
Int_t ReadStaticArrayFloat16(Float_t *f, TStreamerElement *ele=nullptr) final
Read array of Float16_t from buffer.
Int_t ReadStaticArrayDouble32(Double_t *d, TStreamerElement *ele=nullptr) final
Read array of Double32_t from buffer.
static const char * fgDoubleFmt
! printf argument for doubles, either "%f" or "%e" or "%10f" and so on
virtual void ReadBaseClass(void *start, TStreamerBase *elem)
Read data of base class.
UInt_t WriteVersionMemberWise(const TClass *, Bool_t=kFALSE) final
static void SetFloatFormat(const char *fmt="%e")
set printf format for float/double members, default "%e" to change format only for doubles,...
Int_t ReadClassBuffer(const TClass *, void *, const TClass *=nullptr) override
Deserialize information from a buffer into an object.
void WriteFloat16(Float_t *f, TStreamerElement *ele=nullptr) final
write a Float16_t to the buffer
Version_t ReadVersionNoCheckSum(UInt_t *, UInt_t *) final
Definition TBufferText.h:82
static const char * GetDoubleFormat()
return current printf format for double members, default "%.14e"
void ReadDouble32(Double_t *d, TStreamerElement *ele=nullptr) final
read a Double32_t from the buffer
void WriteFastArrayFloat16(const Float_t *d, Long64_t n, TStreamerElement *ele=nullptr) final
Write array of Float16_t to buffer.
void ReadWithFactor(Float_t *ptr, Double_t factor, Double_t minvalue) final
Read a Double32_t from the buffer when the factor and minimun value have been specified see comments ...
void WriteDouble32(Double_t *d, TStreamerElement *ele=nullptr) final
write a Double32_t to the buffer
static const char * fgFloatFmt
! printf argument for floats, either "%f" or "%e" or "%10f" and so on
static void SetDoubleFormat(const char *fmt="%.14e")
set printf format for double members, default "%.14e" use it after SetFloatFormat,...
virtual void StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass=nullptr)=0
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
This class stores a (key,value) pair using an external hash.
Definition TExMap.h:33
Mother of all ROOT objects.
Definition TObject.h:41
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:987
const Int_t n
Definition legend1.C:16