Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TBufferSQL2.cxx
Go to the documentation of this file.
1// @(#)root/sql:$Id$
2// Author: Sergey Linev 20/11/2005
3
4/*************************************************************************
5 * Copyright (C) 1995-2005, 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/**
13\class TBufferSQL2
14\ingroup IO
15
16Converts data to SQL statements or read data from SQL tables.
17
18Class for serializing/deserializing object to/from SQL data base.
19It redefines most of TBuffer class function to convert simple types,
20array of simple types and objects to/from TSQLStructure objects.
21TBufferSQL2 class uses streaming mechanism, provided by ROOT system,
22therefore most of ROOT and user classes can be stored. There are
23limitations for complex objects like TTree, TClonesArray, TDirectory and
24few other, which can not be converted to SQL (yet).
25*/
26
27#include "TBufferSQL2.h"
28
29#include "TROOT.h"
30#include "TDataType.h"
31#include "TClass.h"
32#include "TClassTable.h"
33#include "TMap.h"
34#include "TStreamerInfo.h"
35#include "TStreamerElement.h"
36#include "TMemberStreamer.h"
37#include "TStreamer.h"
39#include "snprintf.h"
40
41#include <cstdlib>
42#include <iostream>
43#include <limits>
44#include <string>
45
46#include "TSQLServer.h"
47#include "TSQLResult.h"
48#include "TSQLRow.h"
49#include "TSQLStructure.h"
50#include "TSQLObjectData.h"
51#include "TSQLFile.h"
52#include "TSQLClassInfo.h"
53
54
55////////////////////////////////////////////////////////////////////////////////
56/// Default constructor, should not be used
57
59 : TBufferText(), fSQL(nullptr), fIOVersion(1), fStructure(nullptr), fStk(nullptr), fReadBuffer(), fErrorFlag(0),
60 fCompressLevel(ROOT::RCompressionSetting::EAlgorithm::kUseGlobal), fReadVersionBuffer(-1), fObjIdCounter(1), fIgnoreVerification(kFALSE),
61 fCurrentData(nullptr), fObjectsInfos(nullptr), fFirstObjId(0), fLastObjId(0), fPoolsMap(nullptr)
62{
63}
64
65////////////////////////////////////////////////////////////////////////////////
66/// Creates buffer object to serialize/deserialize data to/from sql.
67/// This constructor should be used, if data from buffer supposed to be stored in file.
68/// Mode should be either TBuffer::kRead or TBuffer::kWrite.
69
71 : TBufferText(mode, file), fSQL(nullptr), fIOVersion(1), fStructure(nullptr), fStk(nullptr), fReadBuffer(), fErrorFlag(0),
72 fCompressLevel(ROOT::RCompressionSetting::EAlgorithm::kUseGlobal), fReadVersionBuffer(-1), fObjIdCounter(1), fIgnoreVerification(kFALSE),
73 fCurrentData(nullptr), fObjectsInfos(nullptr), fFirstObjId(0), fLastObjId(0), fPoolsMap(nullptr)
74{
75 fSQL = file;
76 if (file) {
78 fIOVersion = file->GetIOVersion();
79 }
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// Destroy sql buffer.
84
86{
87 if (fStructure)
88 delete fStructure;
89
90 if (fObjectsInfos) {
92 delete fObjectsInfos;
93 }
94
95 if (fPoolsMap) {
97 delete fPoolsMap;
98 }
99}
100
101////////////////////////////////////////////////////////////////////////////////
102/// Convert object of any class to sql structures
103/// Return pointer on created TSQLStructure
104/// TSQLStructure object will be owned by TBufferSQL2
105
106TSQLStructure *TBufferSQL2::SqlWriteAny(const void *obj, const TClass *cl, Long64_t objid)
107{
108 fErrorFlag = 0;
109
110 fStructure = nullptr;
111
112 fFirstObjId = objid;
113 fObjIdCounter = objid;
114
115 SqlWriteObject(obj, cl, kTRUE);
116
117 if (gDebug > 3)
118 if (fStructure) {
119 std::cout << "==== Printout of Sql structures ===== " << std::endl;
120 fStructure->Print("*");
121 std::cout << "=========== End printout ============ " << std::endl;
122 }
123
124 return fStructure;
125}
126
127////////////////////////////////////////////////////////////////////////////////
128/// Recreate object from sql structure.
129/// Return pointer to read object.
130/// if (cl!=0) returns pointer to class of object
131
133{
134 if (cl)
135 *cl = nullptr;
136 if (!fSQL)
137 return nullptr;
138
139 fCurrentData = nullptr;
140 fErrorFlag = 0;
141
143
145 fFirstObjId = objid;
146 fLastObjId = objid;
147 if (fObjectsInfos) {
149 if (objinfo)
150 fLastObjId = objinfo->GetObjId();
151 }
152
153 return SqlReadObjectDirect(obj, cl, objid);
154}
155
156////////////////////////////////////////////////////////////////////////////////
157/// Returns object info like classname and version
158/// Should be taken from buffer, which is produced in the beginning
159
161{
162 if ((objid < 0) || !fObjectsInfos)
163 return kFALSE;
164
165 // suppose that objects info are sorted out
166
167 Long64_t shift = objid - fFirstObjId;
168
169 TSQLObjectInfo *info = nullptr;
170 if ((shift >= 0) && (shift <= fObjectsInfos->GetLast())) {
171 info = (TSQLObjectInfo *)fObjectsInfos->At(shift);
172 if (info->GetObjId() != objid)
173 info = nullptr;
174 }
175
176 if (!info) {
177 // I hope, i will never get inside it
178 Info("SqlObjectInfo", "Standard not works %lld", objid);
179 for (Int_t n = 0; n <= fObjectsInfos->GetLast(); n++) {
181 if (info->GetObjId() == objid)
182 break;
183 info = nullptr;
184 }
185 }
186
187 if (!info)
188 return kFALSE;
189
190 clname = info->GetObjClassName();
191 version = info->GetObjVersion();
192 return kTRUE;
193}
194
195////////////////////////////////////////////////////////////////////////////////
196/// Creates TSQLObjectData for specified object id and specified class
197///
198/// Object data for each class can be stored in two different tables.
199/// First table contains data in column-wise form for simple types like integer,
200/// strings and so on when second table contains any other data which cannot
201/// be converted into column-wise representation.
202/// TSQLObjectData will contain results of the requests to both such tables for
203/// concrete object id.
204
206{
207 TSQLResult *classdata = nullptr;
208 TSQLRow *classrow = nullptr;
209
210 if (sqlinfo->IsClassTableExist()) {
211
212 TSQLObjectDataPool *pool = nullptr;
213
214 if (fPoolsMap)
216
217 if (pool && (fLastObjId >= fFirstObjId)) {
218 if (gDebug > 4)
219 Info("SqlObjectData", "Before request to %s", sqlinfo->GetClassTableName());
221 if (gDebug > 4)
222 Info("SqlObjectData", "After request res = 0x%zx", (size_t)alldata);
223 if (!alldata) {
224 Error("SqlObjectData", "Cannot get data from table %s", sqlinfo->GetClassTableName());
225 return nullptr;
226 }
227
228 if (!fPoolsMap)
229 fPoolsMap = new TMap();
232 }
233
234 if (!pool)
235 return nullptr;
236
237 if (pool->GetSqlInfo() != sqlinfo) {
238 Error("SqlObjectData", "Missmatch in pools map !!! CANNOT BE !!!");
239 return nullptr;
240 }
241
242 classdata = pool->GetClassData();
243
244 classrow = pool->GetObjectRow(objid);
245 if (!classrow) {
246 Error("SqlObjectData", "Can not find row for objid = %lld in table %s", objid, sqlinfo->GetClassTableName());
247 return nullptr;
248 }
249 }
250
251 TSQLResult *blobdata = nullptr;
253
254 if (!blobstmt)
256
258}
259
260////////////////////////////////////////////////////////////////////////////////
261/// Write object to buffer.
262/// If object was written before, only pointer will be stored
263/// Return id of saved object
264
267{
268 if (gDebug > 1)
269 Info("SqlWriteObject", "Object: %p Class: %s", obj, (cl ? cl->GetName() : "null"));
270
271 PushStack();
272
273 Long64_t objid = -1;
274
275 if (!cl)
276 obj = nullptr;
277
278 if (!obj) {
279 objid = 0;
280 } else {
282 if (value > 0)
283 objid = fFirstObjId + value - 1;
284 }
285
286 if (gDebug > 1)
287 Info("SqlWriteObject", "Find objectid %ld", (long)objid);
288
289 if (objid >= 0) {
290 Stack()->SetObjectPointer(objid);
291 PopStack();
292 return objid;
293 }
294
295 objid = fObjIdCounter++;
296
297 Stack()->SetObjectRef(objid, cl);
298
299 if (cacheReuse)
300 MapObject(obj, cl, objid - fFirstObjId + 1);
301
302 if (streamer)
303 (*streamer)(*this, (void *)obj, streamer_index);
304 else
305 ((TClass *)cl)->Streamer((void *)obj, *this);
306
307 if (gDebug > 1)
308 Info("SqlWriteObject", "Done write of %s", cl->GetName());
309
310 PopStack();
311
312 return objid;
313}
314
315////////////////////////////////////////////////////////////////////////////////
316/// Read object from the buffer
317
319 const TClass *onFileClass)
320{
321 if (cl)
322 *cl = nullptr;
323
324 if (fErrorFlag > 0)
325 return obj;
326
328
329 const char *refid = fCurrentData->GetValue();
330 if (!refid || (strlen(refid) == 0)) {
331 Error("SqlReadObject", "Invalid object reference value");
332 fErrorFlag = 1;
333 return obj;
334 }
335
336 Long64_t objid = (Long64_t)std::stoll(refid);
337
338 if (gDebug > 2)
339 Info("SqlReadObject", "Starting objid: %ld column: %s", (long)objid, fCurrentData->GetLocatedField());
340
342 if (objid == 0) {
343 obj = nullptr;
344 findptr = kTRUE;
345 } else if (objid == -1) {
346 findptr = kTRUE;
347 } else if (objid >= fFirstObjId) {
348 void *obj1 = nullptr;
349 TClass *cl1 = nullptr;
350 GetMappedObject(objid - fFirstObjId + 1, obj1, cl1);
351 if (obj1 && cl1) {
352 obj = obj1;
353 if (cl)
354 *cl = cl1;
355 }
356 }
357 }
358
359 if ((gDebug > 3) && findptr)
360 Info("SqlReadObject", "Found pointer %p cl %s", obj, ((cl && *cl) ? (*cl)->GetName() : "null"));
361
362 if (findptr) {
364 return obj;
365 }
366
369 Error("SqlReadObject", "Object reference or pointer is not found in blob data");
370 fErrorFlag = 1;
371 return obj;
372 }
373
375
376 if ((gDebug > 2) || (objid < 0))
377 Info("SqlReadObject", "Found object reference %ld", (long)objid);
378
379 return SqlReadObjectDirect(obj, cl, objid, streamer, streamer_index, onFileClass);
380}
381
382////////////////////////////////////////////////////////////////////////////////
383/// Read object data.
384/// Class name and version are taken from special objects table.
385
388{
391
392 if (!SqlObjectInfo(objid, clname, version))
393 return obj;
394
395 if (gDebug > 2)
396 Info("SqlReadObjectDirect", "objid = %lld clname = %s ver = %d", objid, clname.Data(), version);
397
399
403
404 if (!objClass || !sqlinfo) {
405 Error("SqlReadObjectDirect", "Class %s is not known", clname.Data());
406 return obj;
407 }
408
409 if (!obj)
410 obj = objClass->New();
411
412 MapObject(obj, objClass, objid - fFirstObjId + 1);
413
415
417
418 if (sqlinfo->IsClassTableExist()) {
419 // TObject and TString classes treated differently
420 if ((objClass == TObject::Class()) || (objClass == TString::Class())) {
421
423 if (objClass == TObject::Class())
425 else if (objClass == TString::Class())
427
430 } else
431 // before normal streamer first version will be read and
432 // then streamer functions of TStreamerInfo class
434 } else {
436 if (!objdata || !objdata->PrepareForRawData()) {
437 Error("SqlReadObjectDirect", "No found raw data for obj %lld in class %s version %d table", objid,
438 clname.Data(), version);
439 fErrorFlag = 1;
440 return obj;
441 }
442
444
446 }
447
448 if (streamer) {
449 streamer->SetOnFileClass(onFileClass);
450 (*streamer)(*this, (void *)obj, streamer_index);
451 } else {
452 objClass->Streamer((void *)obj, *this, onFileClass);
453 }
454
455 PopStack();
456
457 if (gDebug > 1)
458 Info("SqlReadObjectDirect", "Read object of class %s done", objClass->GetName());
459
460 if (cl)
461 *cl = objClass;
462
464
465 return obj;
466}
467
468////////////////////////////////////////////////////////////////////////////////
469/// Function is called from TStreamerInfo WriteBuffer and Readbuffer functions
470/// and indent new level in data structure.
471/// This call indicates, that TStreamerInfo functions starts streaming
472/// object data of correspondent class
473
475{
476 if (!info)
477 return;
478
480
481 if (gDebug > 2)
482 Info("IncrementLevel", "Info: %s", info->GetName());
483
484 WorkWithClass(info->GetName(), info->GetClassVersion());
485}
486
487////////////////////////////////////////////////////////////////////////////////
488/// Function is called from TStreamerInfo WriteBuffer and Readbuffer functions
489/// and decrease level in sql structure.
490
492{
493 if (Stack()->GetElement())
494 PopStack(); // for element
495 PopStack(); // for streamerinfo
496
497 // restore value of object data
499
500 if (gDebug > 2)
501 Info("DecrementLevel", "Info: %s", info->GetName());
502}
503
504////////////////////////////////////////////////////////////////////////////////
505/// Function is called from TStreamerInfo WriteBuffer and Readbuffer functions
506/// and add/verify next element in sql tables
507/// This calls allows separate data, correspondent to one class member, from another
508
510{
511 if (Stack()->GetElement())
512 PopStack(); // was with if (number > 0), i.e. not first element.
514
515 TStreamerInfo *info = curr->GetStreamerInfo();
516 if (!info) {
517 Error("SetStreamerElementNumber", "Error in structures stack");
518 return;
519 }
520
522}
523
524////////////////////////////////////////////////////////////////////////////////
525/// This method inform buffer data of which class now
526/// will be streamed. When reading, classversion should be specified
527/// as was read by TBuffer::ReadVersion().
528///
529/// ClassBegin(), ClassEnd() & ClassMemeber() should be used in
530/// custom class streamers to specify which kind of data are
531/// now streamed to/from buffer. That information is used to correctly
532/// convert class data to/from "normal" sql tables with meaningfull names
533/// and correct datatypes. Without that functions data from custom streamer
534/// will be saved as "raw" data in special _streamer_ table one value after another
535/// Such MUST be used when object is written with standard ROOT streaming
536/// procedure, but should be read back in custom streamer.
537/// For example, custom streamer of TNamed class may look like:
538
540{
541 // void TNamed::Streamer(TBuffer &b)
542 // UInt_t R__s, R__c;
543 // if (b.IsReading()) {
544 // Version_t R__v = b.ReadVersion(&R__s, &R__c);
545 // b.ClassBegin(TNamed::Class(), R__v);
546 // b.ClassMember("TObject");
547 // TObject::Streamer(b);
548 // b.ClassMember("fName","TString");
549 // fName.Streamer(b);
550 // b.ClassMember("fTitle","TString");
551 // fTitle.Streamer(b);
552 // b.ClassEnd(TNamed::Class());
553 // b.SetBufferOffset(R__s+R__c+sizeof(UInt_t));
554 // } else {
555 // TNamed::Class()->WriteBuffer(b,this);
556 // }
557
558 if (classversion < 0)
560
562
563 if (gDebug > 2)
564 Info("ClassBegin", "Class: %s", cl->GetName());
565
567}
568
569////////////////////////////////////////////////////////////////////////////////
570/// Method indicates end of streaming of classdata in custom streamer.
571/// See ClassBegin() method for more details.
572
574{
575 if (Stack()->GetType() == TSQLStructure::kSqlCustomElement)
576 PopStack(); // for element
577 PopStack(); // for streamerinfo
578
579 // restore value of object data
581
582 if (gDebug > 2)
583 Info("ClassEnd", "Class: %s", cl->GetName());
584}
585
586////////////////////////////////////////////////////////////////////////////////
587/// Method indicates name and typename of class memeber,
588/// which should be now streamed in custom streamer
589/// Following combinations are supported:
590/// see TBufferXML::ClassMember for the details.
591
592void TBufferSQL2::ClassMember(const char *name, const char *typeName, Int_t arrsize1, Int_t arrsize2)
593{
594 if (!typeName)
595 typeName = name;
596
597 if (!name || (strlen(name) == 0)) {
598 Error("ClassMember", "Invalid member name");
599 fErrorFlag = 1;
600 return;
601 }
602
603 TString tname = typeName;
604
605 Int_t typ_id = -1;
606
607 if (strcmp(typeName, "raw:data") == 0)
609
610 if (typ_id < 0) {
611 TDataType *dt = gROOT->GetType(typeName);
612 if (dt)
613 if ((dt->GetType() > 0) && (dt->GetType() < 20))
614 typ_id = dt->GetType();
615 }
616
617 if (typ_id < 0)
618 if (strcmp(name, typeName) == 0) {
619 TClass *cl = TClass::GetClass(tname.Data());
620 if (cl)
622 }
623
624 if (typ_id < 0) {
626 if (tname[tname.Length() - 1] == '*') {
627 tname.Resize(tname.Length() - 1);
628 isptr = kTRUE;
629 }
630 TClass *cl = TClass::GetClass(tname.Data());
631 if (!cl) {
632 Error("ClassMember", "Invalid class specifier %s", typeName);
633 fErrorFlag = 1;
634 return;
635 }
636
637 if (cl->IsTObject())
639 else
641
642 if ((cl == TString::Class()) && !isptr)
644 }
645
646 TStreamerElement *elem = nullptr;
647
649 elem = new TStreamerElement(name, "title", 0, typ_id, "raw:data");
650 } else if (typ_id == TStreamerInfo::kBase) {
651 TClass *cl = TClass::GetClass(tname.Data());
652 if (cl) {
653 TStreamerBase *b = new TStreamerBase(tname.Data(), "title", 0);
654 b->SetBaseVersion(cl->GetClassVersion());
655 elem = b;
656 }
657 } else if ((typ_id > 0) && (typ_id < 20)) {
658 elem = new TStreamerBasicType(name, "title", 0, typ_id, typeName);
661 elem = new TStreamerObject(name, "title", 0, tname.Data());
662 } else if (typ_id == TStreamerInfo::kObjectp) {
663 elem = new TStreamerObjectPointer(name, "title", 0, tname.Data());
664 } else if (typ_id == TStreamerInfo::kAny) {
665 elem = new TStreamerObjectAny(name, "title", 0, tname.Data());
666 } else if (typ_id == TStreamerInfo::kAnyp) {
667 elem = new TStreamerObjectAnyPointer(name, "title", 0, tname.Data());
668 } else if (typ_id == TStreamerInfo::kTString) {
669 elem = new TStreamerString(name, "title", 0);
670 }
671
672 if (!elem) {
673 Error("ClassMember", "Invalid combination name = %s type = %s", name, typeName);
674 fErrorFlag = 1;
675 return;
676 }
677
678 if (arrsize1 > 0) {
679 elem->SetArrayDim(arrsize2 > 0 ? 2 : 1);
680 elem->SetMaxIndex(0, arrsize1);
681 if (arrsize2 > 0)
682 elem->SetMaxIndex(1, arrsize2);
683 }
684
685 // return stack to CustomClass node
687 PopStack();
688
689 // we indicate that there is no streamerinfo
691}
692
693////////////////////////////////////////////////////////////////////////////////
694/// This function is a part of IncrementLevel method.
695/// Also used in StartClass method
696
698{
699 if (IsReading()) {
700 Long64_t objid = 0;
701
702 // if ((fCurrentData!=0) && fCurrentData->VerifyDataType(sqlio::ObjectInst, kFALSE))
703 // if (!fCurrentData->IsBlobData()) Info("WorkWithClass","Big problem %s", fCurrentData->GetValue());
704
706 objid = atoi(fCurrentData->GetValue());
709 sobjid.Form("%lld", objid);
710 Stack()->ChangeValueOnly(sobjid.Data());
711 } else
712 objid = Stack()->DefineObjectId(kTRUE);
713 if (objid < 0) {
714 Error("WorkWithClass", "cannot define object id");
715 fErrorFlag = 1;
716 return;
717 }
718
720 if (!sqlinfo) {
721 Error("WorkWithClass", "Can not find table for class %s version %d", classname, classversion);
722 fErrorFlag = 1;
723 return;
724 }
725
727 if (!objdata) {
728 Error("WorkWithClass", "Request error for data of object %lld for class %s version %d", objid, classname,
730 fErrorFlag = 1;
731 return;
732 }
733
735
737 }
738}
739
740////////////////////////////////////////////////////////////////////////////////
741/// This function is a part of SetStreamerElementNumber method.
742/// It is introduced for reading of data for specified data member of class.
743/// Used also in ReadFastArray methods to resolve problem of compressed data,
744/// when several data members of the same basic type streamed with single ...FastArray call
745
747{
748 if (gDebug > 2)
749 Info("WorkWithElement", "elem = %s", elem->GetName());
750
751 TSQLStructure *stack = Stack(1);
753 Int_t number = info ? info->GetElements()->IndexOf(elem) : -1;
754
755 if (number >= 0)
757 else
759
760 if (IsReading()) {
761
762 if (!fCurrentData) {
763 Error("WorkWithElement", "Object data is lost");
764 fErrorFlag = 1;
765 return;
766 }
767
769
771
773 Error("WorkWithElement", "Cannot locate correct column in the table");
774 fErrorFlag = 1;
775 return;
778 // search again for object data while for BLOB it should be already assign
780 }
781 }
782}
783
784////////////////////////////////////////////////////////////////////////////////
785/// Suppressed function of TBuffer
786
788{
789 return nullptr;
790}
791
792////////////////////////////////////////////////////////////////////////////////
793/// Suppressed function of TBuffer
794
796{
797}
798
799////////////////////////////////////////////////////////////////////////////////
800/// Read version value from buffer
801/// actually version is normally defined by table name
802/// and kept in intermediate variable fReadVersionBuffer
803
805{
806 Version_t res = 0;
807
808 if (start)
809 *start = 0;
810 if (bcnt)
811 *bcnt = 0;
812
813 if (fReadVersionBuffer >= 0) {
814 res = fReadVersionBuffer;
816 if (gDebug > 3)
817 Info("ReadVersion", "from buffer = %d", (int)res);
820 res = value.Atoi();
821 if (gDebug > 3)
822 Info("ReadVersion", "from blob %s = %d", fCurrentData->GetBlobPrefixName(), (int)res);
824 } else {
825 Error("ReadVersion", "No correspondent tags to read version");
826 fErrorFlag = 1;
827 }
828
829 return res;
830}
831
832////////////////////////////////////////////////////////////////////////////////
833/// Copies class version to buffer, but not writes it to sql immidiately
834/// Version will be used to produce complete table
835/// name, which will include class version
836
838{
839 if (gDebug > 2)
840 Info("WriteVersion", "cl:%s ver:%d", (cl ? cl->GetName() : "null"), (int)(cl ? cl->GetClassVersion() : 0));
841
842 if (cl)
843 Stack()->AddVersion(cl);
844
845 return 0;
846}
847
848////////////////////////////////////////////////////////////////////////////////
849/// Read object from buffer. Only used from TBuffer.
850
852{
853 return SqlReadObject(nullptr);
854}
855
856////////////////////////////////////////////////////////////////////////////////
857/// ?????? Skip any kind of object from buffer
858/// !!!!!! fix me, not yet implemented
859/// Should be just skip of current column later
860
864
865////////////////////////////////////////////////////////////////////////////////
866/// Write object to buffer. Only used from TBuffer
867
869{
870 if (gDebug > 2)
871 Info("WriteObjectClass", "class %s", (actualClass ? actualClass->GetName() : " null"));
873}
874
875////////////////////////////////////////////////////////////////////////////////
876/// Template method to read array content
877
878template <typename T>
880{
881 if (gDebug > 3)
882 Info("SqlReadArrayContent", "size %d", (int)(arrsize));
884 Int_t indx(0), first, last;
885 if (fCurrentData->IsBlobData()) {
886 while (indx < arrsize) {
887 const char *name = fCurrentData->GetBlobPrefixName();
889 sscanf(name, "[%d", &first);
890 last = first;
891 } else {
892 sscanf(name, "[%d..%d", &first, &last);
893 }
894 if ((first != indx) || (last < first) || (last >= arrsize)) {
895 Error("SqlReadArrayContent", "Error reading array content %s", name);
896 fErrorFlag = 1;
897 break;
898 }
900 while (indx <= last)
901 arr[indx++] = arr[first];
902 }
903 } else {
904 while (indx < arrsize)
906 }
907 PopStack();
908 if (gDebug > 3)
909 Info("SqlReadArrayContent", "done");
910}
911
912template <typename T>
914{
916 if (n <= 0)
917 return 0;
918 if (!arr) {
919 if (is_static)
920 return 0;
921 arr = new T[n];
922 }
924 return n;
925}
926
927////////////////////////////////////////////////////////////////////////////////
928/// Read array of Bool_t from buffer
929
934
935////////////////////////////////////////////////////////////////////////////////
936/// Read array of Char_t from buffer
937
942
943////////////////////////////////////////////////////////////////////////////////
944/// Read array of UChar_t from buffer
945
950
951////////////////////////////////////////////////////////////////////////////////
952/// Read array of Short_t from buffer
953
958
959////////////////////////////////////////////////////////////////////////////////
960/// Read array of UShort_t from buffer
961
966
967////////////////////////////////////////////////////////////////////////////////
968/// Read array of Int_t from buffer
969
971{
972 return SqlReadArray(i);
973}
974
975////////////////////////////////////////////////////////////////////////////////
976/// Read array of UInt_t from buffer
977
979{
980 return SqlReadArray(i);
981}
982
983////////////////////////////////////////////////////////////////////////////////
984/// Read array of Long_t from buffer
985
990
991////////////////////////////////////////////////////////////////////////////////
992/// Read array of ULong_t from buffer
993
998
999////////////////////////////////////////////////////////////////////////////////
1000/// Read array of Long64_t from buffer
1001
1006
1007////////////////////////////////////////////////////////////////////////////////
1008/// Read array of ULong64_t from buffer
1009
1014
1015////////////////////////////////////////////////////////////////////////////////
1016/// Read array of Float_t from buffer
1017
1022
1023////////////////////////////////////////////////////////////////////////////////
1024/// Read array of Double_t from buffer
1025
1030
1031////////////////////////////////////////////////////////////////////////////////
1032/// Read array of Bool_t from buffer
1033
1038
1039////////////////////////////////////////////////////////////////////////////////
1040/// Read array of Char_t from buffer
1041
1046
1047////////////////////////////////////////////////////////////////////////////////
1048/// Read array of UChar_t from buffer
1049
1054
1055////////////////////////////////////////////////////////////////////////////////
1056/// Read array of Short_t from buffer
1057
1062
1063////////////////////////////////////////////////////////////////////////////////
1064/// Read array of UShort_t from buffer
1065
1070
1071////////////////////////////////////////////////////////////////////////////////
1072/// Read array of Int_t from buffer
1073
1078
1079////////////////////////////////////////////////////////////////////////////////
1080/// Read array of UInt_t from buffer
1081
1086
1087////////////////////////////////////////////////////////////////////////////////
1088/// Read array of Long_t from buffer
1089
1094
1095////////////////////////////////////////////////////////////////////////////////
1096/// Read array of ULong_t from buffer
1097
1102
1103////////////////////////////////////////////////////////////////////////////////
1104/// Read array of Long64_t from buffer
1105
1110
1111////////////////////////////////////////////////////////////////////////////////
1112/// Read array of ULong64_t from buffer
1113
1118
1119////////////////////////////////////////////////////////////////////////////////
1120/// Read array of Float_t from buffer
1121
1126
1127////////////////////////////////////////////////////////////////////////////////
1128/// Read array of Double_t from buffer
1129
1134
1135////////////////////////////////////////////////////////////////////////////////
1136/// Template method to read content of array, which not include size of array
1137
1138template <typename T>
1144
1145////////////////////////////////////////////////////////////////////////////////
1146/// Read array of Bool_t from buffer
1147
1152
1153////////////////////////////////////////////////////////////////////////////////
1154/// Read array of Char_t from buffer
1155/// if nodename==CharStar, read all array as string
1156
1158{
1160 const char *buf = SqlReadCharStarValue();
1161 if (!buf || (n <= 0))
1162 return;
1163 Int_t size = strlen(buf);
1164 if (size < n)
1165 size = n;
1166 memcpy(c, buf, size);
1167 } else {
1169 }
1170}
1171
1172////////////////////////////////////////////////////////////////////////////////
1173/// Read array of UChar_t from buffer
1174
1179
1180////////////////////////////////////////////////////////////////////////////////
1181/// Read array of Short_t from buffer
1182
1187
1188////////////////////////////////////////////////////////////////////////////////
1189/// Read array of UShort_t from buffer
1190
1195
1196////////////////////////////////////////////////////////////////////////////////
1197/// Read array of Int_t from buffer
1198
1203
1204////////////////////////////////////////////////////////////////////////////////
1205/// Read array of UInt_t from buffer
1206
1211
1212////////////////////////////////////////////////////////////////////////////////
1213/// Read array of Long_t from buffer
1214
1219
1220////////////////////////////////////////////////////////////////////////////////
1221/// Read array of ULong_t from buffer
1222
1227
1228////////////////////////////////////////////////////////////////////////////////
1229/// Read array of Long64_t from buffer
1230
1235
1236////////////////////////////////////////////////////////////////////////////////
1237/// Read array of ULong64_t from buffer
1238
1243
1244////////////////////////////////////////////////////////////////////////////////
1245/// Read array of Float_t from buffer
1246
1251
1252////////////////////////////////////////////////////////////////////////////////
1253/// Read array of n characters from the I/O buffer.
1254/// Used only from TLeafC, dummy implementation here
1255
1260
1261////////////////////////////////////////////////////////////////////////////////
1262/// Read array of Double_t from buffer
1263
1268
1269////////////////////////////////////////////////////////////////////////////////
1270/// Same functionality as TBuffer::ReadFastArray(...) but
1271/// instead of calling cl->Streamer(obj,buf) call here
1272/// buf.StreamObject(obj, cl). In that case it is easy to understand where
1273/// object data is started and finished
1274
1276 const TClass *onFileClass)
1277{
1278 if (gDebug > 2)
1279 Info("ReadFastArray", "(void *");
1280
1281 if (streamer) {
1282 StreamObjectExtra(start, streamer, cl, 0, onFileClass);
1283 // (*streamer)(*this,start,0);
1284 return;
1285 }
1286
1287 int objectSize = cl->Size();
1288 char *obj = (char *)start;
1289 char *end = obj + n * objectSize;
1290
1291 for (; obj < end; obj += objectSize) {
1292 StreamObject(obj, cl, onFileClass);
1293 }
1294 // TBuffer::ReadFastArray(start, cl, n, s);
1295}
1296
1297////////////////////////////////////////////////////////////////////////////////
1298/// Same functionality as TBuffer::ReadFastArray(...) but
1299/// instead of calling cl->Streamer(obj,buf) call here
1300/// buf.StreamObject(obj, cl). In that case it is easy to understand where
1301/// object data is started and finished
1302
1304 const TClass *onFileClass)
1305{
1306 if (gDebug > 2)
1307 Info("ReadFastArray", "(void ** pre = %d n = %d", isPreAlloc, n);
1308
1309 Bool_t oldStyle = kFALSE; // flag used to reproduce old-style I/O actions for kSTLp
1310
1311 if ((fIOVersion < 2) && !isPreAlloc) {
1313 if (elem && ((elem->GetType() == TStreamerInfo::kSTLp) ||
1315 oldStyle = kTRUE;
1316 }
1317
1318 if (streamer) {
1319 if (isPreAlloc) {
1320 for (Int_t j = 0; j < n; j++) {
1321 if (!start[j])
1322 start[j] = ((TClass *)cl)->New();
1323 }
1324 }
1325 if (oldStyle)
1326 (*streamer)(*this, (void *)start, n);
1327 else
1328 StreamObjectExtra((void *)start, streamer, cl, 0, onFileClass);
1329 return;
1330 }
1331
1332 if (!isPreAlloc) {
1333
1334 for (Int_t j = 0; j < n; j++) {
1335 if (oldStyle) {
1336 if (!start[j])
1337 start[j] = ((TClass *)cl)->New();
1338 ((TClass *)cl)->Streamer(start[j], *this);
1339 continue;
1340 }
1341
1342 // delete the object or collection
1343 if (start[j] && TStreamerInfo::CanDelete())
1344 ((TClass *)cl)->Destructor(start[j], kFALSE); // call delete and destructor
1345 start[j] = ReadObjectAny(cl);
1346 }
1347
1348 } else { // case //-> in comment
1349
1350 for (Int_t j = 0; j < n; j++) {
1351 if (!start[j])
1352 start[j] = ((TClass *)cl)->New();
1353 StreamObject(start[j], cl, onFileClass);
1354 }
1355 }
1356
1357 if (gDebug > 2)
1358 Info("ReadFastArray", "(void ** Done");
1359
1360 // TBuffer::ReadFastArray(startp, cl, n, isPreAlloc, s);
1361}
1362
1363////////////////////////////////////////////////////////////////////////////////
1364/// Reads array size, written in raw data table.
1365/// Used in ReadArray methods, where TBuffer need to read array size first.
1366
1368{
1369 const char *value = SqlReadValue(sqlio::Array);
1370 if (!value || (strlen(value) == 0))
1371 return 0;
1372 Int_t sz = atoi(value);
1373 return sz;
1374}
1375
1376template <typename T>
1378{
1379 if (!withsize && (arrsize <= 0))
1380 return;
1381 if (arrsize > std::numeric_limits<Int_t>::max()) {
1382 Fatal("SqlWriteArray", "Array larger than 2^31 elements cannot be stored in SQL");
1383 return; // In case the user re-routes the error handler to not die when Fatal is called
1384 }
1386 Int_t indx = 0;
1387 if (fCompressLevel > 0) {
1388 while (indx < arrsize) {
1389 Int_t curr = indx++;
1390 while ((indx < arrsize) && (arr[indx] == arr[curr]))
1391 indx++;
1394 }
1395 } else {
1396 for (; indx < arrsize; indx++) {
1398 Stack()->ChildArrayIndex(indx, 1);
1399 }
1400 }
1401 PopStack();
1402}
1403
1404////////////////////////////////////////////////////////////////////////////////
1405/// Write array of Bool_t to buffer
1406
1408{
1410}
1411
1412////////////////////////////////////////////////////////////////////////////////
1413/// Write array of Char_t to buffer
1414
1416{
1418}
1419
1420////////////////////////////////////////////////////////////////////////////////
1421/// Write array of UChar_t to buffer
1422
1424{
1426}
1427
1428////////////////////////////////////////////////////////////////////////////////
1429/// Write array of Short_t to buffer
1430
1432{
1434}
1435
1436////////////////////////////////////////////////////////////////////////////////
1437/// Write array of UShort_t to buffer
1438
1440{
1442}
1443
1444////////////////////////////////////////////////////////////////////////////////
1445/// Write array of Int_ to buffer
1446
1448{
1449 SqlWriteArray(i, n, kTRUE);
1450}
1451
1452////////////////////////////////////////////////////////////////////////////////
1453/// Write array of UInt_t to buffer
1454
1456{
1457 SqlWriteArray(i, n, kTRUE);
1458}
1459
1460////////////////////////////////////////////////////////////////////////////////
1461/// Write array of Long_t to buffer
1462
1464{
1466}
1467
1468////////////////////////////////////////////////////////////////////////////////
1469/// Write array of ULong_t to buffer
1470
1472{
1474}
1475
1476////////////////////////////////////////////////////////////////////////////////
1477/// Write array of Long64_t to buffer
1478
1480{
1482}
1483
1484////////////////////////////////////////////////////////////////////////////////
1485/// Write array of ULong64_t to buffer
1486
1488{
1490}
1491
1492////////////////////////////////////////////////////////////////////////////////
1493/// Write array of Float_t to buffer
1494
1496{
1498}
1499
1500////////////////////////////////////////////////////////////////////////////////
1501/// Write array of Double_t to buffer
1502
1504{
1506}
1507
1508////////////////////////////////////////////////////////////////////////////////
1509/// Write array of Bool_t to buffer
1510
1512{
1513 SqlWriteArray(b, n);
1514}
1515
1516////////////////////////////////////////////////////////////////////////////////
1517/// Write array of Char_t to buffer
1518/// it will be reproduced as CharStar node with string as attribute
1519
1521{
1522 Bool_t usedefault = (n == 0);
1523
1524 const Char_t *ccc = c;
1525 // check if no zeros in the array
1526 if (!usedefault)
1527 for (Long64_t i = 0; i < n; i++)
1528 if (*ccc++ == 0) {
1529 usedefault = kTRUE;
1530 break;
1531 }
1532
1533 if (usedefault) {
1534 SqlWriteArray(c, n);
1535 } else {
1536 Char_t *buf = new Char_t[n + 1];
1537 memcpy(buf, c, n);
1538 buf[n] = 0;
1540 delete[] buf;
1541 }
1542}
1543
1544////////////////////////////////////////////////////////////////////////////////
1545/// Write array of UChar_t to buffer
1546
1551
1552////////////////////////////////////////////////////////////////////////////////
1553/// Write array of Short_t to buffer
1554
1559
1560////////////////////////////////////////////////////////////////////////////////
1561/// Write array of UShort_t to buffer
1562
1567
1568////////////////////////////////////////////////////////////////////////////////
1569/// Write array of Int_t to buffer
1570
1572{
1573 SqlWriteArray(i, n);
1574}
1575
1576////////////////////////////////////////////////////////////////////////////////
1577/// Write array of UInt_t to buffer
1578
1580{
1581 SqlWriteArray(i, n);
1582}
1583
1584////////////////////////////////////////////////////////////////////////////////
1585/// Write array of Long_t to buffer
1586
1588{
1589 SqlWriteArray(l, n);
1590}
1591
1592////////////////////////////////////////////////////////////////////////////////
1593/// Write array of ULong_t to buffer
1594
1599
1600////////////////////////////////////////////////////////////////////////////////
1601/// Write array of Long64_t to buffer
1602
1607
1608////////////////////////////////////////////////////////////////////////////////
1609/// Write array of ULong64_t to buffer
1610
1615
1616////////////////////////////////////////////////////////////////////////////////
1617/// Write array of Float_t to buffer
1618
1623
1624////////////////////////////////////////////////////////////////////////////////
1625/// Write array of Double_t to buffer
1626
1631
1632////////////////////////////////////////////////////////////////////////////////
1633/// Write array of n characters into the I/O buffer.
1634/// Used only by TLeafC, just dummy implementation here
1635
1640
1641////////////////////////////////////////////////////////////////////////////////
1642/// Same functionality as TBuffer::WriteFastArray(...) but
1643/// instead of calling cl->Streamer(obj,buf) call here
1644/// buf.StreamObject(obj, cl). In that case it is easy to understand where
1645/// object data is started and finished
1646
1648{
1649 if (streamer) {
1650 StreamObjectExtra(start, streamer, cl, 0);
1651 // (*streamer)(*this, start, 0);
1652 return;
1653 }
1654
1655 char *obj = (char *)start;
1656 if (!n)
1657 n = 1;
1658 int size = cl->Size();
1659
1660 for (Long64_t j = 0; j < n; j++, obj += size)
1661 StreamObject(obj, cl);
1662}
1663
1664////////////////////////////////////////////////////////////////////////////////
1665/// Same functionality as TBuffer::WriteFastArray(...) but
1666/// instead of calling cl->Streamer(obj,buf) call here
1667/// buf.StreamObject(obj, cl). In that case it is easy to understand where
1668/// object data is started and finished
1669
1671{
1672
1673 Bool_t oldStyle = kFALSE; // flag used to reproduce old-style I/O actions for kSTLp
1674
1675 if ((fIOVersion < 2) && !isPreAlloc) {
1677 if (elem && ((elem->GetType() == TStreamerInfo::kSTLp) ||
1679 oldStyle = kTRUE;
1680 }
1681
1682 if (streamer) {
1683 if (oldStyle)
1684 (*streamer)(*this, (void *)start, n);
1685 else
1686 StreamObjectExtra((void *)start, streamer, cl, 0);
1687 return 0;
1688 }
1689
1690 int strInfo = 0;
1691
1692 Int_t res = 0;
1693
1694 if (!isPreAlloc) {
1695
1696 for (Long64_t j = 0; j < n; j++) {
1697 // must write StreamerInfo if pointer is null
1698 if (!strInfo && !start[j] && !oldStyle)
1699 ForceWriteInfo(((TClass *)cl)->GetStreamerInfo(), kFALSE);
1700 strInfo = 2003;
1701 if (oldStyle)
1702 ((TClass *)cl)->Streamer(start[j], *this);
1703 else
1704 res |= WriteObjectAny(start[j], cl);
1705 }
1706
1707 } else {
1708 // case //-> in comment
1709
1710 for (Long64_t j = 0; j < n; j++) {
1711 if (!start[j])
1712 start[j] = ((TClass *)cl)->New();
1713 StreamObject(start[j], cl);
1714 }
1715 }
1716 return res;
1717
1718 // return TBuffer::WriteFastArray(startp, cl, n, isPreAlloc, s);
1719}
1720
1721////////////////////////////////////////////////////////////////////////////////
1722/// Stream object to/from buffer
1723
1724void TBufferSQL2::StreamObject(void *obj, const TClass *cl, const TClass *onFileClass)
1725{
1726 if (fIOVersion < 2) {
1728 if (elem && (elem->GetType() == TStreamerInfo::kTObject)) {
1729 ((TObject *)obj)->TObject::Streamer(*this);
1730 return;
1731 } else if (elem && (elem->GetType() == TStreamerInfo::kTNamed)) {
1732 ((TNamed *)obj)->TNamed::Streamer(*this);
1733 return;
1734 }
1735 }
1736
1737 if (gDebug > 1)
1738 Info("StreamObject", "class %s", (cl ? cl->GetName() : "none"));
1739 if (IsReading())
1740 SqlReadObject(obj, nullptr, nullptr, 0, onFileClass);
1741 else
1742 SqlWriteObject(obj, cl, kTRUE);
1743}
1744
1745////////////////////////////////////////////////////////////////////////////////
1746/// Stream object to/from buffer
1747
1749 const TClass *onFileClass)
1750{
1751 if (!streamer)
1752 return;
1753
1754 if (gDebug > 1)
1755 Info("StreamObjectExtra", "class = %s", cl->GetName());
1756 // (*streamer)(*this, obj, n);
1757
1758 if (IsReading())
1759 SqlReadObject(obj, nullptr, streamer, n, onFileClass);
1760 else
1761 SqlWriteObject(obj, cl, kTRUE, streamer, n);
1762}
1763
1764////////////////////////////////////////////////////////////////////////////////
1765/// Reads Bool_t value from buffer
1766
1768{
1769 SqlReadBasic(b);
1770}
1771
1772////////////////////////////////////////////////////////////////////////////////
1773/// Reads Char_t value from buffer
1774
1776{
1777 SqlReadBasic(c);
1778}
1779
1780////////////////////////////////////////////////////////////////////////////////
1781/// Reads UChar_t value from buffer
1782
1787
1788////////////////////////////////////////////////////////////////////////////////
1789/// Reads Short_t value from buffer
1790
1795
1796////////////////////////////////////////////////////////////////////////////////
1797/// Reads UShort_t value from buffer
1798
1803
1804////////////////////////////////////////////////////////////////////////////////
1805/// Reads Int_t value from buffer
1806
1808{
1809 SqlReadBasic(i);
1810}
1811
1812////////////////////////////////////////////////////////////////////////////////
1813/// Reads UInt_t value from buffer
1814
1816{
1817 SqlReadBasic(i);
1818}
1819
1820////////////////////////////////////////////////////////////////////////////////
1821/// Reads Long_t value from buffer
1822
1824{
1825 SqlReadBasic(l);
1826}
1827
1828////////////////////////////////////////////////////////////////////////////////
1829/// Reads ULong_t value from buffer
1830
1835
1836////////////////////////////////////////////////////////////////////////////////
1837/// Reads Long64_t value from buffer
1838
1843
1844////////////////////////////////////////////////////////////////////////////////
1845/// Reads ULong64_t value from buffer
1846
1851
1852////////////////////////////////////////////////////////////////////////////////
1853/// Reads Float_t value from buffer
1854
1859
1860////////////////////////////////////////////////////////////////////////////////
1861/// Reads Double_t value from buffer
1862
1867
1868////////////////////////////////////////////////////////////////////////////////
1869/// Reads array of characters from buffer
1870
1872{
1873 const char *buf = SqlReadCharStarValue();
1874 if (buf)
1875 strcpy(c, buf); // NOLINT unfortunately, we do not know size of target buffer
1876}
1877
1878////////////////////////////////////////////////////////////////////////////////
1879/// Read a TString
1880
1882{
1883 if (fIOVersion < 2) {
1884 // original TBufferFile method can not be used, while used TString methods are private
1885 // try to reimplement close to the original
1886 Int_t nbig;
1887 UChar_t nwh;
1888 *this >> nwh;
1889 if (nwh == 0) {
1890 s.Resize(0);
1891 } else {
1892 if (nwh == 255)
1893 *this >> nbig;
1894 else
1895 nbig = nwh;
1896
1897 char *data = new char[nbig+1];
1898 data[nbig] = 0;
1900 s = data;
1901 delete[] data;
1902 }
1903 } else {
1904 // TODO: new code - direct reading of string
1905 }
1906}
1907
1908////////////////////////////////////////////////////////////////////////////////
1909/// Write a TString
1910
1912{
1913 if (fIOVersion < 2) {
1914 // original TBufferFile method, keep for compatibility
1915 Int_t nbig = s.Length();
1916 UChar_t nwh;
1917 if (nbig > 254) {
1918 nwh = 255;
1919 *this << nwh;
1920 *this << nbig;
1921 } else {
1922 nwh = UChar_t(nbig);
1923 *this << nwh;
1924 }
1925 const char *data = s.Data();
1927 } else {
1928 // TODO: make writing of string directly
1929 }
1930}
1931
1932////////////////////////////////////////////////////////////////////////////////
1933/// Read a std::string
1934
1935void TBufferSQL2::ReadStdString(std::string *obj)
1936{
1937 if (fIOVersion < 2) {
1938 if (!obj) {
1939 Error("ReadStdString", "The std::string address is nullptr but should not");
1940 return;
1941 }
1942 Int_t nbig;
1943 UChar_t nwh;
1944 *this >> nwh;
1945 if (nwh == 0) {
1946 obj->clear();
1947 } else {
1948 if (obj->size()) {
1949 // Insure that the underlying data storage is not shared
1950 (*obj)[0] = '\0';
1951 }
1952 if (nwh == 255) {
1953 *this >> nbig;
1954 obj->resize(nbig, '\0');
1955 ReadFastArray((char *)obj->data(), nbig);
1956 } else {
1957 obj->resize(nwh, '\0');
1958 ReadFastArray((char *)obj->data(), nwh);
1959 }
1960 }
1961 } else {
1962 // TODO: direct reading of std string
1963 }
1964}
1965
1966////////////////////////////////////////////////////////////////////////////////
1967/// Write a std::string
1968
1969void TBufferSQL2::WriteStdString(const std::string *obj)
1970{
1971 if (fIOVersion < 2) {
1972 if (!obj) {
1973 *this << (UChar_t)0;
1974 WriteFastArray("", 0);
1975 return;
1976 }
1977
1978 UChar_t nwh;
1979 Int_t nbig = obj->length();
1980 if (nbig > 254) {
1981 nwh = 255;
1982 *this << nwh;
1983 *this << nbig;
1984 } else {
1985 nwh = UChar_t(nbig);
1986 *this << nwh;
1987 }
1988 WriteFastArray(obj->data(), nbig);
1989 } else {
1990 // TODO: make writing of string directly
1991 }
1992}
1993
1994////////////////////////////////////////////////////////////////////////////////
1995/// Read a char* string
1996
1998{
1999 delete[] s;
2000 s = nullptr;
2001
2002 Int_t nch;
2003 *this >> nch;
2004 if (nch > 0) {
2005 s = new char[nch + 1];
2006 ReadFastArray(s, nch);
2007 s[nch] = 0;
2008 }
2009}
2010
2011////////////////////////////////////////////////////////////////////////////////
2012/// Write a char* string
2013
2015{
2016 Int_t nch = 0;
2017 if (s) {
2018 nch = strlen(s);
2019 *this << nch;
2020 WriteFastArray(s, nch);
2021 } else {
2022 *this << nch;
2023 }
2024}
2025
2026////////////////////////////////////////////////////////////////////////////////
2027/// Writes Bool_t value to buffer
2028
2033
2034////////////////////////////////////////////////////////////////////////////////
2035/// Writes Char_t value to buffer
2036
2041
2042////////////////////////////////////////////////////////////////////////////////
2043/// Writes UChar_t value to buffer
2044
2049
2050////////////////////////////////////////////////////////////////////////////////
2051/// Writes Short_t value to buffer
2052
2057
2058////////////////////////////////////////////////////////////////////////////////
2059/// Writes UShort_t value to buffer
2060
2065
2066////////////////////////////////////////////////////////////////////////////////
2067/// Writes Int_t value to buffer
2068
2070{
2071 SqlWriteBasic(i);
2072}
2073
2074////////////////////////////////////////////////////////////////////////////////
2075/// Writes UInt_t value to buffer
2076
2078{
2079 SqlWriteBasic(i);
2080}
2081
2082////////////////////////////////////////////////////////////////////////////////
2083/// Writes Long_t value to buffer
2084
2089
2090////////////////////////////////////////////////////////////////////////////////
2091/// Writes ULong_t value to buffer
2092
2097
2098////////////////////////////////////////////////////////////////////////////////
2099/// Writes Long64_t value to buffer
2100
2105
2106////////////////////////////////////////////////////////////////////////////////
2107/// Writes ULong64_t value to buffer
2108
2113
2114////////////////////////////////////////////////////////////////////////////////
2115/// Writes Float_t value to buffer
2116
2121
2122////////////////////////////////////////////////////////////////////////////////
2123/// Writes Double_t value to buffer
2124
2129
2130////////////////////////////////////////////////////////////////////////////////
2131/// Writes array of characters to buffer
2132
2137
2138////////////////////////////////////////////////////////////////////////////////
2139/// converts Char_t to string and creates correspondent sql structure
2140
2142{
2143 char buf[50];
2144 snprintf(buf, sizeof(buf), "%d", value);
2145 return SqlWriteValue(buf, sqlio::Char);
2146}
2147
2148////////////////////////////////////////////////////////////////////////////////
2149/// converts Short_t to string and creates correspondent sql structure
2150
2152{
2153 char buf[50];
2154 snprintf(buf, sizeof(buf), "%hd", value);
2155 return SqlWriteValue(buf, sqlio::Short);
2156}
2157
2158////////////////////////////////////////////////////////////////////////////////
2159/// converts Int_t to string and creates correspondent sql structure
2160
2162{
2163 char buf[50];
2164 snprintf(buf, sizeof(buf), "%d", value);
2165 return SqlWriteValue(buf, sqlio::Int);
2166}
2167
2168////////////////////////////////////////////////////////////////////////////////
2169/// converts Long_t to string and creates correspondent sql structure
2170
2172{
2173 char buf[50];
2174 snprintf(buf, sizeof(buf), "%ld", value);
2175 return SqlWriteValue(buf, sqlio::Long);
2176}
2177
2178////////////////////////////////////////////////////////////////////////////////
2179/// converts Long64_t to string and creates correspondent sql structure
2180
2182{
2183 std::string buf = std::to_string(value);
2184 return SqlWriteValue(buf.c_str(), sqlio::Long64);
2185}
2186
2187////////////////////////////////////////////////////////////////////////////////
2188/// converts Float_t to string and creates correspondent sql structure
2189
2191{
2192 char buf[200];
2193 ConvertFloat(value, buf, sizeof(buf), kTRUE);
2194 return SqlWriteValue(buf, sqlio::Float);
2195}
2196
2197////////////////////////////////////////////////////////////////////////////////
2198/// converts Double_t to string and creates correspondent sql structure
2199
2201{
2202 char buf[200];
2203 ConvertDouble(value, buf, sizeof(buf), kTRUE);
2204 return SqlWriteValue(buf, sqlio::Double);
2205}
2206
2207////////////////////////////////////////////////////////////////////////////////
2208/// converts Bool_t to string and creates correspondent sql structure
2209
2214
2215////////////////////////////////////////////////////////////////////////////////
2216/// converts UChar_t to string and creates correspondent sql structure
2217
2219{
2220 char buf[50];
2221 snprintf(buf, sizeof(buf), "%u", value);
2222 return SqlWriteValue(buf, sqlio::UChar);
2223}
2224
2225////////////////////////////////////////////////////////////////////////////////
2226/// converts UShort_t to string and creates correspondent sql structure
2227
2229{
2230 char buf[50];
2231 snprintf(buf, sizeof(buf), "%hu", value);
2232 return SqlWriteValue(buf, sqlio::UShort);
2233}
2234
2235////////////////////////////////////////////////////////////////////////////////
2236/// converts UInt_t to string and creates correspondent sql structure
2237
2239{
2240 char buf[50];
2241 snprintf(buf, sizeof(buf), "%u", value);
2242 return SqlWriteValue(buf, sqlio::UInt);
2243}
2244
2245////////////////////////////////////////////////////////////////////////////////
2246/// converts ULong_t to string and creates correspondent sql structure
2247
2249{
2250 char buf[50];
2251 snprintf(buf, sizeof(buf), "%lu", value);
2252 return SqlWriteValue(buf, sqlio::ULong);
2253}
2254
2255////////////////////////////////////////////////////////////////////////////////
2256/// converts ULong64_t to string and creates correspondent sql structure
2257
2259{
2260 std::string buf = std::to_string(value);
2261 return SqlWriteValue(buf.c_str(), sqlio::ULong64);
2262}
2263
2264//______________________________________________________________________________
2265
2267{
2268 // create structure in stack, which holds specified value
2269
2271
2272 return kTRUE;
2273}
2274
2275////////////////////////////////////////////////////////////////////////////////
2276/// Read current value from table and convert it to Char_t value
2277
2279{
2280 const char *res = SqlReadValue(sqlio::Char);
2281 if (res) {
2282 int n;
2283 sscanf(res, "%d", &n);
2284 value = n;
2285 } else
2286 value = 0;
2287}
2288
2289////////////////////////////////////////////////////////////////////////////////
2290/// Read current value from table and convert it to Short_t value
2291
2293{
2294 const char *res = SqlReadValue(sqlio::Short);
2295 if (res)
2296 sscanf(res, "%hd", &value);
2297 else
2298 value = 0;
2299}
2300
2301////////////////////////////////////////////////////////////////////////////////
2302/// Read current value from table and convert it to Int_t value
2303
2305{
2306 const char *res = SqlReadValue(sqlio::Int);
2307 if (res)
2308 sscanf(res, "%d", &value);
2309 else
2310 value = 0;
2311}
2312
2313////////////////////////////////////////////////////////////////////////////////
2314/// Read current value from table and convert it to Long_t value
2315
2317{
2318 const char *res = SqlReadValue(sqlio::Long);
2319 if (res)
2320 sscanf(res, "%ld", &value);
2321 else
2322 value = 0;
2323}
2324
2325////////////////////////////////////////////////////////////////////////////////
2326/// Read current value from table and convert it to Long64_t value
2327
2329{
2330 const char *res = SqlReadValue(sqlio::Long64);
2331 if (res)
2332 value = (Long64_t)std::stoll(res);
2333 else
2334 value = 0;
2335}
2336
2337////////////////////////////////////////////////////////////////////////////////
2338/// Read current value from table and convert it to Float_t value
2339
2341{
2342 const char *res = SqlReadValue(sqlio::Float);
2343 if (res)
2344 sscanf(res, "%f", &value);
2345 else
2346 value = 0.;
2347}
2348
2349////////////////////////////////////////////////////////////////////////////////
2350/// Read current value from table and convert it to Double_t value
2351
2353{
2354 const char *res = SqlReadValue(sqlio::Double);
2355 if (res)
2356 sscanf(res, "%lf", &value);
2357 else
2358 value = 0.;
2359}
2360
2361////////////////////////////////////////////////////////////////////////////////
2362/// Read current value from table and convert it to Bool_t value
2363
2365{
2366 const char *res = SqlReadValue(sqlio::Bool);
2367 if (res)
2368 value = (strcmp(res, sqlio::True) == 0);
2369 else
2370 value = kFALSE;
2371}
2372
2373////////////////////////////////////////////////////////////////////////////////
2374/// Read current value from table and convert it to UChar_t value
2375
2377{
2378 const char *res = SqlReadValue(sqlio::UChar);
2379 if (res) {
2380 unsigned int n;
2381 sscanf(res, "%ud", &n);
2382 value = n;
2383 } else
2384 value = 0;
2385}
2386
2387////////////////////////////////////////////////////////////////////////////////
2388/// Read current value from table and convert it to UShort_t value
2389
2391{
2392 const char *res = SqlReadValue(sqlio::UShort);
2393 if (res)
2394 sscanf(res, "%hud", &value);
2395 else
2396 value = 0;
2397}
2398
2399////////////////////////////////////////////////////////////////////////////////
2400/// Read current value from table and convert it to UInt_t value
2401
2403{
2404 const char *res = SqlReadValue(sqlio::UInt);
2405 if (res)
2406 sscanf(res, "%u", &value);
2407 else
2408 value = 0;
2409}
2410
2411////////////////////////////////////////////////////////////////////////////////
2412/// Read current value from table and convert it to ULong_t value
2413
2415{
2416 const char *res = SqlReadValue(sqlio::ULong);
2417 if (res)
2418 sscanf(res, "%lu", &value);
2419 else
2420 value = 0;
2421}
2422
2423////////////////////////////////////////////////////////////////////////////////
2424/// Read current value from table and convert it to ULong64_t value
2425
2427{
2428 const char *res = SqlReadValue(sqlio::ULong64);
2429 if (res)
2430 value = (ULong64_t)std::stoull(res);
2431 else
2432 value = 0;
2433}
2434
2435////////////////////////////////////////////////////////////////////////////////
2436/// Read string value from current stack node
2437
2438const char *TBufferSQL2::SqlReadValue(const char *tname)
2439{
2440 if (fErrorFlag > 0)
2441 return nullptr;
2442
2443 if (!fCurrentData) {
2444 Error("SqlReadValue", "No object data to read from");
2445 fErrorFlag = 1;
2446 return nullptr;
2447 }
2448
2451 fErrorFlag = 1;
2452 return nullptr;
2453 }
2454
2456
2458
2459 if (gDebug > 4)
2460 Info("SqlReadValue", "%s = %s", tname, fReadBuffer.Data());
2461
2462 return fReadBuffer.Data();
2463}
2464
2465////////////////////////////////////////////////////////////////////////////////
2466/// Read CharStar value, if it has special code, request it from large table
2467
2469{
2470 const char *res = SqlReadValue(sqlio::CharStar);
2471 if (!res || !fSQL)
2472 return nullptr;
2473
2474 Long64_t objid = Stack()->DefineObjectId(kTRUE);
2475
2476 Int_t strid = fSQL->IsLongStringCode(objid, res);
2477 if (strid <= 0)
2478 return res;
2479
2481
2482 return fReadBuffer.Data();
2483}
2484
2485////////////////////////////////////////////////////////////////////////////////
2486/// Push stack with structural information about streamed object
2487
2489{
2490 TSQLStructure *res = new TSQLStructure;
2491 if (!fStk) {
2492 fStructure = res;
2493 } else {
2494 fStk->Add(res);
2495 }
2496
2497 fStk = res; // add in the stack
2498 return fStk;
2499}
2500
2501////////////////////////////////////////////////////////////////////////////////
2502/// Pop stack
2503
2505{
2506 if (!fStk)
2507 return nullptr;
2508 fStk = fStk->GetParent();
2509 return fStk;
2510}
2511
2512////////////////////////////////////////////////////////////////////////////////
2513/// returns head of stack
2514
2516{
2518 while ((depth-- > 0) && curr)
2519 curr = curr->GetParent();
2520 return curr;
2521}
2522
2523////////////////////////////////////////////////////////////////////////////////
2524/// Return current streamer info element
2525
#define R__ALWAYS_INLINE
Definition RConfig.hxx:558
#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
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short)
Definition RtypesCore.h:54
short Version_t
Class version identifier (short)
Definition RtypesCore.h:79
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:52
char Char_t
Character 1 byte (char)
Definition RtypesCore.h:51
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:53
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
Definition RtypesCore.h:84
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char mode
char name[80]
Definition TGX11.cxx:110
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:627
#define gROOT
Definition TROOT.h:414
#define snprintf
Definition civetweb.c:1579
void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force) override
force writing the TStreamerInfo to the file
void MapObject(const TObject *obj, UInt_t offset=1) override
Add object to the fMap container.
Long64_t GetObjectTag(const void *obj)
Returns tag for specified object from objects map (if exists) Returns 0 if object not included into o...
void GetMappedObject(UInt_t tag, void *&ptr, TClass *&ClassPtr) const override
Retrieve the object stored in the buffer's object map at 'tag' Set ptr and ClassPtr respectively to t...
Int_t WriteObjectAny(const void *obj, const TClass *ptrClass, Bool_t cacheReuse=kTRUE) override
Write object to I/O buffer.
Long64_t fObjIdCounter
! counter of objects id
Definition TBufferSQL2.h:40
void SetStreamerElementNumber(TStreamerElement *elem, Int_t comp_type) final
Function is called from TStreamerInfo WriteBuffer and Readbuffer functions and add/verify next elemen...
TSQLStructure * PopStack()
Pop stack.
Bool_t SqlObjectInfo(Long64_t objid, TString &clname, Version_t &version)
Returns object info like classname and version Should be taken from buffer, which is produced in the ...
void ClassBegin(const TClass *, Version_t=-1) final
This method inform buffer data of which class now will be streamed.
void StreamObjectExtra(void *obj, TMemberStreamer *streamer, const TClass *cl, Int_t n=0, const TClass *onFileClass=nullptr)
Stream object to/from buffer.
void ReadUShort(UShort_t &s) final
Reads UShort_t value from buffer.
Long64_t fFirstObjId
! id of first object to be read from the database
Definition TBufferSQL2.h:44
Bool_t SqlWriteBasic(Char_t value)
converts Char_t to string and creates correspondent sql structure
void WriteFastArrayString(const Char_t *c, Long64_t n) final
Write array of n characters into the I/O buffer.
TSQLObjectData * fCurrentData
!
Definition TBufferSQL2.h:42
Int_t fErrorFlag
! Error id value
Definition TBufferSQL2.h:37
void WriteShort(Short_t s) final
Writes Short_t value to buffer.
void DecrementLevel(TVirtualStreamerInfo *) final
Function is called from TStreamerInfo WriteBuffer and Readbuffer functions and decrease level in sql ...
void WriteULong64(ULong64_t l) final
Writes ULong64_t value to buffer.
void WriteChar(Char_t c) final
Writes Char_t value to buffer.
void WriteCharStar(char *s) final
Write a char* string.
void WriteCharP(const Char_t *c) final
Writes array of characters to buffer.
void WriteFastArray(const Bool_t *b, Long64_t n) final
Write array of Bool_t to buffer.
Long64_t fLastObjId
! id of last object correspond to this key
Definition TBufferSQL2.h:45
void WriteInt(Int_t i) final
Writes Int_t value to buffer.
TSQLStructure * PushStack()
Push stack with structural information about streamed object.
void * ReadObjectAny(const TClass *clCast) final
Read object from buffer. Only used from TBuffer.
void ReadLong64(Long64_t &l) final
Reads Long64_t value from buffer.
void WriteULong(ULong_t l) final
Writes ULong_t value to buffer.
void WriteUInt(UInt_t i) final
Writes UInt_t value to buffer.
void ReadLong(Long_t &l) final
Reads Long_t value from buffer.
void WriteLong(Long_t l) final
Writes Long_t value to buffer.
Int_t fIOVersion
! I/O version from TSQLFile
Definition TBufferSQL2.h:33
void WriteUShort(UShort_t s) final
Writes UShort_t value to buffer.
TSQLFile * fSQL
! instance of TSQLFile
Definition TBufferSQL2.h:32
Int_t ReadStaticArray(Bool_t *b) final
Read array of Bool_t from buffer.
void WriteStdString(const std::string *s) final
Write a std::string.
Int_t fReadVersionBuffer
! buffer, used to by ReadVersion method
Definition TBufferSQL2.h:39
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 memeber, which should be now streamed in custom streamer ...
void ReadFastArray(Bool_t *b, Int_t n) final
Read array of Bool_t from buffer.
void StreamObject(void *obj, const TClass *cl, const TClass *onFileClass=nullptr) final
Stream object to/from buffer.
Bool_t fIgnoreVerification
! ignore verification of names
Definition TBufferSQL2.h:41
void ReadUChar(UChar_t &c) final
Reads UChar_t value from buffer.
void ReadShort(Short_t &s) final
Reads Short_t value from buffer.
void ReadBool(Bool_t &b) final
Reads Bool_t value from buffer.
R__ALWAYS_INLINE Int_t SqlReadArray(T *&arr, Bool_t is_static=kFALSE)
void ReadTString(TString &s) final
Read a TString.
TBufferSQL2()
Default constructor, should not be used.
R__ALWAYS_INLINE void SqlReadFastArray(T *arr, Int_t arrsize)
Template method to read content of array, which not include size of array.
void ReadFastArrayString(Char_t *c, Int_t n) final
Read array of n characters from the I/O buffer.
TVirtualStreamerInfo * GetInfo() final
Return current streamer info element.
TSQLStructure * fStructure
! structures, created by object storing
Definition TBufferSQL2.h:34
void WriteBool(Bool_t b) final
Writes Bool_t value to buffer.
TClass * ReadClass(const TClass *cl=nullptr, UInt_t *objTag=nullptr) final
Suppressed function of TBuffer.
UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE) final
Copies class version to buffer, but not writes it to sql immidiately Version will be used to produce ...
void ReadCharP(Char_t *c) final
Reads array of characters from buffer.
TMap * fPoolsMap
! map of pools with data from different tables
Definition TBufferSQL2.h:46
TSQLStructure * Stack(Int_t depth=0)
returns head of stack
void ClassEnd(const TClass *) final
Method indicates end of streaming of classdata in custom streamer.
void ReadFloat(Float_t &f) final
Reads Float_t value from buffer.
void SetCompressionLevel(int level)
const char * SqlReadValue(const char *tname)
Read string value from current stack node.
TString fReadBuffer
! Buffer for read value
Definition TBufferSQL2.h:36
TSQLStructure * fStk
! pointer on current active structure (stack head)
Definition TBufferSQL2.h:35
void ReadUInt(UInt_t &i) final
Reads UInt_t value from buffer.
const char * SqlReadCharStarValue()
Read CharStar value, if it has special code, request it from large table.
R__ALWAYS_INLINE void SqlWriteArray(T *arr, Long64_t arrsize, Bool_t withsize=kFALSE)
friend class TSQLStructure
Definition TBufferSQL2.h:29
void WriteClass(const TClass *cl) final
Suppressed function of TBuffer.
Int_t SqlReadArraySize()
Reads array size, written in raw data table.
void * SqlReadObject(void *obj, TClass **cl=nullptr, TMemberStreamer *streamer=nullptr, Int_t streamer_index=0, const TClass *onFileClass=nullptr)
Read object from the buffer.
void WorkWithClass(const char *classname, Version_t classversion)
This function is a part of IncrementLevel method.
void IncrementLevel(TVirtualStreamerInfo *) final
Function is called from TStreamerInfo WriteBuffer and Readbuffer functions and indent new level in da...
Int_t ReadArray(Bool_t *&b) final
Read array of Bool_t from buffer.
void ReadChar(Char_t &c) final
Reads Char_t value from buffer.
Int_t SqlWriteObject(const void *obj, const TClass *objClass, Bool_t cacheReuse, TMemberStreamer *streamer=nullptr, Int_t streamer_index=0)
Write object to buffer.
void WriteArray(const Bool_t *b, Int_t n) final
Write array of Bool_t to buffer.
void ReadStdString(std::string *s) final
Read a std::string.
void ReadDouble(Double_t &d) final
Reads Double_t value from buffer.
void ReadCharStar(char *&s) final
Read a char* string.
void ReadInt(Int_t &i) final
Reads Int_t value from buffer.
void SkipObjectAny() final
?????? Skip any kind of object from buffer !!!!!! fix me, not yet implemented Should be just skip of ...
Bool_t SqlWriteValue(const char *value, const char *tname)
void WriteTString(const TString &s) final
Write a TString.
void * SqlReadObjectDirect(void *obj, TClass **cl, Long64_t objid, TMemberStreamer *streamer=nullptr, Int_t streamer_index=0, const TClass *onFileClass=nullptr)
Read object data.
void WriteFloat(Float_t f) final
Writes Float_t value to buffer.
void WorkWithElement(TStreamerElement *elem, Int_t comp_type)
This function is a part of SetStreamerElementNumber method.
void WriteObjectClass(const void *actualObjStart, const TClass *actualClass, Bool_t cacheReuse) final
Write object to buffer. Only used from TBuffer.
TSQLObjectData * SqlObjectData(Long64_t objid, TSQLClassInfo *sqlinfo)
Creates TSQLObjectData for specified object id and specified class.
TSQLStructure * SqlWriteAny(const void *obj, const TClass *cl, Long64_t objid)
Convert object of any class to sql structures Return pointer on created TSQLStructure TSQLStructure o...
void WriteDouble(Double_t d) final
Writes Double_t value to buffer.
void ReadULong64(ULong64_t &l) final
Reads ULong64_t value from buffer.
void WriteUChar(UChar_t c) final
Writes UChar_t value to buffer.
void * SqlReadAny(Long64_t keyid, Long64_t objid, TClass **cl, void *obj=nullptr)
Recreate object from sql structure.
Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr) final
Read version value from buffer actually version is normally defined by table name and kept in interme...
TObjArray * fObjectsInfos
! array of objects info for selected key
Definition TBufferSQL2.h:43
R__ALWAYS_INLINE void SqlReadArrayContent(T *arr, Int_t arrsize, Bool_t withsize)
Template method to read array content.
~TBufferSQL2() override
Destroy sql buffer.
void WriteLong64(Long64_t l) final
Writes Long64_t value to buffer.
void SqlReadBasic(Char_t &value)
Read current value from table and convert it to Char_t value.
Int_t fCompressLevel
! compress level used to minimize size of data in database
Definition TBufferSQL2.h:38
void ReadULong(ULong_t &l) final
Reads ULong_t value from buffer.
Base class for text-based streamers like TBufferJSON or TBufferXML Special actions list will use meth...
Definition TBufferText.h:20
static const char * ConvertFloat(Float_t v, char *buf, unsigned len, Bool_t not_optimize=kFALSE)
convert float to string with configured format
static const char * ConvertDouble(Double_t v, char *buf, unsigned len, Bool_t not_optimize=kFALSE)
convert float to string with configured format
Bool_t IsReading() const
Definition TBuffer.h:86
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
Int_t Size() const
Return size of object of this class.
Definition TClass.cxx:5743
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Definition TClass.cxx:5980
Version_t GetClassVersion() const
Definition TClass.h:432
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2973
Basic data type descriptor (datatype information is obtained from CINT).
Definition TDataType.h:44
static TClass * Class()
static TClass * Class()
Int_t GetCompressionLevel() const
Definition TFile.h:483
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition TMap.h:40
void Add(TObject *obj) override
This function may not be used (but we need to provide it since it is a pure virtual in TCollection).
Definition TMap.cxx:53
void DeleteValues()
Remove all (key,value) pairs from the map AND delete the values when they are allocated on the heap.
Definition TMap.cxx:150
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Definition TMap.cxx:235
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
TObject * Last() const override
Return the object in the last filled slot. Returns 0 if no entries.
void Delete(Option_t *option="") override
Remove all objects from the array AND delete all heap based objects.
TObject * At(Int_t idx) const override
Definition TObjArray.h:170
Int_t GetLast() const override
Return index of last object in array.
Mother of all ROOT objects.
Definition TObject.h:42
static TClass * Class()
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1089
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1117
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1063
Contains information about tables specific to one class and version.
Access an SQL db via the TFile interface.
Definition TSQLFile.h:30
Int_t GetIOVersion() const
Definition TSQLFile.h:196
Int_t IsLongStringCode(Long64_t objid, const char *value)
Checks if this is long string code returns 0, if not or string id.
TSQLClassInfo * FindSQLClassInfo(const char *clname, Int_t version)
Return (if exists) TSQLClassInfo for specified class name and version.
TObjArray * SQLObjectsInfo(Long64_t keyid)
Produce array of TSQLObjectInfo objects for all objects, belong to that key Array should be deleted b...
TSQLStatement * GetBlobClassDataStmt(Long64_t objid, TSQLClassInfo *sqlinfo)
Method return request results for specified objid from streamer classtable Data returned in form of s...
TSQLResult * GetBlobClassData(Long64_t objid, TSQLClassInfo *sqlinfo)
Method return request results for specified objid from streamer classtable.
TSQLResult * GetNormalClassDataAll(Long64_t minobjid, Long64_t maxobjid, TSQLClassInfo *sqlinfo)
Return data for several objects from the range from normal class table.
Bool_t GetLongString(Long64_t objid, Int_t strid, TString &value)
Returns value of string, extracted from special table, where long strings are stored.
XML object keeper class.
TSQLObjectData is used in TBufferSQL2 class in reading procedure.
const char * GetLocatedField() const
void ShiftToNextValue()
shift to next column or next row in blob data
Bool_t IsBlobData() const
const char * GetValue() const
const char * GetBlobPrefixName() const
Bool_t VerifyDataType(const char *tname, Bool_t errormsg=kTRUE)
checks if data type corresponds to that stored in raw table
Info (classname, version) about object in database.
This is hierarchical structure, which is created when data is written by TBufferSQL2.
TSQLStructure * GetParent() const
Int_t LocateElementColumn(TSQLFile *f, TBufferSQL2 *buf, TSQLObjectData *data)
find column in TSQLObjectData object, which correspond to current element
void Add(TSQLStructure *child)
Add child structure.
void AddVersion(const TClass *cl, Int_t version=-100)
add child as version
void SetObjectPointer(Long64_t ptrid)
set structure type as kSqlPointer
void SetArray(Int_t sz=-1)
Set structure as array element.
TSQLObjectData * GetObjectData(Bool_t search=false)
searches for objects data
TStreamerInfo * GetStreamerInfo() const
return TStreamerInfo* if type is kSqlStreamerInfo
void SetCustomClass(const TClass *cl, Version_t version)
set structure type as kSqlCustomClass
static Bool_t UnpackTString(TSQLFile *f, TBufferSQL2 *buf, TSQLObjectData *data, Long64_t objid, Int_t clversion)
Unpack TString data in form, accepted by custom TString streamer.
void AddValue(const char *value, const char *tname=nullptr)
Add child structure as value.
void SetStreamerInfo(const TStreamerInfo *info)
set structure type as kSqlStreamerInfo
void AddObjectData(TSQLObjectData *objdata)
add element with pointer to object data
Int_t GetType() const
static Bool_t UnpackTObject(TSQLFile *f, TBufferSQL2 *buf, TSQLObjectData *data, Long64_t objid, Int_t clversion)
Unpack TObject data in form, accepted by custom TObject streamer.
void ChangeValueOnly(const char *value)
change value of this structure used as "workaround" to keep object id in kSqlElement node
void Print(Option_t *option="") const override
print content of complete structure
void SetCustomElement(TStreamerElement *elem)
set structure type as kSqlCustomElement
void SetObjectRef(Long64_t refid, const TClass *cl)
set structure type as kSqlObject
Long64_t DefineObjectId(Bool_t recursive=kTRUE)
defines current object id, to which this structure belong make life complicated, because some objects...
TStreamerElement * GetElement() const
return TStremerElement* if type is kSqlElement
void SetStreamerElement(const TStreamerElement *elem, Int_t number)
set structure type as kSqlElement
void ChildArrayIndex(Int_t index, Int_t cnt=1)
set array index for last child element if (cnt<=1) return;
Describe one element (data member) to be Streamed.
Describes a persistent version of a class.
Basic string class.
Definition TString.h:138
Ssiz_t Length() const
Definition TString.h:425
const char * Data() const
Definition TString.h:384
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Definition TString.cxx:1159
static TClass * Class()
Abstract Interface class describing Streamer information for one class.
static Bool_t CanDelete()
static function returning true if ReadBuffer can delete object
const Int_t n
Definition legend1.C:16
const char * Long
const char * ULong
const char * Float
const char * ObjectRef
const char * False
const char * Double
const char * UChar
const char * ObjectPtr
const char * ULong64
const char * IndexSepar
const char * ObjectInst
const char * Version
const char * Short
const char * Int
const char * Long64
const char * UInt
const char * True
const char * Array
const char * UShort
const char * Bool
const char * Char
const char * CharStar
TLine l
Definition textangle.C:4