File indexing completed on 2025-01-18 10:11:34
0001
0002
0003
0004 #ifndef ROOT_TBufferSQL2
0005 #define ROOT_TBufferSQL2
0006
0007 #include "TBufferText.h"
0008 #include "TString.h"
0009 #include <string>
0010
0011 class TMap;
0012 class TExMap;
0013 class TVirtualStreamerInfo;
0014 class TStreamerElement;
0015 class TObjArray;
0016 class TMemberStreamer;
0017
0018 class TSQLStackObj;
0019 class TSQLServer;
0020 class TSQLResult;
0021 class TSQLRow;
0022 class TSQLFile;
0023 class TSQLStructure;
0024 class TSQLObjectData;
0025 class TSQLClassInfo;
0026
0027 class TBufferSQL2 final : public TBufferText {
0028
0029 friend class TSQLStructure;
0030
0031 protected:
0032 TSQLFile *fSQL;
0033 Int_t fIOVersion;
0034 TSQLStructure *fStructure;
0035 TSQLStructure *fStk;
0036 TString fReadBuffer;
0037 Int_t fErrorFlag;
0038 Int_t fCompressLevel;
0039 Int_t fReadVersionBuffer;
0040 Long64_t fObjIdCounter;
0041 Bool_t fIgnoreVerification;
0042 TSQLObjectData *fCurrentData;
0043 TObjArray *fObjectsInfos;
0044 Long64_t fFirstObjId;
0045 Long64_t fLastObjId;
0046 TMap *fPoolsMap;
0047
0048
0049 TBufferSQL2(const TBufferSQL2 &) = delete;
0050 void operator=(const TBufferSQL2 &) = delete;
0051
0052 TBufferSQL2();
0053
0054
0055
0056 void WriteObjectClass(const void *actualObjStart, const TClass *actualClass, Bool_t cacheReuse) final;
0057
0058
0059
0060 TSQLStructure *PushStack();
0061 TSQLStructure *PopStack();
0062 TSQLStructure *Stack(Int_t depth = 0);
0063
0064 void WorkWithClass(const char *classname, Version_t classversion);
0065 void WorkWithElement(TStreamerElement *elem, Int_t comp_type);
0066
0067 Int_t SqlReadArraySize();
0068 Bool_t SqlObjectInfo(Long64_t objid, TString &clname, Version_t &version);
0069 TSQLObjectData *SqlObjectData(Long64_t objid, TSQLClassInfo *sqlinfo);
0070
0071 Bool_t SqlWriteBasic(Char_t value);
0072 Bool_t SqlWriteBasic(Short_t value);
0073 Bool_t SqlWriteBasic(Int_t value);
0074 Bool_t SqlWriteBasic(Long_t value);
0075 Bool_t SqlWriteBasic(Long64_t value);
0076 Bool_t SqlWriteBasic(Float_t value);
0077 Bool_t SqlWriteBasic(Double_t value);
0078 Bool_t SqlWriteBasic(Bool_t value);
0079 Bool_t SqlWriteBasic(UChar_t value);
0080 Bool_t SqlWriteBasic(UShort_t value);
0081 Bool_t SqlWriteBasic(UInt_t value);
0082 Bool_t SqlWriteBasic(ULong_t value);
0083 Bool_t SqlWriteBasic(ULong64_t value);
0084 Bool_t SqlWriteValue(const char *value, const char *tname);
0085
0086 void SqlReadBasic(Char_t &value);
0087 void SqlReadBasic(Short_t &value);
0088 void SqlReadBasic(Int_t &value);
0089 void SqlReadBasic(Long_t &value);
0090 void SqlReadBasic(Long64_t &value);
0091 void SqlReadBasic(Float_t &value);
0092 void SqlReadBasic(Double_t &value);
0093 void SqlReadBasic(Bool_t &value);
0094 void SqlReadBasic(UChar_t &value);
0095 void SqlReadBasic(UShort_t &value);
0096 void SqlReadBasic(UInt_t &value);
0097 void SqlReadBasic(ULong_t &value);
0098 void SqlReadBasic(ULong64_t &value);
0099 const char *SqlReadValue(const char *tname);
0100 const char *SqlReadCharStarValue();
0101
0102 Int_t SqlWriteObject(const void *obj, const TClass *objClass, Bool_t cacheReuse, TMemberStreamer *streamer = nullptr,
0103 Int_t streamer_index = 0);
0104 void *SqlReadObject(void *obj, TClass **cl = nullptr, TMemberStreamer *streamer = nullptr, Int_t streamer_index = 0,
0105 const TClass *onFileClass = nullptr);
0106 void *SqlReadObjectDirect(void *obj, TClass **cl, Long64_t objid, TMemberStreamer *streamer = nullptr,
0107 Int_t streamer_index = 0, const TClass *onFileClass = nullptr);
0108
0109 void StreamObjectExtra(void *obj, TMemberStreamer *streamer, const TClass *cl, Int_t n = 0,
0110 const TClass *onFileClass = nullptr);
0111
0112 template <typename T>
0113 R__ALWAYS_INLINE void SqlReadArrayContent(T *arr, Int_t arrsize, Bool_t withsize);
0114
0115 template <typename T>
0116 R__ALWAYS_INLINE Int_t SqlReadArray(T *&arr, Bool_t is_static = kFALSE);
0117
0118 template <typename T>
0119 R__ALWAYS_INLINE void SqlReadFastArray(T *arr, Int_t arrsize);
0120
0121 template <typename T>
0122 R__ALWAYS_INLINE void SqlWriteArray(T *arr, Long64_t arrsize, Bool_t withsize = kFALSE);
0123
0124 public:
0125 TBufferSQL2(TBuffer::EMode mode, TSQLFile *file = nullptr);
0126 ~TBufferSQL2() override;
0127
0128 void SetCompressionLevel(int level) { fCompressLevel = level; }
0129
0130 TSQLStructure *GetStructure() const { return fStructure; }
0131
0132 Int_t GetErrorFlag() const { return fErrorFlag; }
0133
0134 void SetIgnoreVerification() { fIgnoreVerification = kTRUE; }
0135
0136 TSQLStructure *SqlWriteAny(const void *obj, const TClass *cl, Long64_t objid);
0137
0138 void *SqlReadAny(Long64_t keyid, Long64_t objid, TClass **cl, void *obj = nullptr);
0139
0140
0141
0142 TClass *ReadClass(const TClass *cl = nullptr, UInt_t *objTag = nullptr) final;
0143 void WriteClass(const TClass *cl) final;
0144
0145
0146
0147 Version_t ReadVersion(UInt_t *start = nullptr, UInt_t *bcnt = nullptr, const TClass *cl = nullptr) final;
0148 UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt = kFALSE) final;
0149
0150 void *ReadObjectAny(const TClass *clCast) final;
0151 void SkipObjectAny() final;
0152
0153 void IncrementLevel(TVirtualStreamerInfo *) final;
0154 void SetStreamerElementNumber(TStreamerElement *elem, Int_t comp_type) final;
0155 void DecrementLevel(TVirtualStreamerInfo *) final;
0156
0157 void ClassBegin(const TClass *, Version_t = -1) final;
0158 void ClassEnd(const TClass *) final;
0159 void ClassMember(const char *name, const char *typeName = nullptr, Int_t arrsize1 = -1, Int_t arrsize2 = -1) final;
0160
0161 Int_t ReadArray(Bool_t *&b) final;
0162 Int_t ReadArray(Char_t *&c) final;
0163 Int_t ReadArray(UChar_t *&c) final;
0164 Int_t ReadArray(Short_t *&h) final;
0165 Int_t ReadArray(UShort_t *&h) final;
0166 Int_t ReadArray(Int_t *&i) final;
0167 Int_t ReadArray(UInt_t *&i) final;
0168 Int_t ReadArray(Long_t *&l) final;
0169 Int_t ReadArray(ULong_t *&l) final;
0170 Int_t ReadArray(Long64_t *&l) final;
0171 Int_t ReadArray(ULong64_t *&l) final;
0172 Int_t ReadArray(Float_t *&f) final;
0173 Int_t ReadArray(Double_t *&d) final;
0174
0175 Int_t ReadStaticArray(Bool_t *b) final;
0176 Int_t ReadStaticArray(Char_t *c) final;
0177 Int_t ReadStaticArray(UChar_t *c) final;
0178 Int_t ReadStaticArray(Short_t *h) final;
0179 Int_t ReadStaticArray(UShort_t *h) final;
0180 Int_t ReadStaticArray(Int_t *i) final;
0181 Int_t ReadStaticArray(UInt_t *i) final;
0182 Int_t ReadStaticArray(Long_t *l) final;
0183 Int_t ReadStaticArray(ULong_t *l) final;
0184 Int_t ReadStaticArray(Long64_t *l) final;
0185 Int_t ReadStaticArray(ULong64_t *l) final;
0186 Int_t ReadStaticArray(Float_t *f) final;
0187 Int_t ReadStaticArray(Double_t *d) final;
0188
0189 void ReadFastArray(Bool_t *b, Int_t n) final;
0190 void ReadFastArray(Char_t *c, Int_t n) final;
0191 void ReadFastArray(UChar_t *c, Int_t n) final;
0192 void ReadFastArray(Short_t *h, Int_t n) final;
0193 void ReadFastArray(UShort_t *h, Int_t n) final;
0194 void ReadFastArray(Int_t *i, Int_t n) final;
0195 void ReadFastArray(UInt_t *i, Int_t n) final;
0196 void ReadFastArray(Long_t *l, Int_t n) final;
0197 void ReadFastArray(ULong_t *l, Int_t n) final;
0198 void ReadFastArray(Long64_t *l, Int_t n) final;
0199 void ReadFastArray(ULong64_t *l, Int_t n) final;
0200 void ReadFastArray(Float_t *f, Int_t n) final;
0201 void ReadFastArray(Double_t *d, Int_t n) final;
0202 void ReadFastArrayString(Char_t *c, Int_t n) final;
0203 void ReadFastArray(void *start, const TClass *cl, Int_t n = 1, TMemberStreamer *s = nullptr,
0204 const TClass *onFileClass = nullptr) final;
0205 void ReadFastArray(void **startp, const TClass *cl, Int_t n = 1, Bool_t isPreAlloc = kFALSE,
0206 TMemberStreamer *s = nullptr, const TClass *onFileClass = nullptr) final;
0207
0208 void WriteArray(const Bool_t *b, Int_t n) final;
0209 void WriteArray(const Char_t *c, Int_t n) final;
0210 void WriteArray(const UChar_t *c, Int_t n) final;
0211 void WriteArray(const Short_t *h, Int_t n) final;
0212 void WriteArray(const UShort_t *h, Int_t n) final;
0213 void WriteArray(const Int_t *i, Int_t n) final;
0214 void WriteArray(const UInt_t *i, Int_t n) final;
0215 void WriteArray(const Long_t *l, Int_t n) final;
0216 void WriteArray(const ULong_t *l, Int_t n) final;
0217 void WriteArray(const Long64_t *l, Int_t n) final;
0218 void WriteArray(const ULong64_t *l, Int_t n) final;
0219 void WriteArray(const Float_t *f, Int_t n) final;
0220 void WriteArray(const Double_t *d, Int_t n) final;
0221
0222 void WriteFastArray(const Bool_t *b, Long64_t n) final;
0223 void WriteFastArray(const Char_t *c, Long64_t n) final;
0224 void WriteFastArray(const UChar_t *c, Long64_t n) final;
0225 void WriteFastArray(const Short_t *h, Long64_t n) final;
0226 void WriteFastArray(const UShort_t *h, Long64_t n) final;
0227 void WriteFastArray(const Int_t *i, Long64_t n) final;
0228 void WriteFastArray(const UInt_t *i, Long64_t n) final;
0229 void WriteFastArray(const Long_t *l, Long64_t n) final;
0230 void WriteFastArray(const ULong_t *l, Long64_t n) final;
0231 void WriteFastArray(const Long64_t *l, Long64_t n) final;
0232 void WriteFastArray(const ULong64_t *l, Long64_t n) final;
0233 void WriteFastArray(const Float_t *f, Long64_t n) final;
0234 void WriteFastArray(const Double_t *d, Long64_t n) final;
0235 void WriteFastArrayString(const Char_t *c, Long64_t n) final;
0236 void WriteFastArray(void *start, const TClass *cl, Long64_t n = 1, TMemberStreamer *s = nullptr) final;
0237 Int_t WriteFastArray(void **startp, const TClass *cl, Long64_t n = 1, Bool_t isPreAlloc = kFALSE,
0238 TMemberStreamer *s = nullptr) final;
0239
0240 void StreamObject(void *obj, const TClass *cl, const TClass *onFileClass = nullptr) final;
0241 using TBufferText::StreamObject;
0242
0243 void ReadBool(Bool_t &b) final;
0244 void ReadChar(Char_t &c) final;
0245 void ReadUChar(UChar_t &c) final;
0246 void ReadShort(Short_t &s) final;
0247 void ReadUShort(UShort_t &s) final;
0248 void ReadInt(Int_t &i) final;
0249 void ReadUInt(UInt_t &i) final;
0250 void ReadLong(Long_t &l) final;
0251 void ReadULong(ULong_t &l) final;
0252 void ReadLong64(Long64_t &l) final;
0253 void ReadULong64(ULong64_t &l) final;
0254 void ReadFloat(Float_t &f) final;
0255 void ReadDouble(Double_t &d) final;
0256 void ReadCharP(Char_t *c) final;
0257 void ReadTString(TString &s) final;
0258 void ReadStdString(std::string *s) final;
0259 using TBuffer::ReadStdString;
0260 void ReadCharStar(char *&s) final;
0261
0262 void WriteBool(Bool_t b) final;
0263 void WriteChar(Char_t c) final;
0264 void WriteUChar(UChar_t c) final;
0265 void WriteShort(Short_t s) final;
0266 void WriteUShort(UShort_t s) final;
0267 void WriteInt(Int_t i) final;
0268 void WriteUInt(UInt_t i) final;
0269 void WriteLong(Long_t l) final;
0270 void WriteULong(ULong_t l) final;
0271 void WriteLong64(Long64_t l) final;
0272 void WriteULong64(ULong64_t l) final;
0273 void WriteFloat(Float_t f) final;
0274 void WriteDouble(Double_t d) final;
0275 void WriteCharP(const Char_t *c) final;
0276 void WriteTString(const TString &s) final;
0277 void WriteStdString(const std::string *s) final;
0278 using TBuffer::WriteStdString;
0279 void WriteCharStar(char *s) final;
0280
0281 TVirtualStreamerInfo *GetInfo() final;
0282
0283
0284
0285 ClassDefOverride(TBufferSQL2, 0);
0286 };
0287
0288 #endif