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
55
56////////////////////////////////////////////////////////////////////////////////
57/// Default constructor, should not be used
58
60 : TBufferText(), fSQL(nullptr), fIOVersion(1), fStructure(nullptr), fStk(nullptr), fReadBuffer(), fErrorFlag(0),
61 fCompressLevel(ROOT::RCompressionSetting::EAlgorithm::kUseGlobal), fReadVersionBuffer(-1), fObjIdCounter(1), fIgnoreVerification(kFALSE),
62 fCurrentData(nullptr), fObjectsInfos(nullptr), fFirstObjId(0), fLastObjId(0), fPoolsMap(nullptr)
63{
64}
65
66////////////////////////////////////////////////////////////////////////////////
67/// Creates buffer object to serialize/deserialize data to/from sql.
68/// This constructor should be used, if data from buffer supposed to be stored in file.
69/// Mode should be either TBuffer::kRead or TBuffer::kWrite.
70
72 : TBufferText(mode, file), fSQL(nullptr), fIOVersion(1), fStructure(nullptr), fStk(nullptr), fReadBuffer(), fErrorFlag(0),
73 fCompressLevel(ROOT::RCompressionSetting::EAlgorithm::kUseGlobal), fReadVersionBuffer(-1), fObjIdCounter(1), fIgnoreVerification(kFALSE),
74 fCurrentData(nullptr), fObjectsInfos(nullptr), fFirstObjId(0), fLastObjId(0), fPoolsMap(nullptr)
75{
76 fSQL = file;
77 if (file) {
79 fIOVersion = file->GetIOVersion();
80 }
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// Destroy sql buffer.
85
87{
88 if (fStructure)
89 delete fStructure;
90
91 if (fObjectsInfos) {
93 delete fObjectsInfos;
94 }
95
96 if (fPoolsMap) {
98 delete fPoolsMap;
99 }
100}
101
102////////////////////////////////////////////////////////////////////////////////
103/// Convert object of any class to sql structures
104/// Return pointer on created TSQLStructure
105/// TSQLStructure object will be owned by TBufferSQL2
106
107TSQLStructure *TBufferSQL2::SqlWriteAny(const void *obj, const TClass *cl, Long64_t objid)
108{
109 fErrorFlag = 0;
110
111 fStructure = nullptr;
112
113 fFirstObjId = objid;
114 fObjIdCounter = objid;
115
116 SqlWriteObject(obj, cl, kTRUE);
117
118 if (gDebug > 3)
119 if (fStructure) {
120 std::cout << "==== Printout of Sql structures ===== " << std::endl;
121 fStructure->Print("*");
122 std::cout << "=========== End printout ============ " << std::endl;
123 }
124
125 return fStructure;
126}
127
128////////////////////////////////////////////////////////////////////////////////
129/// Recreate object from sql structure.
130/// Return pointer to read object.
131/// if (cl!=0) returns pointer to class of object
132
134{
135 if (cl)
136 *cl = nullptr;
137 if (!fSQL)
138 return nullptr;
139
140 fCurrentData = nullptr;
141 fErrorFlag = 0;
142
144
146 fFirstObjId = objid;
147 fLastObjId = objid;
148 if (fObjectsInfos) {
150 if (objinfo)
151 fLastObjId = objinfo->GetObjId();
152 }
153
154 return SqlReadObjectDirect(obj, cl, objid);
155}
156
157////////////////////////////////////////////////////////////////////////////////
158/// Returns object info like classname and version
159/// Should be taken from buffer, which is produced in the beginning
160
162{
163 if ((objid < 0) || !fObjectsInfos)
164 return kFALSE;
165
166 // suppose that objects info are sorted out
167
168 Long64_t shift = objid - fFirstObjId;
169
170 TSQLObjectInfo *info = nullptr;
171 if ((shift >= 0) && (shift <= fObjectsInfos->GetLast())) {
172 info = (TSQLObjectInfo *)fObjectsInfos->At(shift);
173 if (info->GetObjId() != objid)
174 info = nullptr;
175 }
176
177 if (!info) {
178 // I hope, i will never get inside it
179 Info("SqlObjectInfo", "Standard not works %lld", objid);
180 for (Int_t n = 0; n <= fObjectsInfos->GetLast(); n++) {
182 if (info->GetObjId() == objid)
183 break;
184 info = nullptr;
185 }
186 }
187
188 if (!info)
189 return kFALSE;
190
191 clname = info->GetObjClassName();
192 version = info->GetObjVersion();
193 return kTRUE;
194}
195
196////////////////////////////////////////////////////////////////////////////////
197/// Creates TSQLObjectData for specified object id and specified class
198///
199/// Object data for each class can be stored in two different tables.
200/// First table contains data in column-wise form for simple types like integer,
201/// strings and so on when second table contains any other data which cannot
202/// be converted into column-wise representation.
203/// TSQLObjectData will contain results of the requests to both such tables for
204/// concrete object id.
205
207{
208 TSQLResult *classdata = nullptr;
209 TSQLRow *classrow = nullptr;
210
211 if (sqlinfo->IsClassTableExist()) {
212
213 TSQLObjectDataPool *pool = nullptr;
214
215 if (fPoolsMap)
217
218 if (pool && (fLastObjId >= fFirstObjId)) {
219 if (gDebug > 4)
220 Info("SqlObjectData", "Before request to %s", sqlinfo->GetClassTableName());
222 if (gDebug > 4)
223 Info("SqlObjectData", "After request res = 0x%zx", (size_t)alldata);
224 if (!alldata) {
225 Error("SqlObjectData", "Cannot get data from table %s", sqlinfo->GetClassTableName());
226 return nullptr;
227 }
228
229 if (!fPoolsMap)
230 fPoolsMap = new TMap();
233 }
234
235 if (!pool)
236 return nullptr;
237
238 if (pool->GetSqlInfo() != sqlinfo) {
239 Error("SqlObjectData", "Missmatch in pools map !!! CANNOT BE !!!");
240 return nullptr;
241 }
242
243 classdata = pool->GetClassData();
244
245 classrow = pool->GetObjectRow(objid);
246 if (!classrow) {
247 Error("SqlObjectData", "Can not find row for objid = %lld in table %s", objid, sqlinfo->GetClassTableName());
248 return nullptr;
249 }
250 }
251
252 TSQLResult *blobdata = nullptr;
254
255 if (!blobstmt)
257
259}
260
261////////////////////////////////////////////////////////////////////////////////
262/// Write object to buffer.
263/// If object was written before, only pointer will be stored
264/// Return id of saved object
265
268{
269 if (gDebug > 1)
270 Info("SqlWriteObject", "Object: %p Class: %s", obj, (cl ? cl->GetName() : "null"));
271
272 PushStack();
273
274 Long64_t objid = -1;
275
276 if (!cl)
277 obj = nullptr;
278
279 if (!obj) {
280 objid = 0;
281 } else {
283 if (value > 0)
284 objid = fFirstObjId + value - 1;
285 }
286
287 if (gDebug > 1)
288 Info("SqlWriteObject", "Find objectid %ld", (long)objid);
289
290 if (objid >= 0) {
291 Stack()->SetObjectPointer(objid);
292 PopStack();
293 return objid;
294 }
295
296 objid = fObjIdCounter++;
297
298 Stack()->SetObjectRef(objid, cl);
299
300 if (cacheReuse)
301 MapObject(obj, cl, objid - fFirstObjId + 1);
302
303 if (streamer)
304 (*streamer)(*this, (void *)obj, streamer_index);
305 else
306 ((TClass *)cl)->Streamer((void *)obj, *this);
307
308 if (gDebug > 1)
309 Info("SqlWriteObject", "Done write of %s", cl->GetName());
310
311 PopStack();
312
313 return objid;
314}
315
316////////////////////////////////////////////////////////////////////////////////
317/// Read object from the buffer
318
320 const TClass *onFileClass)
321{
322 if (cl)
323 *cl = nullptr;
324
325 if (fErrorFlag > 0)
326 return obj;
327
329
330 const char *refid = fCurrentData->GetValue();
331 if (!refid || (strlen(refid) == 0)) {
332 Error("SqlReadObject", "Invalid object reference value");
333 fErrorFlag = 1;
334 return obj;
335 }
336
337 Long64_t objid = (Long64_t)std::stoll(refid);
338
339 if (gDebug > 2)
340 Info("SqlReadObject", "Starting objid: %ld column: %s", (long)objid, fCurrentData->GetLocatedField());
341
343 if (objid == 0) {
344 obj = nullptr;
345 findptr = kTRUE;
346 } else if (objid == -1) {
347 findptr = kTRUE;
348 } else if (objid >= fFirstObjId) {
349 void *obj1 = nullptr;
350 TClass *cl1 = nullptr;
351 GetMappedObject(objid - fFirstObjId + 1, obj1, cl1);
352 if (obj1 && cl1) {
353 obj = obj1;
354 if (cl)
355 *cl = cl1;
356 }
357 }
358 }
359
360 if ((gDebug > 3) && findptr)
361 Info("SqlReadObject", "Found pointer %p cl %s", obj, ((cl && *cl) ? (*cl)->GetName() : "null"));
362
363 if (findptr) {
365 return obj;
366 }
367
370 Error("SqlReadObject", "Object reference or pointer is not found in blob data");
371 fErrorFlag = 1;
372 return obj;
373 }
374
376
377 if ((gDebug > 2) || (objid < 0))
378 Info("SqlReadObject", "Found object reference %ld", (long)objid);
379
380 return SqlReadObjectDirect(obj, cl, objid, streamer, streamer_index, onFileClass);
381}
382
383////////////////////////////////////////////////////////////////////////////////
384/// Read object data.
385/// Class name and version are taken from special objects table.
386
389{
392
393 if (!SqlObjectInfo(objid, clname, version))
394 return obj;
395
396 if (gDebug > 2)
397 Info("SqlReadObjectDirect", "objid = %lld clname = %s ver = %d", objid, clname.Data(), version);
398
400
404
405 if (!objClass || !sqlinfo) {
406 Error("SqlReadObjectDirect", "Class %s is not known", clname.Data());
407 return obj;
408 }
409
410 if (!obj)
411 obj = objClass->New();
412
413 MapObject(obj, objClass, objid - fFirstObjId + 1);
414
416
418
419 if (sqlinfo->IsClassTableExist()) {
420 // TObject and TString classes treated differently
421 if ((objClass == TObject::Class()) || (objClass == TString::Class())) {
422
424 if (objClass == TObject::Class())
426 else if (objClass == TString::Class())
428
431 } else
432 // before normal streamer first version will be read and
433 // then streamer functions of TStreamerInfo class
435 } else {
437 if (!objdata || !objdata->PrepareForRawData()) {
438 Error("SqlReadObjectDirect", "No found raw data for obj %lld in class %s version %d table", objid,
439 clname.Data(), version);
440 fErrorFlag = 1;
441 return obj;
442 }
443
445
447 }
448
449 if (streamer) {
450 streamer->SetOnFileClass(onFileClass);
451 (*streamer)(*this, (void *)obj, streamer_index);
452 } else {
453 objClass->Streamer((void *)obj, *this, onFileClass);
454 }
455
456 PopStack();
457
458 if (gDebug > 1)
459 Info("SqlReadObjectDirect", "Read object of class %s done", objClass->GetName());
460
461 if (cl)
462 *cl = objClass;
463
465
466 return obj;
467}
468
469////////////////////////////////////////////////////////////////////////////////
470/// Function is called from TStreamerInfo WriteBuffer and Readbuffer functions
471/// and indent new level in data structure.
472/// This call indicates, that TStreamerInfo functions starts streaming
473/// object data of correspondent class
474
476{
477 if (!info)
478 return;
479
481
482 if (gDebug > 2)
483 Info("IncrementLevel", "Info: %s", info->GetName());
484
485 WorkWithClass(info->GetName(), info->GetClassVersion());
486}
487
488////////////////////////////////////////////////////////////////////////////////
489/// Function is called from TStreamerInfo WriteBuffer and Readbuffer functions
490/// and decrease level in sql structure.
491
493{
494 if (Stack()->GetElement())
495 PopStack(); // for element
496 PopStack(); // for streamerinfo
497
498 // restore value of object data
500
501 if (gDebug > 2)
502 Info("DecrementLevel", "Info: %s", info->GetName());
503}
504
505////////////////////////////////////////////////////////////////////////////////
506/// Function is called from TStreamerInfo WriteBuffer and Readbuffer functions
507/// and add/verify next element in sql tables
508/// This calls allows separate data, correspondent to one class member, from another
509
511{
512 if (Stack()->GetElement())
513 PopStack(); // was with if (number > 0), i.e. not first element.
515
516 TStreamerInfo *info = curr->GetStreamerInfo();
517 if (!info) {
518 Error("SetStreamerElementNumber", "Error in structures stack");
519 return;
520 }
521
523}
524
525////////////////////////////////////////////////////////////////////////////////
526/// This method inform buffer data of which class now
527/// will be streamed. When reading, classversion should be specified
528/// as was read by TBuffer::ReadVersion().
529///
530/// ClassBegin(), ClassEnd() & ClassMemeber() should be used in
531/// custom class streamers to specify which kind of data are
532/// now streamed to/from buffer. That information is used to correctly
533/// convert class data to/from "normal" sql tables with meaningfull names
534/// and correct datatypes. Without that functions data from custom streamer
535/// will be saved as "raw" data in special _streamer_ table one value after another
536/// Such MUST be used when object is written with standard ROOT streaming
537/// procedure, but should be read back in custom streamer.
538/// For example, custom streamer of TNamed class may look like:
539
541{
542 // void TNamed::Streamer(TBuffer &b)
543 // UInt_t R__s, R__c;
544 // if (b.IsReading()) {
545 // Version_t R__v = b.ReadVersion(&R__s, &R__c);
546 // b.ClassBegin(TNamed::Class(), R__v);
547 // b.ClassMember("TObject");
548 // TObject::Streamer(b);
549 // b.ClassMember("fName","TString");
550 // fName.Streamer(b);
551 // b.ClassMember("fTitle","TString");
552 // fTitle.Streamer(b);
553 // b.ClassEnd(TNamed::Class());
554 // b.SetBufferOffset(R__s+R__c+sizeof(UInt_t));
555 // } else {
556 // TNamed::Class()->WriteBuffer(b,this);
557 // }
558
559 if (classversion < 0)
561
563
564 if (gDebug > 2)
565 Info("ClassBegin", "Class: %s", cl->GetName());
566
568}
569
570////////////////////////////////////////////////////////////////////////////////
571/// Method indicates end of streaming of classdata in custom streamer.
572/// See ClassBegin() method for more details.
573
575{
576 if (Stack()->GetType() == TSQLStructure::kSqlCustomElement)
577 PopStack(); // for element
578 PopStack(); // for streamerinfo
579
580 // restore value of object data
582
583 if (gDebug > 2)
584 Info("ClassEnd", "Class: %s", cl->GetName());
585}
586
587////////////////////////////////////////////////////////////////////////////////
588/// Method indicates name and typename of class memeber,
589/// which should be now streamed in custom streamer
590/// Following combinations are supported:
591/// see TBufferXML::ClassMember for the details.
592
593void TBufferSQL2::ClassMember(const char *name, const char *typeName, Int_t arrsize1, Int_t arrsize2)
594{
595 if (!typeName)
596 typeName = name;
597
598 if (!name || (strlen(name) == 0)) {
599 Error("ClassMember", "Invalid member name");
600 fErrorFlag = 1;
601 return;
602 }
603
604 TString tname = typeName;
605
606 Int_t typ_id = -1;
607
608 if (strcmp(typeName, "raw:data") == 0)
610
611 if (typ_id < 0) {
612 TDataType *dt = gROOT->GetType(typeName);
613 if (dt)
614 if ((dt->GetType() > 0) && (dt->GetType() < 20))
615 typ_id = dt->GetType();
616 }
617
618 if (typ_id < 0)
619 if (strcmp(name, typeName) == 0) {
620 TClass *cl = TClass::GetClass(tname.Data());
621 if (cl)
623 }
624
625 if (typ_id < 0) {
627 if (tname[tname.Length() - 1] == '*') {
628 tname.Resize(tname.Length() - 1);
629 isptr = kTRUE;
630 }
631 TClass *cl = TClass::GetClass(tname.Data());
632 if (!cl) {
633 Error("ClassMember", "Invalid class specifier %s", typeName);
634 fErrorFlag = 1;
635 return;
636 }
637
638 if (cl->IsTObject())
640 else
642
643 if ((cl == TString::Class()) && !isptr)
645 }
646
647 TStreamerElement *elem = nullptr;
648
650 elem = new TStreamerElement(name, "title", 0, typ_id, "raw:data");
651 } else if (typ_id == TStreamerInfo::kBase) {
652 TClass *cl = TClass::GetClass(tname.Data());
653 if (cl) {
654 TStreamerBase *b = new TStreamerBase(tname.Data(), "title", 0);
655 b->SetBaseVersion(cl->GetClassVersion());
656 elem = b;
657 }
658 } else if ((typ_id > 0) && (typ_id < 20)) {
659 elem = new TStreamerBasicType(name, "title", 0, typ_id, typeName);
662 elem = new TStreamerObject(name, "title", 0, tname.Data());
663 } else if (typ_id == TStreamerInfo::kObjectp) {
664 elem = new TStreamerObjectPointer(name, "title", 0, tname.Data());
665 } else if (typ_id == TStreamerInfo::kAny) {
666 elem = new TStreamerObjectAny(name, "title", 0, tname.Data());
667 } else if (typ_id == TStreamerInfo::kAnyp) {
668 elem = new TStreamerObjectAnyPointer(name, "title", 0, tname.Data());
669 } else if (typ_id == TStreamerInfo::kTString) {
670 elem = new TStreamerString(name, "title", 0);
671 }
672
673 if (!elem) {
674 Error("ClassMember", "Invalid combination name = %s type = %s", name, typeName);
675 fErrorFlag = 1;
676 return;
677 }
678
679 if (arrsize1 > 0) {
680 elem->SetArrayDim(arrsize2 > 0 ? 2 : 1);
681 elem->SetMaxIndex(0, arrsize1);
682 if (arrsize2 > 0)
683 elem->SetMaxIndex(1, arrsize2);
684 }
685
686 // return stack to CustomClass node
688 PopStack();
689
690 // we indicate that there is no streamerinfo
692}
693
694////////////////////////////////////////////////////////////////////////////////
695/// This function is a part of IncrementLevel method.
696/// Also used in StartClass method
697
699{
700 if (IsReading()) {
701 Long64_t objid = 0;
702
703 // if ((fCurrentData!=0) && fCurrentData->VerifyDataType(sqlio::ObjectInst, kFALSE))
704 // if (!fCurrentData->IsBlobData()) Info("WorkWithClass","Big problem %s", fCurrentData->GetValue());
705
707 objid = atoi(fCurrentData->GetValue());
710 sobjid.Form("%lld", objid);
711 Stack()->ChangeValueOnly(sobjid.Data());
712 } else
713 objid = Stack()->DefineObjectId(kTRUE);
714 if (objid < 0) {
715 Error("WorkWithClass", "cannot define object id");
716 fErrorFlag = 1;
717 return;
718 }
719
721 if (!sqlinfo) {
722 Error("WorkWithClass", "Can not find table for class %s version %d", classname, classversion);
723 fErrorFlag = 1;
724 return;
725 }
726
728 if (!objdata) {
729 Error("WorkWithClass", "Request error for data of object %lld for class %s version %d", objid, classname,
731 fErrorFlag = 1;
732 return;
733 }
734
736
738 }
739}
740
741////////////////////////////////////////////////////////////////////////////////
742/// This function is a part of SetStreamerElementNumber method.
743/// It is introduced for reading of data for specified data member of class.
744/// Used also in ReadFastArray methods to resolve problem of compressed data,
745/// when several data members of the same basic type streamed with single ...FastArray call
746
748{
749 if (gDebug > 2)
750 Info("WorkWithElement", "elem = %s", elem->GetName());
751
752 TSQLStructure *stack = Stack(1);
754 Int_t number = info ? info->GetElements()->IndexOf(elem) : -1;
755
756 if (number >= 0)
758 else
760
761 if (IsReading()) {
762
763 if (!fCurrentData) {
764 Error("WorkWithElement", "Object data is lost");
765 fErrorFlag = 1;
766 return;
767 }
768
770
772
774 Error("WorkWithElement", "Cannot locate correct column in the table");
775 fErrorFlag = 1;
776 return;
779 // search again for object data while for BLOB it should be already assign
781 }
782 }
783}
784
785////////////////////////////////////////////////////////////////////////////////
786/// Suppressed function of TBuffer
787
789{
790 return nullptr;
791}
792
793////////////////////////////////////////////////////////////////////////////////
794/// Suppressed function of TBuffer
795
797{
798}
799
800////////////////////////////////////////////////////////////////////////////////
801/// Read version value from buffer
802/// actually version is normally defined by table name
803/// and kept in intermediate variable fReadVersionBuffer
804
806{
807 Version_t res = 0;
808
809 if (start)
810 *start = 0;
811 if (bcnt)
812 *bcnt = 0;
813
814 if (fReadVersionBuffer >= 0) {
815 res = fReadVersionBuffer;
817 if (gDebug > 3)
818 Info("ReadVersion", "from buffer = %d", (int)res);
821 res = value.Atoi();
822 if (gDebug > 3)
823 Info("ReadVersion", "from blob %s = %d", fCurrentData->GetBlobPrefixName(), (int)res);
825 } else {
826 Error("ReadVersion", "No correspondent tags to read version");
827 fErrorFlag = 1;
828 }
829
830 return res;
831}
832
833////////////////////////////////////////////////////////////////////////////////
834/// Copies class version to buffer, but not writes it to sql immidiately
835/// Version will be used to produce complete table
836/// name, which will include class version
837
839{
840 if (gDebug > 2)
841 Info("WriteVersion", "cl:%s ver:%d", (cl ? cl->GetName() : "null"), (int)(cl ? cl->GetClassVersion() : 0));
842
843 if (cl)
844 Stack()->AddVersion(cl);
845
846 return 0;
847}
848
849////////////////////////////////////////////////////////////////////////////////
850/// Read object from buffer. Only used from TBuffer.
851
853{
854 return SqlReadObject(nullptr);
855}
856
857////////////////////////////////////////////////////////////////////////////////
858/// ?????? Skip any kind of object from buffer
859/// !!!!!! fix me, not yet implemented
860/// Should be just skip of current column later
861
865
866////////////////////////////////////////////////////////////////////////////////
867/// Write object to buffer. Only used from TBuffer
868
870{
871 if (gDebug > 2)
872 Info("WriteObjectClass", "class %s", (actualClass ? actualClass->GetName() : " null"));
874}
875
876////////////////////////////////////////////////////////////////////////////////
877/// Template method to read array content
878
879template <typename T>
881{
882 if (gDebug > 3)
883 Info("SqlReadArrayContent", "size %d", (int)(arrsize));
885 Int_t indx(0), first, last;
886 if (fCurrentData->IsBlobData()) {
887 while (indx < arrsize) {
888 const char *name = fCurrentData->GetBlobPrefixName();
890 sscanf(name, "[%d", &first);
891 last = first;
892 } else {
893 sscanf(name, "[%d..%d", &first, &last);
894 }
895 if ((first != indx) || (last < first) || (last >= arrsize)) {
896 Error("SqlReadArrayContent", "Error reading array content %s", name);
897 fErrorFlag = 1;
898 break;
899 }
901 while (indx <= last)
902 arr[indx++] = arr[first];
903 }
904 } else {
905 while (indx < arrsize)
907 }
908 PopStack();
909 if (gDebug > 3)
910 Info("SqlReadArrayContent", "done");
911}
912
913template <typename T>
915{
917 if (n <= 0)
918 return 0;
919 if (!arr) {
920 if (is_static)
921 return 0;
922 arr = new T[n];
923 }
925 return n;
926}
927
928////////////////////////////////////////////////////////////////////////////////
929/// Read array of Bool_t from buffer
930
935
936////////////////////////////////////////////////////////////////////////////////
937/// Read array of Char_t from buffer
938
943
944////////////////////////////////////////////////////////////////////////////////
945/// Read array of UChar_t from buffer
946
951
952////////////////////////////////////////////////////////////////////////////////
953/// Read array of Short_t from buffer
954
959
960////////////////////////////////////////////////////////////////////////////////
961/// Read array of UShort_t from buffer
962
967
968////////////////////////////////////////////////////////////////////////////////
969/// Read array of Int_t from buffer
970
972{
973 return SqlReadArray(i);
974}
975
976////////////////////////////////////////////////////////////////////////////////
977/// Read array of UInt_t from buffer
978
980{
981 return SqlReadArray(i);
982}
983
984////////////////////////////////////////////////////////////////////////////////
985/// Read array of Long_t from buffer
986
991
992////////////////////////////////////////////////////////////////////////////////
993/// Read array of ULong_t from buffer
994
999
1000////////////////////////////////////////////////////////////////////////////////
1001/// Read array of Long64_t from buffer
1002
1007
1008////////////////////////////////////////////////////////////////////////////////
1009/// Read array of ULong64_t from buffer
1010
1015
1016////////////////////////////////////////////////////////////////////////////////
1017/// Read array of Float_t from buffer
1018
1023
1024////////////////////////////////////////////////////////////////////////////////
1025/// Read array of Double_t from buffer
1026
1031
1032////////////////////////////////////////////////////////////////////////////////
1033/// Read array of Bool_t from buffer
1034
1039
1040////////////////////////////////////////////////////////////////////////////////
1041/// Read array of Char_t from buffer
1042
1047
1048////////////////////////////////////////////////////////////////////////////////
1049/// Read array of UChar_t from buffer
1050
1055
1056////////////////////////////////////////////////////////////////////////////////
1057/// Read array of Short_t from buffer
1058
1063
1064////////////////////////////////////////////////////////////////////////////////
1065/// Read array of UShort_t from buffer
1066
1071
1072////////////////////////////////////////////////////////////////////////////////
1073/// Read array of Int_t from buffer
1074
1079
1080////////////////////////////////////////////////////////////////////////////////
1081/// Read array of UInt_t from buffer
1082
1087
1088////////////////////////////////////////////////////////////////////////////////
1089/// Read array of Long_t from buffer
1090
1095
1096////////////////////////////////////////////////////////////////////////////////
1097/// Read array of ULong_t from buffer
1098
1103
1104////////////////////////////////////////////////////////////////////////////////
1105/// Read array of Long64_t from buffer
1106
1111
1112////////////////////////////////////////////////////////////////////////////////
1113/// Read array of ULong64_t from buffer
1114
1119
1120////////////////////////////////////////////////////////////////////////////////
1121/// Read array of Float_t from buffer
1122
1127
1128////////////////////////////////////////////////////////////////////////////////
1129/// Read array of Double_t from buffer
1130
1135
1136////////////////////////////////////////////////////////////////////////////////
1137/// Template method to read content of array, which not include size of array
1138
1139template <typename T>
1145
1146////////////////////////////////////////////////////////////////////////////////
1147/// Read array of Bool_t from buffer
1148
1153
1154////////////////////////////////////////////////////////////////////////////////
1155/// Read array of Char_t from buffer
1156/// if nodename==CharStar, read all array as string
1157
1159{
1161 const char *buf = SqlReadCharStarValue();
1162 if (!buf || (n <= 0))
1163 return;
1164 Int_t size = strlen(buf);
1165 if (size < n)
1166 size = n;
1167 memcpy(c, buf, size);
1168 } else {
1170 }
1171}
1172
1173////////////////////////////////////////////////////////////////////////////////
1174/// Read array of UChar_t from buffer
1175
1180
1181////////////////////////////////////////////////////////////////////////////////
1182/// Read array of Short_t from buffer
1183
1188
1189////////////////////////////////////////////////////////////////////////////////
1190/// Read array of UShort_t from buffer
1191
1196
1197////////////////////////////////////////////////////////////////////////////////
1198/// Read array of Int_t from buffer
1199
1204
1205////////////////////////////////////////////////////////////////////////////////
1206/// Read array of UInt_t from buffer
1207
1212
1213////////////////////////////////////////////////////////////////////////////////
1214/// Read array of Long_t from buffer
1215
1220
1221////////////////////////////////////////////////////////////////////////////////
1222/// Read array of ULong_t from buffer
1223
1228
1229////////////////////////////////////////////////////////////////////////////////
1230/// Read array of Long64_t from buffer
1231
1236
1237////////////////////////////////////////////////////////////////////////////////
1238/// Read array of ULong64_t from buffer
1239
1244
1245////////////////////////////////////////////////////////////////////////////////
1246/// Read array of Float_t from buffer
1247
1252
1253////////////////////////////////////////////////////////////////////////////////
1254/// Read array of n characters from the I/O buffer.
1255/// Used only from TLeafC, dummy implementation here
1256
1261
1262////////////////////////////////////////////////////////////////////////////////
1263/// Read array of Double_t from buffer
1264
1269
1270////////////////////////////////////////////////////////////////////////////////
1271/// Same functionality as TBuffer::ReadFastArray(...) but
1272/// instead of calling cl->Streamer(obj,buf) call here
1273/// buf.StreamObject(obj, cl). In that case it is easy to understand where
1274/// object data is started and finished
1275
1277 const TClass *onFileClass)
1278{
1279 if (gDebug > 2)
1280 Info("ReadFastArray", "(void *");
1281
1282 if (streamer) {
1283 StreamObjectExtra(start, streamer, cl, 0, onFileClass);
1284 // (*streamer)(*this,start,0);
1285 return;
1286 }
1287
1288 int objectSize = cl->Size();
1289 char *obj = (char *)start;
1290 char *end = obj + n * objectSize;
1291
1292 for (; obj < end; obj += objectSize) {
1293 StreamObject(obj, cl, onFileClass);
1294 }
1295 // TBuffer::ReadFastArray(start, cl, n, s);
1296}
1297
1298////////////////////////////////////////////////////////////////////////////////
1299/// Same functionality as TBuffer::ReadFastArray(...) but
1300/// instead of calling cl->Streamer(obj,buf) call here
1301/// buf.StreamObject(obj, cl). In that case it is easy to understand where
1302/// object data is started and finished
1303
1305 const TClass *onFileClass)
1306{
1307 if (gDebug > 2)
1308 Info("ReadFastArray", "(void ** pre = %d n = %d", isPreAlloc, n);
1309
1310 Bool_t oldStyle = kFALSE; // flag used to reproduce old-style I/O actions for kSTLp
1311
1312 if ((fIOVersion < 2) && !isPreAlloc) {
1314 if (elem && ((elem->GetType() == TStreamerInfo::kSTLp) ||
1316 oldStyle = kTRUE;
1317 }
1318
1319 if (streamer) {
1320 if (isPreAlloc) {
1321 for (Int_t j = 0; j < n; j++) {
1322 if (!start[j])
1323 start[j] = ((TClass *)cl)->New();
1324 }
1325 }
1326 if (oldStyle)
1327 (*streamer)(*this, (void *)start, n);
1328 else
1329 StreamObjectExtra((void *)start, streamer, cl, 0, onFileClass);
1330 return;
1331 }
1332
1333 if (!isPreAlloc) {
1334
1335 for (Int_t j = 0; j < n; j++) {
1336 if (oldStyle) {
1337 if (!start[j])
1338 start[j] = ((TClass *)cl)->New();
1339 ((TClass *)cl)->Streamer(start[j], *this);
1340 continue;
1341 }
1342
1343 // delete the object or collection
1344 if (start[j] && TStreamerInfo::CanDelete())
1345 ((TClass *)cl)->Destructor(start[j], kFALSE); // call delete and desctructor
1346 start[j] = ReadObjectAny(cl);
1347 }
1348
1349 } else { // case //-> in comment
1350
1351 for (Int_t j = 0; j < n; j++) {
1352 if (!start[j])
1353 start[j] = ((TClass *)cl)->New();
1354 StreamObject(start[j], cl, onFileClass);
1355 }
1356 }
1357
1358 if (gDebug > 2)
1359 Info("ReadFastArray", "(void ** Done");
1360
1361 // TBuffer::ReadFastArray(startp, cl, n, isPreAlloc, s);
1362}
1363
1364////////////////////////////////////////////////////////////////////////////////
1365/// Reads array size, written in raw data table.
1366/// Used in ReadArray methods, where TBuffer need to read array size first.
1367
1369{
1370 const char *value = SqlReadValue(sqlio::Array);
1371 if (!value || (strlen(value) == 0))
1372 return 0;
1373 Int_t sz = atoi(value);
1374 return sz;
1375}
1376
1377template <typename T>
1379{
1380 constexpr Int_t dataWidth = 1; // at least 1
1381 const Int_t maxElements = (std::numeric_limits<Int_t>::max() - Length())/dataWidth;
1383 {
1384 Fatal("SqlWriteArray", "Not enough space left in the buffer (1GB limit). %lld elements is greater than the max left of %d", arrsize, maxElements);
1385 return; // In case the user re-routes the error handler to not die when Fatal is called
1386 }
1387 if (!withsize && (arrsize <= 0))
1388 return;
1390 Int_t indx = 0;
1391 if (fCompressLevel > 0) {
1392 while (indx < arrsize) {
1393 Int_t curr = indx++;
1394 while ((indx < arrsize) && (arr[indx] == arr[curr]))
1395 indx++;
1398 }
1399 } else {
1400 for (; indx < arrsize; indx++) {
1402 Stack()->ChildArrayIndex(indx, 1);
1403 }
1404 }
1405 PopStack();
1406}
1407
1408////////////////////////////////////////////////////////////////////////////////
1409/// Write array of Bool_t to buffer
1410
1412{
1414}
1415
1416////////////////////////////////////////////////////////////////////////////////
1417/// Write array of Char_t to buffer
1418
1420{
1422}
1423
1424////////////////////////////////////////////////////////////////////////////////
1425/// Write array of UChar_t to buffer
1426
1428{
1430}
1431
1432////////////////////////////////////////////////////////////////////////////////
1433/// Write array of Short_t to buffer
1434
1436{
1438}
1439
1440////////////////////////////////////////////////////////////////////////////////
1441/// Write array of UShort_t to buffer
1442
1444{
1446}
1447
1448////////////////////////////////////////////////////////////////////////////////
1449/// Write array of Int_ to buffer
1450
1452{
1453 SqlWriteArray(i, n, kTRUE);
1454}
1455
1456////////////////////////////////////////////////////////////////////////////////
1457/// Write array of UInt_t to buffer
1458
1460{
1461 SqlWriteArray(i, n, kTRUE);
1462}
1463
1464////////////////////////////////////////////////////////////////////////////////
1465/// Write array of Long_t to buffer
1466
1468{
1470}
1471
1472////////////////////////////////////////////////////////////////////////////////
1473/// Write array of ULong_t to buffer
1474
1476{
1478}
1479
1480////////////////////////////////////////////////////////////////////////////////
1481/// Write array of Long64_t to buffer
1482
1484{
1486}
1487
1488////////////////////////////////////////////////////////////////////////////////
1489/// Write array of ULong64_t to buffer
1490
1492{
1494}
1495
1496////////////////////////////////////////////////////////////////////////////////
1497/// Write array of Float_t to buffer
1498
1500{
1502}
1503
1504////////////////////////////////////////////////////////////////////////////////
1505/// Write array of Double_t to buffer
1506
1508{
1510}
1511
1512////////////////////////////////////////////////////////////////////////////////
1513/// Write array of Bool_t to buffer
1514
1516{
1517 SqlWriteArray(b, n);
1518}
1519
1520////////////////////////////////////////////////////////////////////////////////
1521/// Write array of Char_t to buffer
1522/// it will be reproduced as CharStar node with string as attribute
1523
1525{
1526 Bool_t usedefault = (n == 0);
1527
1528 const Char_t *ccc = c;
1529 // check if no zeros in the array
1530 if (!usedefault)
1531 for (Long64_t i = 0; i < n; i++)
1532 if (*ccc++ == 0) {
1533 usedefault = kTRUE;
1534 break;
1535 }
1536
1537 if (usedefault) {
1538 SqlWriteArray(c, n);
1539 } else {
1540 Char_t *buf = new Char_t[n + 1];
1541 memcpy(buf, c, n);
1542 buf[n] = 0;
1544 delete[] buf;
1545 }
1546}
1547
1548////////////////////////////////////////////////////////////////////////////////
1549/// Write array of UChar_t to buffer
1550
1555
1556////////////////////////////////////////////////////////////////////////////////
1557/// Write array of Short_t to buffer
1558
1563
1564////////////////////////////////////////////////////////////////////////////////
1565/// Write array of UShort_t to buffer
1566
1571
1572////////////////////////////////////////////////////////////////////////////////
1573/// Write array of Int_t to buffer
1574
1576{
1577 SqlWriteArray(i, n);
1578}
1579
1580////////////////////////////////////////////////////////////////////////////////
1581/// Write array of UInt_t to buffer
1582
1584{
1585 SqlWriteArray(i, n);
1586}
1587
1588////////////////////////////////////////////////////////////////////////////////
1589/// Write array of Long_t to buffer
1590
1592{
1593 SqlWriteArray(l, n);
1594}
1595
1596////////////////////////////////////////////////////////////////////////////////
1597/// Write array of ULong_t to buffer
1598
1603
1604////////////////////////////////////////////////////////////////////////////////
1605/// Write array of Long64_t to buffer
1606
1611
1612////////////////////////////////////////////////////////////////////////////////
1613/// Write array of ULong64_t to buffer
1614
1619
1620////////////////////////////////////////////////////////////////////////////////
1621/// Write array of Float_t to buffer
1622
1627
1628////////////////////////////////////////////////////////////////////////////////
1629/// Write array of Double_t to buffer
1630
1635
1636////////////////////////////////////////////////////////////////////////////////
1637/// Write array of n characters into the I/O buffer.
1638/// Used only by TLeafC, just dummy implementation here
1639
1644
1645////////////////////////////////////////////////////////////////////////////////
1646/// Same functionality as TBuffer::WriteFastArray(...) but
1647/// instead of calling cl->Streamer(obj,buf) call here
1648/// buf.StreamObject(obj, cl). In that case it is easy to understand where
1649/// object data is started and finished
1650
1652{
1653 if (streamer) {
1654 StreamObjectExtra(start, streamer, cl, 0);
1655 // (*streamer)(*this, start, 0);
1656 return;
1657 }
1658
1659 char *obj = (char *)start;
1660 if (!n)
1661 n = 1;
1662 int size = cl->Size();
1663
1664 for (Long64_t j = 0; j < n; j++, obj += size)
1665 StreamObject(obj, cl);
1666}
1667
1668////////////////////////////////////////////////////////////////////////////////
1669/// Same functionality as TBuffer::WriteFastArray(...) but
1670/// instead of calling cl->Streamer(obj,buf) call here
1671/// buf.StreamObject(obj, cl). In that case it is easy to understand where
1672/// object data is started and finished
1673
1675{
1676
1677 Bool_t oldStyle = kFALSE; // flag used to reproduce old-style I/O actions for kSTLp
1678
1679 if ((fIOVersion < 2) && !isPreAlloc) {
1681 if (elem && ((elem->GetType() == TStreamerInfo::kSTLp) ||
1683 oldStyle = kTRUE;
1684 }
1685
1686 if (streamer) {
1687 if (oldStyle)
1688 (*streamer)(*this, (void *)start, n);
1689 else
1690 StreamObjectExtra((void *)start, streamer, cl, 0);
1691 return 0;
1692 }
1693
1694 int strInfo = 0;
1695
1696 Int_t res = 0;
1697
1698 if (!isPreAlloc) {
1699
1700 for (Long64_t j = 0; j < n; j++) {
1701 // must write StreamerInfo if pointer is null
1702 if (!strInfo && !start[j] && !oldStyle)
1703 ForceWriteInfo(((TClass *)cl)->GetStreamerInfo(), kFALSE);
1704 strInfo = 2003;
1705 if (oldStyle)
1706 ((TClass *)cl)->Streamer(start[j], *this);
1707 else
1708 res |= WriteObjectAny(start[j], cl);
1709 }
1710
1711 } else {
1712 // case //-> in comment
1713
1714 for (Long64_t j = 0; j < n; j++) {
1715 if (!start[j])
1716 start[j] = ((TClass *)cl)->New();
1717 StreamObject(start[j], cl);
1718 }
1719 }
1720 return res;
1721
1722 // return TBuffer::WriteFastArray(startp, cl, n, isPreAlloc, s);
1723}
1724
1725////////////////////////////////////////////////////////////////////////////////
1726/// Stream object to/from buffer
1727
1728void TBufferSQL2::StreamObject(void *obj, const TClass *cl, const TClass *onFileClass)
1729{
1730 if (fIOVersion < 2) {
1732 if (elem && (elem->GetType() == TStreamerInfo::kTObject)) {
1733 ((TObject *)obj)->TObject::Streamer(*this);
1734 return;
1735 } else if (elem && (elem->GetType() == TStreamerInfo::kTNamed)) {
1736 ((TNamed *)obj)->TNamed::Streamer(*this);
1737 return;
1738 }
1739 }
1740
1741 if (gDebug > 1)
1742 Info("StreamObject", "class %s", (cl ? cl->GetName() : "none"));
1743 if (IsReading())
1744 SqlReadObject(obj, nullptr, nullptr, 0, onFileClass);
1745 else
1746 SqlWriteObject(obj, cl, kTRUE);
1747}
1748
1749////////////////////////////////////////////////////////////////////////////////
1750/// Stream object to/from buffer
1751
1753 const TClass *onFileClass)
1754{
1755 if (!streamer)
1756 return;
1757
1758 if (gDebug > 1)
1759 Info("StreamObjectExtra", "class = %s", cl->GetName());
1760 // (*streamer)(*this, obj, n);
1761
1762 if (IsReading())
1763 SqlReadObject(obj, nullptr, streamer, n, onFileClass);
1764 else
1765 SqlWriteObject(obj, cl, kTRUE, streamer, n);
1766}
1767
1768////////////////////////////////////////////////////////////////////////////////
1769/// Reads Bool_t value from buffer
1770
1772{
1773 SqlReadBasic(b);
1774}
1775
1776////////////////////////////////////////////////////////////////////////////////
1777/// Reads Char_t value from buffer
1778
1780{
1781 SqlReadBasic(c);
1782}
1783
1784////////////////////////////////////////////////////////////////////////////////
1785/// Reads UChar_t value from buffer
1786
1791
1792////////////////////////////////////////////////////////////////////////////////
1793/// Reads Short_t value from buffer
1794
1799
1800////////////////////////////////////////////////////////////////////////////////
1801/// Reads UShort_t value from buffer
1802
1807
1808////////////////////////////////////////////////////////////////////////////////
1809/// Reads Int_t value from buffer
1810
1812{
1813 SqlReadBasic(i);
1814}
1815
1816////////////////////////////////////////////////////////////////////////////////
1817/// Reads UInt_t value from buffer
1818
1820{
1821 SqlReadBasic(i);
1822}
1823
1824////////////////////////////////////////////////////////////////////////////////
1825/// Reads Long_t value from buffer
1826
1828{
1829 SqlReadBasic(l);
1830}
1831
1832////////////////////////////////////////////////////////////////////////////////
1833/// Reads ULong_t value from buffer
1834
1839
1840////////////////////////////////////////////////////////////////////////////////
1841/// Reads Long64_t value from buffer
1842
1847
1848////////////////////////////////////////////////////////////////////////////////
1849/// Reads ULong64_t value from buffer
1850
1855
1856////////////////////////////////////////////////////////////////////////////////
1857/// Reads Float_t value from buffer
1858
1863
1864////////////////////////////////////////////////////////////////////////////////
1865/// Reads Double_t value from buffer
1866
1871
1872////////////////////////////////////////////////////////////////////////////////
1873/// Reads array of characters from buffer
1874
1876{
1877 const char *buf = SqlReadCharStarValue();
1878 if (buf)
1879 strcpy(c, buf); // NOLINT unfortunately, we do not know size of target buffer
1880}
1881
1882////////////////////////////////////////////////////////////////////////////////
1883/// Read a TString
1884
1886{
1887 if (fIOVersion < 2) {
1888 // original TBufferFile method can not be used, while used TString methods are private
1889 // try to reimplement close to the original
1890 Int_t nbig;
1891 UChar_t nwh;
1892 *this >> nwh;
1893 if (nwh == 0) {
1894 s.Resize(0);
1895 } else {
1896 if (nwh == 255)
1897 *this >> nbig;
1898 else
1899 nbig = nwh;
1900
1901 char *data = new char[nbig+1];
1902 data[nbig] = 0;
1904 s = data;
1905 delete[] data;
1906 }
1907 } else {
1908 // TODO: new code - direct reading of string
1909 }
1910}
1911
1912////////////////////////////////////////////////////////////////////////////////
1913/// Write a TString
1914
1916{
1917 if (fIOVersion < 2) {
1918 // original TBufferFile method, keep for compatibility
1919 Int_t nbig = s.Length();
1920 UChar_t nwh;
1921 if (nbig > 254) {
1922 nwh = 255;
1923 *this << nwh;
1924 *this << nbig;
1925 } else {
1926 nwh = UChar_t(nbig);
1927 *this << nwh;
1928 }
1929 const char *data = s.Data();
1931 } else {
1932 // TODO: make writing of string directly
1933 }
1934}
1935
1936////////////////////////////////////////////////////////////////////////////////
1937/// Read a std::string
1938
1939void TBufferSQL2::ReadStdString(std::string *obj)
1940{
1941 if (fIOVersion < 2) {
1942 if (!obj) {
1943 Error("ReadStdString", "The std::string address is nullptr but should not");
1944 return;
1945 }
1946 Int_t nbig;
1947 UChar_t nwh;
1948 *this >> nwh;
1949 if (nwh == 0) {
1950 obj->clear();
1951 } else {
1952 if (obj->size()) {
1953 // Insure that the underlying data storage is not shared
1954 (*obj)[0] = '\0';
1955 }
1956 if (nwh == 255) {
1957 *this >> nbig;
1958 obj->resize(nbig, '\0');
1959 ReadFastArray((char *)obj->data(), nbig);
1960 } else {
1961 obj->resize(nwh, '\0');
1962 ReadFastArray((char *)obj->data(), nwh);
1963 }
1964 }
1965 } else {
1966 // TODO: direct reading of std string
1967 }
1968}
1969
1970////////////////////////////////////////////////////////////////////////////////
1971/// Write a std::string
1972
1973void TBufferSQL2::WriteStdString(const std::string *obj)
1974{
1975 if (fIOVersion < 2) {
1976 if (!obj) {
1977 *this << (UChar_t)0;
1978 WriteFastArray("", 0);
1979 return;
1980 }
1981
1982 UChar_t nwh;
1983 Int_t nbig = obj->length();
1984 if (nbig > 254) {
1985 nwh = 255;
1986 *this << nwh;
1987 *this << nbig;
1988 } else {
1989 nwh = UChar_t(nbig);
1990 *this << nwh;
1991 }
1992 WriteFastArray(obj->data(), nbig);
1993 } else {
1994 // TODO: make writing of string directly
1995 }
1996}
1997
1998////////////////////////////////////////////////////////////////////////////////
1999/// Read a char* string
2000
2002{
2003 delete[] s;
2004 s = nullptr;
2005
2006 Int_t nch;
2007 *this >> nch;
2008 if (nch > 0) {
2009 s = new char[nch + 1];
2010 ReadFastArray(s, nch);
2011 s[nch] = 0;
2012 }
2013}
2014
2015////////////////////////////////////////////////////////////////////////////////
2016/// Write a char* string
2017
2019{
2020 Int_t nch = 0;
2021 if (s) {
2022 nch = strlen(s);
2023 *this << nch;
2024 WriteFastArray(s, nch);
2025 } else {
2026 *this << nch;
2027 }
2028}
2029
2030////////////////////////////////////////////////////////////////////////////////
2031/// Writes Bool_t value to buffer
2032
2037
2038////////////////////////////////////////////////////////////////////////////////
2039/// Writes Char_t value to buffer
2040
2045
2046////////////////////////////////////////////////////////////////////////////////
2047/// Writes UChar_t value to buffer
2048
2053
2054////////////////////////////////////////////////////////////////////////////////
2055/// Writes Short_t value to buffer
2056
2061
2062////////////////////////////////////////////////////////////////////////////////
2063/// Writes UShort_t value to buffer
2064
2069
2070////////////////////////////////////////////////////////////////////////////////
2071/// Writes Int_t value to buffer
2072
2074{
2075 SqlWriteBasic(i);
2076}
2077
2078////////////////////////////////////////////////////////////////////////////////
2079/// Writes UInt_t value to buffer
2080
2082{
2083 SqlWriteBasic(i);
2084}
2085
2086////////////////////////////////////////////////////////////////////////////////
2087/// Writes Long_t value to buffer
2088
2093
2094////////////////////////////////////////////////////////////////////////////////
2095/// Writes ULong_t value to buffer
2096
2101
2102////////////////////////////////////////////////////////////////////////////////
2103/// Writes Long64_t value to buffer
2104
2109
2110////////////////////////////////////////////////////////////////////////////////
2111/// Writes ULong64_t value to buffer
2112
2117
2118////////////////////////////////////////////////////////////////////////////////
2119/// Writes Float_t value to buffer
2120
2125
2126////////////////////////////////////////////////////////////////////////////////
2127/// Writes Double_t value to buffer
2128
2133
2134////////////////////////////////////////////////////////////////////////////////
2135/// Writes array of characters to buffer
2136
2141
2142////////////////////////////////////////////////////////////////////////////////
2143/// converts Char_t to string and creates correspondent sql structure
2144
2146{
2147 char buf[50];
2148 snprintf(buf, sizeof(buf), "%d", value);
2149 return SqlWriteValue(buf, sqlio::Char);
2150}
2151
2152////////////////////////////////////////////////////////////////////////////////
2153/// converts Short_t to string and creates correspondent sql structure
2154
2156{
2157 char buf[50];
2158 snprintf(buf, sizeof(buf), "%hd", value);
2159 return SqlWriteValue(buf, sqlio::Short);
2160}
2161
2162////////////////////////////////////////////////////////////////////////////////
2163/// converts Int_t to string and creates correspondent sql structure
2164
2166{
2167 char buf[50];
2168 snprintf(buf, sizeof(buf), "%d", value);
2169 return SqlWriteValue(buf, sqlio::Int);
2170}
2171
2172////////////////////////////////////////////////////////////////////////////////
2173/// converts Long_t to string and creates correspondent sql structure
2174
2176{
2177 char buf[50];
2178 snprintf(buf, sizeof(buf), "%ld", value);
2179 return SqlWriteValue(buf, sqlio::Long);
2180}
2181
2182////////////////////////////////////////////////////////////////////////////////
2183/// converts Long64_t to string and creates correspondent sql structure
2184
2186{
2187 std::string buf = std::to_string(value);
2188 return SqlWriteValue(buf.c_str(), sqlio::Long64);
2189}
2190
2191////////////////////////////////////////////////////////////////////////////////
2192/// converts Float_t to string and creates correspondent sql structure
2193
2195{
2196 char buf[200];
2197 ConvertFloat(value, buf, sizeof(buf), kTRUE);
2198 return SqlWriteValue(buf, sqlio::Float);
2199}
2200
2201////////////////////////////////////////////////////////////////////////////////
2202/// converts Double_t to string and creates correspondent sql structure
2203
2205{
2206 char buf[200];
2207 ConvertDouble(value, buf, sizeof(buf), kTRUE);
2208 return SqlWriteValue(buf, sqlio::Double);
2209}
2210
2211////////////////////////////////////////////////////////////////////////////////
2212/// converts Bool_t to string and creates correspondent sql structure
2213
2218
2219////////////////////////////////////////////////////////////////////////////////
2220/// converts UChar_t to string and creates correspondent sql structure
2221
2223{
2224 char buf[50];
2225 snprintf(buf, sizeof(buf), "%u", value);
2226 return SqlWriteValue(buf, sqlio::UChar);
2227}
2228
2229////////////////////////////////////////////////////////////////////////////////
2230/// converts UShort_t to string and creates correspondent sql structure
2231
2233{
2234 char buf[50];
2235 snprintf(buf, sizeof(buf), "%hu", value);
2236 return SqlWriteValue(buf, sqlio::UShort);
2237}
2238
2239////////////////////////////////////////////////////////////////////////////////
2240/// converts UInt_t to string and creates correspondent sql structure
2241
2243{
2244 char buf[50];
2245 snprintf(buf, sizeof(buf), "%u", value);
2246 return SqlWriteValue(buf, sqlio::UInt);
2247}
2248
2249////////////////////////////////////////////////////////////////////////////////
2250/// converts ULong_t to string and creates correspondent sql structure
2251
2253{
2254 char buf[50];
2255 snprintf(buf, sizeof(buf), "%lu", value);
2256 return SqlWriteValue(buf, sqlio::ULong);
2257}
2258
2259////////////////////////////////////////////////////////////////////////////////
2260/// converts ULong64_t to string and creates correspondent sql structure
2261
2263{
2264 std::string buf = std::to_string(value);
2265 return SqlWriteValue(buf.c_str(), sqlio::ULong64);
2266}
2267
2268//______________________________________________________________________________
2269
2271{
2272 // create structure in stack, which holds specified value
2273
2275
2276 return kTRUE;
2277}
2278
2279////////////////////////////////////////////////////////////////////////////////
2280/// Read current value from table and convert it to Char_t value
2281
2283{
2284 const char *res = SqlReadValue(sqlio::Char);
2285 if (res) {
2286 int n;
2287 sscanf(res, "%d", &n);
2288 value = n;
2289 } else
2290 value = 0;
2291}
2292
2293////////////////////////////////////////////////////////////////////////////////
2294/// Read current value from table and convert it to Short_t value
2295
2297{
2298 const char *res = SqlReadValue(sqlio::Short);
2299 if (res)
2300 sscanf(res, "%hd", &value);
2301 else
2302 value = 0;
2303}
2304
2305////////////////////////////////////////////////////////////////////////////////
2306/// Read current value from table and convert it to Int_t value
2307
2309{
2310 const char *res = SqlReadValue(sqlio::Int);
2311 if (res)
2312 sscanf(res, "%d", &value);
2313 else
2314 value = 0;
2315}
2316
2317////////////////////////////////////////////////////////////////////////////////
2318/// Read current value from table and convert it to Long_t value
2319
2321{
2322 const char *res = SqlReadValue(sqlio::Long);
2323 if (res)
2324 sscanf(res, "%ld", &value);
2325 else
2326 value = 0;
2327}
2328
2329////////////////////////////////////////////////////////////////////////////////
2330/// Read current value from table and convert it to Long64_t value
2331
2333{
2334 const char *res = SqlReadValue(sqlio::Long64);
2335 if (res)
2336 value = (Long64_t)std::stoll(res);
2337 else
2338 value = 0;
2339}
2340
2341////////////////////////////////////////////////////////////////////////////////
2342/// Read current value from table and convert it to Float_t value
2343
2345{
2346 const char *res = SqlReadValue(sqlio::Float);
2347 if (res)
2348 sscanf(res, "%f", &value);
2349 else
2350 value = 0.;
2351}
2352
2353////////////////////////////////////////////////////////////////////////////////
2354/// Read current value from table and convert it to Double_t value
2355
2357{
2358 const char *res = SqlReadValue(sqlio::Double);
2359 if (res)
2360 sscanf(res, "%lf", &value);
2361 else
2362 value = 0.;
2363}
2364
2365////////////////////////////////////////////////////////////////////////////////
2366/// Read current value from table and convert it to Bool_t value
2367
2369{
2370 const char *res = SqlReadValue(sqlio::Bool);
2371 if (res)
2372 value = (strcmp(res, sqlio::True) == 0);
2373 else
2374 value = kFALSE;
2375}
2376
2377////////////////////////////////////////////////////////////////////////////////
2378/// Read current value from table and convert it to UChar_t value
2379
2381{
2382 const char *res = SqlReadValue(sqlio::UChar);
2383 if (res) {
2384 unsigned int n;
2385 sscanf(res, "%ud", &n);
2386 value = n;
2387 } else
2388 value = 0;
2389}
2390
2391////////////////////////////////////////////////////////////////////////////////
2392/// Read current value from table and convert it to UShort_t value
2393
2395{
2396 const char *res = SqlReadValue(sqlio::UShort);
2397 if (res)
2398 sscanf(res, "%hud", &value);
2399 else
2400 value = 0;
2401}
2402
2403////////////////////////////////////////////////////////////////////////////////
2404/// Read current value from table and convert it to UInt_t value
2405
2407{
2408 const char *res = SqlReadValue(sqlio::UInt);
2409 if (res)
2410 sscanf(res, "%u", &value);
2411 else
2412 value = 0;
2413}
2414
2415////////////////////////////////////////////////////////////////////////////////
2416/// Read current value from table and convert it to ULong_t value
2417
2419{
2420 const char *res = SqlReadValue(sqlio::ULong);
2421 if (res)
2422 sscanf(res, "%lu", &value);
2423 else
2424 value = 0;
2425}
2426
2427////////////////////////////////////////////////////////////////////////////////
2428/// Read current value from table and convert it to ULong64_t value
2429
2431{
2432 const char *res = SqlReadValue(sqlio::ULong64);
2433 if (res)
2434 value = (ULong64_t)std::stoull(res);
2435 else
2436 value = 0;
2437}
2438
2439////////////////////////////////////////////////////////////////////////////////
2440/// Read string value from current stack node
2441
2442const char *TBufferSQL2::SqlReadValue(const char *tname)
2443{
2444 if (fErrorFlag > 0)
2445 return nullptr;
2446
2447 if (!fCurrentData) {
2448 Error("SqlReadValue", "No object data to read from");
2449 fErrorFlag = 1;
2450 return nullptr;
2451 }
2452
2455 fErrorFlag = 1;
2456 return nullptr;
2457 }
2458
2460
2462
2463 if (gDebug > 4)
2464 Info("SqlReadValue", "%s = %s", tname, fReadBuffer.Data());
2465
2466 return fReadBuffer.Data();
2467}
2468
2469////////////////////////////////////////////////////////////////////////////////
2470/// Read CharStar value, if it has special code, request it from large table
2471
2473{
2474 const char *res = SqlReadValue(sqlio::CharStar);
2475 if (!res || !fSQL)
2476 return nullptr;
2477
2478 Long64_t objid = Stack()->DefineObjectId(kTRUE);
2479
2480 Int_t strid = fSQL->IsLongStringCode(objid, res);
2481 if (strid <= 0)
2482 return res;
2483
2485
2486 return fReadBuffer.Data();
2487}
2488
2489////////////////////////////////////////////////////////////////////////////////
2490/// Push stack with structural information about streamed object
2491
2493{
2494 TSQLStructure *res = new TSQLStructure;
2495 if (!fStk) {
2496 fStructure = res;
2497 } else {
2498 fStk->Add(res);
2499 }
2500
2501 fStk = res; // add in the stack
2502 return fStk;
2503}
2504
2505////////////////////////////////////////////////////////////////////////////////
2506/// Pop stack
2507
2509{
2510 if (!fStk)
2511 return nullptr;
2512 fStk = fStk->GetParent();
2513 return fStk;
2514}
2515
2516////////////////////////////////////////////////////////////////////////////////
2517/// returns head of stack
2518
2520{
2522 while ((depth-- > 0) && curr)
2523 curr = curr->GetParent();
2524 return curr;
2525}
2526
2527////////////////////////////////////////////////////////////////////////////////
2528/// Return current streamer info element
2529
#define R__ALWAYS_INLINE
Definition RConfig.hxx:560
#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
#define ClassImp(name)
Definition Rtypes.h:376
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:411
#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.
Converts data to SQL statements or read data from SQL tables.
Definition TBufferSQL2.h:27
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
Int_t Length() const
Definition TBuffer.h:100
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:5744
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Definition TClass.cxx:5981
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:2974
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:474
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:54
void DeleteValues()
Remove all (key,value) pairs from the map AND delete the values when they are allocated on the heap.
Definition TMap.cxx:151
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Definition TMap.cxx:236
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:164
Int_t GetLast() const override
Return index of last object in array.
Mother of all ROOT objects.
Definition TObject.h:41
static TClass * Class()
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1072
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1100
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1046
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:1160
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
Namespace for new ROOT classes and functions.
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