Logo ROOT   6.10/09
Reference Guide
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 
16 Converts data to SQL statements or read data from SQL tables.
17 
18 Class for serializing/deserializing object to/from SQL data base.
19 It redefines most of TBuffer class function to convert simple types,
20 array of simple types and objects to/from TSQLStructure objects.
21 TBufferSQL2 class uses streaming mechanism, provided by ROOT system,
22 therefore most of ROOT and user classes can be stored. There are
23 limitations for complex objects like TTree, TClonesArray, TDirectory and
24 few other, which can not be converted to SQL (yet).
25 */
26 
27 #include "TBufferSQL2.h"
28 
29 #include "TObjArray.h"
30 #include "TROOT.h"
31 #include "TDataType.h"
32 #include "TClass.h"
33 #include "TClassTable.h"
34 #include "TMap.h"
35 #include "TExMap.h"
36 #include "TMethodCall.h"
37 #include "TStreamerInfo.h"
38 #include "TStreamerElement.h"
39 #include "TProcessID.h"
40 #include "TFile.h"
41 #include "TMemberStreamer.h"
42 #include "TStreamer.h"
43 #include "Riostream.h"
44 #include <stdlib.h>
45 #include "TStreamerInfoActions.h"
46 
47 #include "TSQLServer.h"
48 #include "TSQLResult.h"
49 #include "TSQLRow.h"
50 #include "TSQLStructure.h"
51 #include "TSQLObjectData.h"
52 #include "TSQLFile.h"
53 #include "TSQLClassInfo.h"
54 
55 #ifdef R__VISUAL_CPLUSPLUS
56 #define FLong64 "%I64d"
57 #define FULong64 "%I64u"
58 #else
59 #define FLong64 "%lld"
60 #define FULong64 "%llu"
61 #endif
62 
64 
65 ////////////////////////////////////////////////////////////////////////////////
66 /// Default constructor, should not be used
67 
69  TBufferFile(),
70  fSQL(0),
71  fStructure(0),
72  fStk(0),
73  fObjMap(0),
74  fReadBuffer(),
75  fErrorFlag(0),
76  fExpectedChain(kFALSE),
77  fCompressLevel(0),
78  fReadVersionBuffer(-1),
79  fObjIdCounter(1),
80  fIgnoreVerification(kFALSE),
81  fCurrentData(0),
82  fObjectsInfos(0),
83  fFirstObjId(0),
84  fLastObjId(0),
85  fPoolsMap(0)
86 {
87 }
88 
89 ////////////////////////////////////////////////////////////////////////////////
90 /// Creates buffer object to serailize/deserialize data to/from sql.
91 /// Mode should be either TBuffer::kRead or TBuffer::kWrite.
92 
94  TBufferFile(mode),
95  fSQL(0),
96  fStructure(0),
97  fStk(0),
98  fObjMap(0),
99  fReadBuffer(),
100  fErrorFlag(0),
102  fCompressLevel(0),
103  fReadVersionBuffer(-1),
104  fObjIdCounter(1),
106  fCurrentData(0),
107  fObjectsInfos(0),
108  fFirstObjId(0),
109  fLastObjId(0),
110  fPoolsMap(0)
111 {
112  SetParent(0);
115 }
116 
117 ////////////////////////////////////////////////////////////////////////////////
118 /// Creates buffer object to serailize/deserialize data to/from sql.
119 /// This constructor should be used, if data from buffer supposed to be stored in file.
120 /// Mode should be either TBuffer::kRead or TBuffer::kWrite.
121 
123  TBufferFile(mode),
124  fSQL(0),
125  fStructure(0),
126  fStk(0),
127  fObjMap(0),
128  fReadBuffer(),
129  fErrorFlag(0),
131  fCompressLevel(0),
132  fReadVersionBuffer(-1),
133  fObjIdCounter(1),
135  fCurrentData(0),
136  fObjectsInfos(0),
137  fFirstObjId(0),
138  fLastObjId(0),
139  fPoolsMap(0)
140 {
141  fBufSize = 1000000000;
142 
143  // for TClonesArray recognize if this is special case
146 
147  SetParent(file);
148  fSQL = file;
149  if (file!=0)
151 }
152 
153 ////////////////////////////////////////////////////////////////////////////////
154 /// Destroy sql buffer.
155 
157 {
158  if (fObjMap) delete fObjMap;
159 
160  if (fStructure!=0) {
161  delete fStructure;
162  fStructure = 0;
163  }
164 
165  if (fObjectsInfos!=0) {
167  delete fObjectsInfos;
168  }
169 
170  if (fPoolsMap!=0) {
172  delete fPoolsMap;
173  }
174 }
175 
176 ////////////////////////////////////////////////////////////////////////////////
177 /// Convert object of any class to sql structures
178 /// Return pointer on created TSQLStructure
179 /// TSQLStructure object will be owned by TBufferSQL2
180 
181 TSQLStructure* TBufferSQL2::SqlWriteAny(const void* obj, const TClass* cl, Long64_t objid)
182 {
183  fErrorFlag = 0;
184 
185  fStructure = 0;
186 
187  fFirstObjId = objid;
188  fObjIdCounter = objid;
189 
190  SqlWriteObject(obj, cl);
191 
192  if (gDebug>3)
193  if (fStructure!=0) {
194  std::cout << "==== Printout of Sql structures ===== " << std::endl;
195  fStructure->Print("*");
196  std::cout << "=========== End printout ============ " << std::endl;
197  }
198 
199  return fStructure;
200 }
201 
202 ////////////////////////////////////////////////////////////////////////////////
203 /// Recreate object from sql structure.
204 /// Return pointer to read object.
205 /// if (cl!=0) returns pointer to class of object
206 
207 void* TBufferSQL2::SqlReadAny(Long64_t keyid, Long64_t objid, TClass** cl, void* obj)
208 {
209  if (cl) *cl = 0;
210  if (fSQL==0) return 0;
211 
212  fCurrentData = 0;
213  fErrorFlag = 0;
214 
215  fReadVersionBuffer = -1;
216 
218 // fObjectsInfos = 0;
219  fFirstObjId = objid;
220  fLastObjId = objid;
221  if (fObjectsInfos!=0) {
223  if (objinfo!=0) fLastObjId = objinfo->GetObjId();
224  }
225 
226  return SqlReadObjectDirect(obj, cl, objid);
227 }
228 
229 ////////////////////////////////////////////////////////////////////////////////
230 /// Returns object info like classname and version
231 /// Should be taken from buffer, which is produced in the begginnig
232 
234 {
235  if ((objid<0) || (fObjectsInfos==0)) return kFALSE;
236 
237  // if (fObjectsInfos==0) return fSQL->SQLObjectInfo(objid, clname, version);
238 
239  // suppose that objects info are sorted out
240 
241  Long64_t shift = objid - fFirstObjId;
242 
243  TSQLObjectInfo* info = 0;
244  if ((shift>=0) && (shift<=fObjectsInfos->GetLast())) {
245  info = (TSQLObjectInfo*) fObjectsInfos->At(shift);
246  if (info->GetObjId()!=objid) info = 0;
247  }
248 
249  if (info==0) {
250  // I hope, i will never get inside it
251  Info("SqlObjectInfo", "Standard not works %lld", objid);
252  for (Int_t n=0;n<=fObjectsInfos->GetLast();n++) {
253  info = (TSQLObjectInfo*) fObjectsInfos->At(n);
254  if (info->GetObjId()==objid) break;
255  info = 0;
256  }
257  }
258 
259  if (info==0) return kFALSE;
260 
261  clname = info->GetObjClassName();
262  version = info->GetObjVersion();
263  return kTRUE;
264 }
265 
266 
267 ////////////////////////////////////////////////////////////////////////////////
268 /// Creates TSQLObjectData for specifed object id and specified class
269 ///
270 /// Object data for each class can be stored in two different tables.
271 /// First table contains data in column-wise form for simple types like integer,
272 /// strings and so on when second table contains any other data which cannot
273 /// be converted into column-wise representation.
274 /// TSQLObjectData will contain results of the requests to both such tables for
275 /// concrete object id.
276 
278 {
279  TSQLResult *classdata = 0;
280  TSQLRow *classrow = 0;
281 
282  if (sqlinfo->IsClassTableExist()) {
283 
284  TSQLObjectDataPool* pool = 0;
285 
286  if (fPoolsMap!=0)
287  pool = (TSQLObjectDataPool*) fPoolsMap->GetValue(sqlinfo);
288 
289  if ((pool==0) && (fLastObjId>=fFirstObjId)) {
290  if (gDebug>4) Info("SqlObjectData","Before request to %s",sqlinfo->GetClassTableName());
292  if (gDebug>4) Info("SqlObjectData","After request res = 0x%lx",(Long_t)alldata);
293  if (alldata==0) {
294  Error("SqlObjectData","Cannot get data from table %s",sqlinfo->GetClassTableName());
295  return 0;
296  }
297 
298  if (fPoolsMap==0) fPoolsMap = new TMap();
299  pool = new TSQLObjectDataPool(sqlinfo, alldata);
300  fPoolsMap->Add(sqlinfo, pool);
301  }
302 
303  if (pool==0) return 0;
304 
305  if (pool->GetSqlInfo()!=sqlinfo) {
306  Error("SqlObjectData","Missmatch in pools map !!! CANNOT BE !!!");
307  return 0;
308  }
309 
310  classdata = pool->GetClassData();
311 
312  classrow = pool->GetObjectRow(objid);
313  if (classrow==0) {
314  Error("SqlObjectData","Can not find row for objid = %lld in table %s", objid, sqlinfo->GetClassTableName());
315  return 0;
316  }
317  }
318 
319  TSQLResult *blobdata = 0;
320  TSQLStatement* blobstmt = fSQL->GetBlobClassDataStmt(objid, sqlinfo);
321 
322  if (blobstmt==0) blobdata = fSQL->GetBlobClassData(objid, sqlinfo);
323 
324  return new TSQLObjectData(sqlinfo, objid, classdata, classrow, blobdata, blobstmt);
325 }
326 
327 ////////////////////////////////////////////////////////////////////////////////
328 /// Convert object into sql structures.
329 /// <b>It should be used only by TBufferSQL2 itself</b>
330 /// Use SqlWrite() functions to convert your object to sql
331 /// Redefined here to avoid gcc 3.x warning
332 
334 {
336 }
337 
338 ////////////////////////////////////////////////////////////////////////////////
339 /// Write object to buffer.
340 /// If object was written before, only pointer will be stored
341 /// Return id of saved object
342 
343 Int_t TBufferSQL2::SqlWriteObject(const void* obj, const TClass* cl, TMemberStreamer *streamer, Int_t streamer_index)
344 {
345  if (gDebug>1)
346  std::cout << " SqlWriteObject " << obj << " : cl = " << (cl ? cl->GetName() : "null") << std::endl;
347 
348  PushStack();
349 
350  Long64_t objid = -1;
351 
352  if (cl==0) obj = 0;
353 
354  if (obj==0)
355  objid = 0;
356  else
357  if (fObjMap!=0) {
358  ULong_t hash = TString::Hash(&obj, sizeof(void*));
359  Long_t value = fObjMap->GetValue(hash, (Long_t) obj);
360  if (value>0)
361  objid = fFirstObjId + value - 1;
362  }
363 
364  if (gDebug>1)
365  std::cout << " Find objectid = " << objid << std::endl;
366 
367  if (objid>=0) {
368  Stack()->SetObjectPointer(objid);
369  PopStack();
370  return objid;
371  }
372 
373  objid = fObjIdCounter++;
374 
375  Stack()->SetObjectRef(objid, cl);
376 
377  ULong_t hash = TString::Hash(&obj, sizeof(void*));
378  if (fObjMap==0) fObjMap = new TExMap();
379  if (fObjMap->GetValue(hash, (Long_t) obj)==0)
380  fObjMap->Add(hash, (Long_t) obj, (Long_t) objid - fFirstObjId + 1);
381 
382  if (streamer!=0)
383  (*streamer)(*this, (void*) obj, streamer_index);
384  else
385  ((TClass*)cl)->Streamer((void*)obj, *this);
386 
387  if (gDebug>1)
388  std::cout << "Done write of " << cl->GetName() << std::endl;
389 
390  PopStack();
391 
392  return objid;
393 }
394 
395 ////////////////////////////////////////////////////////////////////////////////
396 /// Read object from the buffer
397 
398 void* TBufferSQL2::SqlReadObject(void* obj, TClass** cl, TMemberStreamer *streamer, Int_t streamer_index, const TClass *onFileClass)
399 {
400  if (cl) *cl = 0;
401 
402  if (fErrorFlag>0) return obj;
403 
404  Bool_t findptr = kFALSE;
405 
406  const char* refid = fCurrentData->GetValue();
407  if ((refid==0) || (strlen(refid)==0)) {
408  Error("SqlReadObject","Invalid object reference value");
409  fErrorFlag = 1;
410  return obj;
411  }
412 
413  Long64_t objid = -1;
414  sscanf(refid, FLong64, &objid);
415 
416  if (gDebug>2)
417  Info("SqlReadObject","Starting objid = %lld column=%s", objid, fCurrentData->GetLocatedField());
418 
419  if (!fCurrentData->IsBlobData() ||
421  if (objid==0) {
422  obj = 0;
423  findptr = kTRUE;
424  } else {
425  if (objid==-1) {
426  findptr = kTRUE;
427  } else {
428  if ((fObjMap!=0) && (objid>=fFirstObjId)) {
429  void* obj1 = (void*) (Long_t)fObjMap->GetValue((Long_t) objid - fFirstObjId);
430  if (obj1!=0) {
431  obj = obj1;
432  findptr = kTRUE;
433  TString clname;
434  Version_t version;
435  if ((cl!=0) && SqlObjectInfo(objid, clname, version))
436  *cl = TClass::GetClass(clname);
437  }
438  }
439  }
440  }
441  }
442 
443  if ((gDebug>3) && findptr)
444  std::cout << " Found pointer " << (obj ? obj : 0)
445  << " class = " << ((cl && *cl) ? (*cl)->GetName() : "null") << std::endl;
446 
447  if (findptr) {
449  return obj;
450  }
451 
452  if (fCurrentData->IsBlobData())
454  Error("SqlReadObject","Object reference or pointer is not found in blob data");
455  fErrorFlag = 1;
456  return obj;
457  }
458 
460 
461  if ((gDebug>2) || (objid<0))
462  std::cout << "Found object reference " << objid << std::endl;
463 
464  return SqlReadObjectDirect(obj, cl, objid, streamer, streamer_index, onFileClass);
465 }
466 
467 ////////////////////////////////////////////////////////////////////////////////
468 /// Read object data.
469 /// Class name and version are taken from special objects table.
470 
471 void* TBufferSQL2::SqlReadObjectDirect(void* obj, TClass** cl, Long64_t objid, TMemberStreamer *streamer, Int_t streamer_index, const TClass *onFileClass)
472 {
473  TString clname;
474  Version_t version;
475 
476  if (!SqlObjectInfo(objid, clname, version)) return obj;
477 
478  if (gDebug>2)
479  Info("SqlReadObjectDirect","objid = %lld clname = %s ver = %d",objid, clname.Data(), version);
480 
481  TSQLClassInfo* sqlinfo = fSQL->FindSQLClassInfo(clname.Data(), version);
482 
483  TClass* objClass = TClass::GetClass(clname);
484  if (objClass == TDirectory::Class()) objClass = TDirectoryFile::Class();
485 
486  if ((objClass==0) || (sqlinfo==0)) {
487  Error("SqlReadObjectDirect","Class %s is not known", clname.Data());
488  return obj;
489  }
490 
491  if (obj==0) obj = objClass->New();
492 
493  if (fObjMap==0) fObjMap = new TExMap();
494 
495  fObjMap->Add((Long_t) objid - fFirstObjId, (Long_t) obj);
496 
497  PushStack()->SetObjectRef(objid, objClass);
498 
499  TSQLObjectData* olddata = fCurrentData;
500 
501  if (sqlinfo->IsClassTableExist()) {
502  // TObject and TString classes treated differently
503  if ((objClass==TObject::Class()) || (objClass==TString::Class())) {
504 
505  TSQLObjectData* objdata = new TSQLObjectData;
506  if (objClass==TObject::Class())
507  TSQLStructure::UnpackTObject(fSQL, this, objdata, objid, version);
508  else
509  if (objClass==TString::Class())
510  TSQLStructure::UnpackTString(fSQL, this, objdata, objid, version);
511 
512  Stack()->AddObjectData(objdata);
513  fCurrentData = objdata;
514  } else
515  // before normal streamer first version will be read and
516  // then streamer functions of TStreamerInfo class
517  fReadVersionBuffer = version;
518  } else {
519  TSQLObjectData* objdata = SqlObjectData(objid, sqlinfo);
520  if ((objdata==0) || !objdata->PrepareForRawData()) {
521  Error("SqlReadObjectDirect","No found raw data for obj %lld in class %s version %d table", objid, clname.Data(), version);
522  fErrorFlag = 1;
523  return obj;
524  }
525 
526  Stack()->AddObjectData(objdata);
527 
528  fCurrentData = objdata;
529  }
530 
531  if (streamer!=0) {
532  streamer->SetOnFileClass( onFileClass );
533  (*streamer)(*this, (void*)obj, streamer_index);
534  } else {
535  objClass->Streamer((void*)obj, *this, onFileClass);
536  }
537 
538  PopStack();
539 
540  if (gDebug>1)
541  std::cout << "Read object of class " << objClass->GetName() << " done" << std::endl << std::endl;
542 
543  if (cl!=0) *cl = objClass;
544 
545  fCurrentData = olddata;
546 
547  return obj;
548 }
549 
550 ////////////////////////////////////////////////////////////////////////////////
551 /// Function is called from TStreamerInfo WriteBuffer and Readbuffer functions
552 /// and indent new level in data structure.
553 /// This call indicates, that TStreamerInfo functions starts streaming
554 /// object data of correspondent class
555 
557 {
558  if (info==0) return;
559 
561 
562  if (gDebug>2)
563  std::cout << " IncrementLevel " << info->GetName() << std::endl;
564 
565  WorkWithClass(info->GetName(), info->GetClassVersion());
566 }
567 
568 ////////////////////////////////////////////////////////////////////////////////
569 /// Function is called from TStreamerInfo WriteBuffer and Readbuffer functions
570 /// and decrease level in sql structure.
571 
573 {
574  TSQLStructure* curr = Stack();
575  if (curr->GetElement()) PopStack(); // for element
576  PopStack(); // for streamerinfo
577 
578  // restore value of object data
580 
582 
583  if (gDebug>2)
584  std::cout << " DecrementLevel " << info->GetClass()->GetName() << std::endl;
585 }
586 
587 ////////////////////////////////////////////////////////////////////////////////
588 /// Function is called from TStreamerInfo WriteBuffer and Readbuffer functions
589 /// and add/verify next element in sql tables
590 /// This calls allows separate data, correspondent to one class member, from another
591 
593 {
594  if (Stack()->GetElement()) PopStack(); // was with if (number > 0), i.e. not first element.
595  TSQLStructure* curr = Stack();
596 
597  TStreamerInfo* info = curr->GetStreamerInfo();
598  if (info==0) {
599  Error("SetStreamerElementNumber","Error in structures stack");
600  return;
601  }
602 
603  Int_t elem_type = elem->GetType();
604 
605  fExpectedChain = ((elem_type>0) && (elem_type<20)) &&
606  (comp_type - elem_type == TStreamerInfo::kOffsetL);
607 
608  WorkWithElement(elem, comp_type);
609 }
610 
611 ////////////////////////////////////////////////////////////////////////////////
612 /// This method inform buffer data of which class now
613 /// will be streamed. When reading, classversion should be specified
614 /// as was read by TBuffer::ReadVersion().
615 ///
616 /// ClassBegin(), ClassEnd() & ClassMemeber() should be used in
617 /// custom class streamers to specify which kind of data are
618 /// now streamed to/from buffer. That information is used to correctly
619 /// convert class data to/from "normal" sql tables with meaningfull names
620 /// and correct datatypes. Without that functions data from custom streamer
621 /// will be saved as "raw" data in special _streamer_ table one value after another
622 /// Such MUST be used when object is written with standard ROOT streaming
623 /// procedure, but should be read back in custom streamer.
624 /// For example, custom streamer of TNamed class may look like:
625 
626 void TBufferSQL2::ClassBegin(const TClass* cl, Version_t classversion)
627 {
628 // void TNamed::Streamer(TBuffer &b)
629 // UInt_t R__s, R__c;
630 // if (b.IsReading()) {
631 // Version_t R__v = b.ReadVersion(&R__s, &R__c);
632 // b.ClassBegin(TNamed::Class(), R__v);
633 // b.ClassMember("TObject");
634 // TObject::Streamer(b);
635 // b.ClassMember("fName","TString");
636 // fName.Streamer(b);
637 // b.ClassMember("fTitle","TString");
638 // fTitle.Streamer(b);
639 // b.ClassEnd(TNamed::Class());
640 // b.SetBufferOffset(R__s+R__c+sizeof(UInt_t));
641 // } else {
642 // TNamed::Class()->WriteBuffer(b,this);
643 // }
644 
645  if (classversion<0) classversion = cl->GetClassVersion();
646 
647  PushStack()->SetCustomClass(cl, classversion);
648 
649  if (gDebug>2) Info("ClassBegin", "%s", cl->GetName());
650 
651  WorkWithClass(cl->GetName(), classversion);
652 }
653 
654 ////////////////////////////////////////////////////////////////////////////////
655 /// Method indicates end of streaming of classdata in custom streamer.
656 /// See ClassBegin() method for more details.
657 
659 {
660  TSQLStructure* curr = Stack();
661  if (curr->GetType()==TSQLStructure::kSqlCustomElement) PopStack(); // for element
662  PopStack(); // for streamerinfo
663 
664  // restore value of object data
666 
668 
669  if (gDebug>2) Info("ClassEnd","%s",cl->GetName());
670 }
671 
672 ////////////////////////////////////////////////////////////////////////////////
673 /// Method indicates name and typename of class memeber,
674 /// which should be now streamed in custom streamer
675 /// Following combinations are supported:
676 /// see TBufferXML::ClassMember for the details.
677 
678 void TBufferSQL2::ClassMember(const char* name, const char* typeName, Int_t arrsize1, Int_t arrsize2)
679 {
680  if (typeName==0) typeName = name;
681 
682  if ((name==0) || (strlen(name)==0)) {
683  Error("ClassMember","Invalid member name");
684  fErrorFlag = 1;
685  return;
686  }
687 
688  TString tname = typeName;
689 
690  Int_t typ_id = -1;
691 
692  if (strcmp(typeName,"raw:data")==0)
693  typ_id = TStreamerInfo::kMissing;
694 
695  if (typ_id<0) {
696  TDataType *dt = gROOT->GetType(typeName);
697  if (dt!=0)
698  if ((dt->GetType()>0) && (dt->GetType()<20))
699  typ_id = dt->GetType();
700  }
701 
702  if (typ_id<0)
703  if (strcmp(name, typeName)==0) {
704  TClass* cl = TClass::GetClass(tname.Data());
705  if (cl!=0) typ_id = TStreamerInfo::kBase;
706  }
707 
708  if (typ_id<0) {
709  Bool_t isptr = kFALSE;
710  if (tname[tname.Length()-1]=='*') {
711  tname.Resize(tname.Length()-1);
712  isptr = kTRUE;
713  }
714  TClass* cl = TClass::GetClass(tname.Data());
715  if (cl==0) {
716  Error("ClassMember","Invalid class specifier %s", typeName);
717  fErrorFlag = 1;
718  return;
719  }
720 
721  if (cl->IsTObject())
723  else
724  typ_id = isptr ? TStreamerInfo::kAnyp : TStreamerInfo::kAny;
725 
726  if ((cl==TString::Class()) && !isptr)
727  typ_id = TStreamerInfo::kTString;
728  }
729 
730  TStreamerElement* elem = 0;
731 
732  if (typ_id == TStreamerInfo::kMissing) {
733  elem = new TStreamerElement(name,"title",0, typ_id, "raw:data");
734  } else
735 
736  if (typ_id==TStreamerInfo::kBase) {
737  TClass* cl = TClass::GetClass(tname.Data());
738  if (cl!=0) {
739  TStreamerBase* b = new TStreamerBase(tname.Data(), "title", 0);
741  elem = b;
742  }
743  } else
744 
745  if ((typ_id>0) && (typ_id<20)) {
746  elem = new TStreamerBasicType(name, "title", 0, typ_id, typeName);
747  } else
748 
749  if ((typ_id==TStreamerInfo::kObject) ||
750  (typ_id==TStreamerInfo::kTObject) ||
751  (typ_id==TStreamerInfo::kTNamed)) {
752  elem = new TStreamerObject(name, "title", 0, tname.Data());
753  } else
754 
755  if (typ_id==TStreamerInfo::kObjectp) {
756  elem = new TStreamerObjectPointer(name, "title", 0, tname.Data());
757  } else
758 
759  if (typ_id==TStreamerInfo::kAny) {
760  elem = new TStreamerObjectAny(name, "title", 0, tname.Data());
761  } else
762 
763  if (typ_id==TStreamerInfo::kAnyp) {
764  elem = new TStreamerObjectAnyPointer(name, "title", 0, tname.Data());
765  } else
766 
767  if (typ_id==TStreamerInfo::kTString) {
768  elem = new TStreamerString(name, "title", 0);
769  }
770 
771  if (elem==0) {
772  Error("ClassMember","Invalid combination name = %s type = %s", name, typeName);
773  fErrorFlag = 1;
774  return;
775  }
776 
777  if (arrsize1>0) {
778  elem->SetArrayDim(arrsize2>0 ? 2 : 1);
779  elem->SetMaxIndex(0, arrsize1);
780  if (arrsize2>0)
781  elem->SetMaxIndex(1, arrsize2);
782  }
783 
784  // return stack to CustomClass node
786 
788 
789  // we indicate that there is no streamerinfo
790  WorkWithElement(elem, -1);
791 }
792 
793 ////////////////////////////////////////////////////////////////////////////////
794 /// This function is a part of IncrementLevel method.
795 /// Also used in StartClass method
796 
797 void TBufferSQL2::WorkWithClass(const char* classname, Version_t classversion)
798 {
800 
801  if (IsReading()) {
802  Long64_t objid = 0;
803 
804 // if ((fCurrentData!=0) && fCurrentData->VerifyDataType(sqlio::ObjectInst, kFALSE))
805 // if (!fCurrentData->IsBlobData()) Info("WorkWithClass","Big problem %s", fCurrentData->GetValue());
806 
807  if ((fCurrentData!=0) && fCurrentData->IsBlobData() &&
809  objid = atoi(fCurrentData->GetValue());
811  TString sobjid;
812  sobjid.Form("%lld",objid);
813  Stack()->ChangeValueOnly(sobjid.Data());
814  } else
815  objid = Stack()->DefineObjectId(kTRUE);
816  if (objid<0) {
817  Error("WorkWithClass","cannot define object id");
818  fErrorFlag = 1;
819  return;
820  }
821 
822  TSQLClassInfo* sqlinfo = fSQL->FindSQLClassInfo(classname, classversion);
823  if (sqlinfo==0) {
824  Error("WorkWithClass","Can not find table for class %s version %d", classname, classversion);
825  fErrorFlag = 1;
826  return;
827  }
828 
829  TSQLObjectData* objdata = SqlObjectData(objid, sqlinfo);
830  if (objdata==0) {
831  Error("WorkWithClass","Request error for data of object %lld for class %s version %d", objid, classname, classversion);
832  fErrorFlag = 1;
833  return;
834  }
835 
836  Stack()->AddObjectData(objdata);
837 
838  fCurrentData = objdata;
839  }
840 }
841 
842 ////////////////////////////////////////////////////////////////////////////////
843 /// This function is a part of SetStreamerElementNumber method.
844 /// It is introduced for reading of data for specified data memeber of class.
845 /// Used also in ReadFastArray methods to resolve problem of compressed data,
846 /// when several data memebers of the same basic type streamed with single ...FastArray call
847 
849 {
850  if (gDebug>2)
851  Info("WorkWithElement","elem = %s",elem->GetName());
852 
853  TSQLStructure* stack = Stack(1);
854  TStreamerInfo* info = stack->GetStreamerInfo();
855  Int_t number = info ? info->GetElements()->IndexOf(elem) : -1;
856 
857  if (number>=0)
858  PushStack()->SetStreamerElement(elem, number);
859  else
860  PushStack()->SetCustomElement(elem);
861 
862  if (IsReading()) {
863 
864  if (fCurrentData==0) {
865  Error("WorkWithElement","Object data is lost");
866  fErrorFlag = 1;
867  return;
868  }
869 
871 
872  Int_t located = Stack()->LocateElementColumn(fSQL, this, fCurrentData);
873 
874  if (located==TSQLStructure::kColUnknown) {
875  Error("WorkWithElement","Cannot locate correct column in the table");
876  fErrorFlag = 1;
877  return;
878  } else
879  if ((located==TSQLStructure::kColObject) ||
880  (located==TSQLStructure::kColObjectArray) ||
881  (located==TSQLStructure::kColParent)) {
882  // search again for object data while for BLOB it should be already assign
884  }
885  }
886 }
887 
888 ////////////////////////////////////////////////////////////////////////////////
889 /// Suppressed function of TBuffer
890 
892 {
893  return 0;
894 }
895 
896 ////////////////////////////////////////////////////////////////////////////////
897 /// Suppressed function of TBuffer
898 
900 {
901 }
902 
903 ////////////////////////////////////////////////////////////////////////////////
904 /// Suppressed function of TBuffer
905 
906 Int_t TBufferSQL2::CheckByteCount(UInt_t /*r_s */, UInt_t /*r_c*/, const TClass* /*cl*/)
907 {
908  return 0;
909 }
910 
911 ////////////////////////////////////////////////////////////////////////////////
912 /// Suppressed function of TBuffer
913 
915 {
916  return 0;
917 }
918 
919 ////////////////////////////////////////////////////////////////////////////////
920 /// Suppressed function of TBuffer
921 
923 {
924 }
925 
926 ////////////////////////////////////////////////////////////////////////////////
927 /// Skip class version from I/O buffer.
928 
930 {
931  ReadVersion(0,0,cl);
932 }
933 
934 ////////////////////////////////////////////////////////////////////////////////
935 /// Read version value from buffer
936 /// actually version is normally defined by table name
937 /// and kept in intermediate variable fReadVersionBuffer
938 
940 {
941  Version_t res = 0;
942 
943  if (start) *start = 0;
944  if (bcnt) *bcnt = 0;
945 
946  if (fReadVersionBuffer>=0) {
947  res = fReadVersionBuffer;
948  fReadVersionBuffer = -1;
949  if (gDebug>3)
950  std::cout << "TBufferSQL2::ReadVersion from buffer = " << res << std::endl;
951  } else
952  if ((fCurrentData!=0) && fCurrentData->IsBlobData() &&
954  TString value = fCurrentData->GetValue();
955  res = value.Atoi();
956  if (gDebug>3)
957  std::cout << "TBufferSQL2::ReadVersion from blob " << fCurrentData->GetBlobPrefixName() << " = " << res << std::endl;
959  } else {
960  Error("ReadVersion", "No correspondent tags to read version");
961  fErrorFlag = 1;
962  }
963 
964  return res;
965 }
966 
967 ////////////////////////////////////////////////////////////////////////////////
968 /// Copies class version to buffer, but not writes it to sql immidiately
969 /// Version will be used to produce complete table
970 /// name, which will include class version
971 
973 {
974  if (gDebug>2)
975  std::cout << "TBufferSQL2::WriteVersion " << (cl ? cl->GetName() : "null") << " ver = " << (cl ? cl->GetClassVersion() : 0) << std::endl;
976 
977  if (cl)
978  Stack()->AddVersion(cl);
979 
980  return 0;
981 }
982 
983 ////////////////////////////////////////////////////////////////////////////////
984 /// Read object from buffer. Only used from TBuffer.
985 
987 {
988  return SqlReadObject(0);
989 }
990 
991 ////////////////////////////////////////////////////////////////////////////////
992 /// ?????? Skip any kind of object from buffer
993 /// !!!!!! fix me, not yet implemented
994 /// Should be just skip of current column later
995 
997 {
998 }
999 
1000 ////////////////////////////////////////////////////////////////////////////////
1001 /// Write object to buffer. Only used from TBuffer
1002 
1003 void TBufferSQL2::WriteObjectClass(const void *actualObjStart, const TClass *actualClass)
1004 {
1005  if (gDebug>2)
1006  std::cout << "TBufferSQL2::WriteObject of class " << (actualClass ? actualClass->GetName() : " null") << std::endl;
1007  SqlWriteObject(actualObjStart, actualClass);
1008 }
1009 
1010 #define SQLReadArrayUncompress(vname, arrsize) \
1011  { \
1012  while(indx<arrsize) \
1013  SqlReadBasic(vname[indx++]); \
1014  }
1015 
1016 
1017 #define SQLReadArrayCompress(vname, arrsize) \
1018  { \
1019  while(indx<arrsize) { \
1020  const char* name = fCurrentData->GetBlobPrefixName(); \
1021  Int_t first, last, res; \
1022  if (strstr(name,sqlio::IndexSepar)==0) { \
1023  res = sscanf(name,"[%d", &first); last = first; \
1024  } else res = sscanf(name,"[%d..%d", &first, &last); \
1025  if (gDebug>5) std::cout << name << " first = " << first << " last = " << last << " res = " << res << std::endl; \
1026  if ((first!=indx) || (last<first) || (last>=arrsize)) { \
1027  Error("SQLReadArrayCompress","Error reading array content %s", name); \
1028  fErrorFlag = 1; \
1029  break; \
1030  } \
1031  SqlReadBasic(vname[indx]); indx++; \
1032  while(indx<=last) \
1033  vname[indx++] = vname[first]; \
1034  } \
1035  }
1036 
1037 
1038 // macro to read content of array with compression
1039 #define SQLReadArrayContent(vname, arrsize, withsize) \
1040  { \
1041  if (gDebug>3) std::cout << "SQLReadArrayContent " << (arrsize) << std::endl; \
1042  PushStack()->SetArray(withsize ? arrsize : -1); \
1043  Int_t indx = 0; \
1044  if (fCurrentData->IsBlobData()) \
1045  SQLReadArrayCompress(vname, arrsize) \
1046  else \
1047  SQLReadArrayUncompress(vname, arrsize) \
1048  PopStack(); \
1049  if (gDebug>3) std::cout << "SQLReadArrayContent done " << std::endl; \
1050  }
1051 
1052 // macro to read array, which include size attribute
1053 #define TBufferSQL2_ReadArray(tname, vname) \
1054  { \
1055  Int_t n = SqlReadArraySize(); \
1056  if (n<=0) return 0; \
1057  if (!vname) vname = new tname[n]; \
1058  SQLReadArrayContent(vname, n, kTRUE); \
1059  return n; \
1060  }
1061 
1062 ////////////////////////////////////////////////////////////////////////////////
1063 /// Read Float16 value
1064 
1066 {
1067  SqlReadBasic(*f);
1068 }
1069 
1070 ////////////////////////////////////////////////////////////////////////////////
1071 /// Read Double32 value
1072 
1074 {
1075  SqlReadBasic(*d);
1076 }
1077 
1078 ////////////////////////////////////////////////////////////////////////////////
1079 /// Read a Double32_t from the buffer when the factor and minimun value have been specified
1080 /// see comments about Double32_t encoding at TBufferFile::WriteDouble32().
1081 /// Currently TBufferXML does not optimize space in this case.
1082 
1083 void TBufferSQL2::ReadWithFactor(Float_t *ptr, Double_t /* factor */, Double_t /* minvalue */)
1084 {
1085  SqlReadBasic(*ptr);
1086 }
1087 
1088 ////////////////////////////////////////////////////////////////////////////////
1089 /// Read a Float16_t from the buffer when the number of bits is specified (explicitly or not)
1090 /// see comments about Float16_t encoding at TBufferFile::WriteFloat16().
1091 /// Currently TBufferXML does not optimize space in this case.
1092 
1094 {
1095  SqlReadBasic(*ptr);
1096 }
1097 
1098 ////////////////////////////////////////////////////////////////////////////////
1099 /// Read a Double32_t from the buffer when the factor and minimun value have been specified
1100 /// see comments about Double32_t encoding at TBufferFile::WriteDouble32().
1101 /// Currently TBufferXML does not optimize space in this case.
1102 
1103 void TBufferSQL2::ReadWithFactor(Double_t *ptr, Double_t /* factor */, Double_t /* minvalue */)
1104 {
1105  SqlReadBasic(*ptr);
1106 }
1107 
1108 ////////////////////////////////////////////////////////////////////////////////
1109 /// Read a Double32_t from the buffer when the number of bits is specified (explicitly or not)
1110 /// see comments about Double32_t encoding at TBufferFile::WriteDouble32().
1111 /// Currently TBufferXML does not optimize space in this case.
1112 
1114 {
1115  SqlReadBasic(*ptr);
1116 }
1117 
1118 ////////////////////////////////////////////////////////////////////////////////
1119 /// Write Float16 value
1120 
1122 {
1123  SqlWriteBasic(*f);
1124 }
1125 
1126 ////////////////////////////////////////////////////////////////////////////////
1127 /// Write Double32 value
1128 
1130 {
1131  SqlWriteBasic(*d);
1132 }
1133 
1134 ////////////////////////////////////////////////////////////////////////////////
1135 /// Read array of Bool_t from buffer
1136 
1138 {
1140 }
1141 
1142 ////////////////////////////////////////////////////////////////////////////////
1143 /// Read array of Char_t from buffer
1144 
1146 {
1148 }
1149 
1150 ////////////////////////////////////////////////////////////////////////////////
1151 /// Read array of UChar_t from buffer
1152 
1154 {
1156 }
1157 
1158 ////////////////////////////////////////////////////////////////////////////////
1159 /// Read array of Short_t from buffer
1160 
1162 {
1164 }
1165 
1166 ////////////////////////////////////////////////////////////////////////////////
1167 /// Read array of UShort_t from buffer
1168 
1170 {
1172 }
1173 
1174 ////////////////////////////////////////////////////////////////////////////////
1175 /// Read array of Int_t from buffer
1176 
1178 {
1180 }
1181 
1182 ////////////////////////////////////////////////////////////////////////////////
1183 /// Read array of UInt_t from buffer
1184 
1186 {
1188 }
1189 
1190 ////////////////////////////////////////////////////////////////////////////////
1191 /// Read array of Long_t from buffer
1192 
1194 {
1196 }
1197 
1198 ////////////////////////////////////////////////////////////////////////////////
1199 /// Read array of ULong_t from buffer
1200 
1202 {
1204 }
1205 
1206 ////////////////////////////////////////////////////////////////////////////////
1207 /// Read array of Long64_t from buffer
1208 
1210 {
1212 }
1213 
1214 ////////////////////////////////////////////////////////////////////////////////
1215 /// Read array of ULong64_t from buffer
1216 
1218 {
1220 }
1221 
1222 ////////////////////////////////////////////////////////////////////////////////
1223 /// Read array of Float_t from buffer
1224 
1226 {
1228 }
1229 
1230 ////////////////////////////////////////////////////////////////////////////////
1231 /// Read array of Double_t from buffer
1232 
1234 {
1236 }
1237 
1238 ////////////////////////////////////////////////////////////////////////////////
1239 /// Read array of Float16_t from buffer
1240 
1242 {
1244 }
1245 
1246 ////////////////////////////////////////////////////////////////////////////////
1247 /// Read array of Double32_t from buffer
1248 
1250 {
1252 }
1253 
1254 // macro to read static array, which include size attribute
1255 #define TBufferSQL2_ReadStaticArray(vname) \
1256  { \
1257  Int_t n = SqlReadArraySize(); \
1258  if (n<=0) return 0; \
1259  if (!vname) return 0; \
1260  SQLReadArrayContent(vname, n, kTRUE); \
1261  return n; \
1262  }
1263 
1264 ////////////////////////////////////////////////////////////////////////////////
1265 /// Read array of Bool_t from buffer
1266 
1268 {
1270 }
1271 
1272 ////////////////////////////////////////////////////////////////////////////////
1273 /// Read array of Char_t from buffer
1274 
1276 {
1278 }
1279 
1280 ////////////////////////////////////////////////////////////////////////////////
1281 /// Read array of UChar_t from buffer
1282 
1284 {
1286 }
1287 
1288 ////////////////////////////////////////////////////////////////////////////////
1289 /// Read array of Short_t from buffer
1290 
1292 {
1294 }
1295 
1296 ////////////////////////////////////////////////////////////////////////////////
1297 /// Read array of UShort_t from buffer
1298 
1300 {
1302 }
1303 
1304 ////////////////////////////////////////////////////////////////////////////////
1305 /// Read array of Int_t from buffer
1306 
1308 {
1310 }
1311 
1312 ////////////////////////////////////////////////////////////////////////////////
1313 /// Read array of UInt_t from buffer
1314 
1316 {
1318 }
1319 
1320 ////////////////////////////////////////////////////////////////////////////////
1321 /// Read array of Long_t from buffer
1322 
1324 {
1326 }
1327 
1328 ////////////////////////////////////////////////////////////////////////////////
1329 /// Read array of ULong_t from buffer
1330 
1332 {
1334 }
1335 
1336 ////////////////////////////////////////////////////////////////////////////////
1337 /// Read array of Long64_t from buffer
1338 
1340 {
1342 }
1343 
1344 ////////////////////////////////////////////////////////////////////////////////
1345 /// Read array of ULong64_t from buffer
1346 
1348 {
1350 }
1351 
1352 ////////////////////////////////////////////////////////////////////////////////
1353 /// Read array of Float_t from buffer
1354 
1356 {
1358 }
1359 
1360 ////////////////////////////////////////////////////////////////////////////////
1361 /// Read array of Double_t from buffer
1362 
1364 {
1366 }
1367 
1368 ////////////////////////////////////////////////////////////////////////////////
1369 /// Read array of Float16_t from buffer
1370 
1372 {
1374 }
1375 
1376 ////////////////////////////////////////////////////////////////////////////////
1377 /// Read array of Double32_t from buffer
1378 
1380 {
1382 }
1383 
1384 // macro to read content of array, which not include size of array
1385 // macro also treat situation, when instead of one single array chain of several elements should be produced
1386 #define TBufferSQL2_ReadFastArray(vname) \
1387  { \
1388  if (n<=0) return; \
1389  TStreamerElement* elem = Stack(0)->GetElement(); \
1390  if ((elem!=0) && (elem->GetType()>TStreamerInfo::kOffsetL) && \
1391  (elem->GetType()<TStreamerInfo::kOffsetP) && \
1392  (elem->GetArrayLength()!=n)) fExpectedChain = kTRUE; \
1393  if (fExpectedChain) { \
1394  fExpectedChain = kFALSE; \
1395  Int_t startnumber = Stack(0)->GetElementNumber(); \
1396  TStreamerInfo* info = Stack(1)->GetStreamerInfo(); \
1397  Int_t index = 0; \
1398  while (index<n) { \
1399  elem = (TStreamerElement*)info->GetElements()->At(startnumber++); \
1400  if (index>1) { PopStack(); WorkWithElement(elem, elem->GetType()); } \
1401  if (elem->GetType()<TStreamerInfo::kOffsetL) { \
1402  SqlReadBasic(vname[index]); \
1403  index++; \
1404  } else { \
1405  Int_t elemlen = elem->GetArrayLength(); \
1406  SQLReadArrayContent((vname+index), elemlen, kFALSE); \
1407  index+=elemlen; \
1408  } \
1409  } \
1410  } else { \
1411  SQLReadArrayContent(vname, n, kFALSE); \
1412  } \
1413  }
1414 ////////////////////////////////////////////////////////////////////////////////
1415 /// Read array of Bool_t from buffer
1416 
1418 {
1420 }
1421 
1422 ////////////////////////////////////////////////////////////////////////////////
1423 /// Read array of Char_t from buffer
1424 /// if nodename==CharStar, read all array as string
1425 
1427 {
1428  if ((n>0) && fCurrentData->IsBlobData() &&
1430  const char* buf = SqlReadCharStarValue();
1431  if ((buf==0) || (n<=0)) return;
1432  Int_t size = strlen(buf);
1433  if (size<n) size = n;
1434  memcpy(c, buf, size);
1435  } else {
1436  // std::cout << "call standard macro TBufferSQL2_ReadFastArray" << std::endl;
1438  }
1439 }
1440 
1441 ////////////////////////////////////////////////////////////////////////////////
1442 /// Read array of UChar_t from buffer
1443 
1445 {
1447 }
1448 
1449 ////////////////////////////////////////////////////////////////////////////////
1450 /// Read array of Short_t from buffer
1451 
1453 {
1455 }
1456 
1457 ////////////////////////////////////////////////////////////////////////////////
1458 /// Read array of UShort_t from buffer
1459 
1461 {
1463 }
1464 
1465 ////////////////////////////////////////////////////////////////////////////////
1466 /// Read array of Int_t from buffer
1467 
1469 {
1471 }
1472 
1473 ////////////////////////////////////////////////////////////////////////////////
1474 /// Read array of UInt_t from buffer
1475 
1477 {
1479 }
1480 
1481 ////////////////////////////////////////////////////////////////////////////////
1482 /// Read array of Long_t from buffer
1483 
1485 {
1487 }
1488 
1489 ////////////////////////////////////////////////////////////////////////////////
1490 /// Read array of ULong_t from buffer
1491 
1493 {
1495 }
1496 
1497 ////////////////////////////////////////////////////////////////////////////////
1498 /// Read array of Long64_t from buffer
1499 
1501 {
1503 }
1504 
1505 ////////////////////////////////////////////////////////////////////////////////
1506 /// Read array of ULong64_t from buffer
1507 
1509 {
1511 }
1512 
1513 ////////////////////////////////////////////////////////////////////////////////
1514 /// Read array of Float_t from buffer
1515 
1517 {
1519 }
1520 
1521 ////////////////////////////////////////////////////////////////////////////////
1522 /// Read array of Double_t from buffer
1523 
1525 {
1527 }
1528 
1529 ////////////////////////////////////////////////////////////////////////////////
1530 /// Read array of Float16_t from buffer
1531 
1533 {
1535 }
1536 
1537 ////////////////////////////////////////////////////////////////////////////////
1538 /// Read array of Float16_t from buffer
1539 
1541 {
1543 }
1544 
1545 ////////////////////////////////////////////////////////////////////////////////
1546 /// Read array of Float16_t from buffer
1547 
1549 {
1551 }
1552 
1553 ////////////////////////////////////////////////////////////////////////////////
1554 /// Read array of Double32_t from buffer
1555 
1557 {
1559 }
1560 
1561 ////////////////////////////////////////////////////////////////////////////////
1562 /// Read array of Double32_t from buffer
1563 
1565 {
1567 }
1568 ////////////////////////////////////////////////////////////////////////////////
1569 /// Read array of Double32_t from buffer
1570 
1572 {
1574 }
1575 
1576 ////////////////////////////////////////////////////////////////////////////////
1577 /// Same functionality as TBuffer::ReadFastArray(...) but
1578 /// instead of calling cl->Streamer(obj,buf) call here
1579 /// buf.StreamObject(obj, cl). In that case it is easy to understand where
1580 /// object data is started and finished
1581 
1582 void TBufferSQL2::ReadFastArray(void *start, const TClass *cl, Int_t n, TMemberStreamer *streamer, const TClass* onFileClass )
1583 {
1584  if (gDebug>2)
1585  Info("ReadFastArray","(void *");
1586 
1587  if (streamer) {
1588  StreamObject(start, streamer, cl, 0, onFileClass);
1589 // (*streamer)(*this,start,0);
1590  return;
1591  }
1592 
1593  int objectSize = cl->Size();
1594  char *obj = (char*)start;
1595  char *end = obj + n*objectSize;
1596 
1597  for(; obj<end; obj+=objectSize) {
1598  StreamObject(obj, cl, onFileClass);
1599  }
1600  // TBuffer::ReadFastArray(start, cl, n, s);
1601 }
1602 
1603 ////////////////////////////////////////////////////////////////////////////////
1604 /// Same functionality as TBuffer::ReadFastArray(...) but
1605 /// instead of calling cl->Streamer(obj,buf) call here
1606 /// buf.StreamObject(obj, cl). In that case it is easy to understand where
1607 /// object data is started and finished
1608 
1609 void TBufferSQL2::ReadFastArray(void **start, const TClass *cl, Int_t n, Bool_t isPreAlloc, TMemberStreamer *streamer, const TClass* onFileClass )
1610 {
1611  if (gDebug>2)
1612  Info("ReadFastArray","(void ** pre = %d n = %d", isPreAlloc, n);
1613 
1614  if (streamer) {
1615  if (isPreAlloc) {
1616  for (Int_t j=0;j<n;j++) {
1617  if (!start[j]) start[j] = ((TClass*)cl)->New();
1618  }
1619  }
1620  StreamObject((void*)start, streamer, cl, 0, onFileClass);
1621 // (*streamer)(*this,(void*)start,0);
1622  return;
1623  }
1624 
1625  if (!isPreAlloc) {
1626 
1627  for (Int_t j=0; j<n; j++){
1628  //delete the object or collection
1629  if (start[j] && TStreamerInfo::CanDelete()) ((TClass*)cl)->Destructor(start[j],kFALSE); // call delete and desctructor
1630  start[j] = ReadObjectAny(cl);
1631  }
1632 
1633  } else { //case //-> in comment
1634 
1635  for (Int_t j=0; j<n; j++) {
1636  if (!start[j]) start[j] = ((TClass*)cl)->New();
1637  StreamObject(start[j], cl, onFileClass);
1638  }
1639  }
1640 
1641  if (gDebug>2)
1642  Info("ReadFastArray","(void ** Done" );
1643 
1644  // TBuffer::ReadFastArray(startp, cl, n, isPreAlloc, s);
1645 }
1646 
1647 ////////////////////////////////////////////////////////////////////////////////
1648 /// Reads array size, written in raw data table.
1649 /// Used in ReadArray methods, where TBuffer need to read array size first.
1650 
1652 {
1653  const char* value = SqlReadValue(sqlio::Array);
1654  if ((value==0) || (strlen(value)==0)) return 0;
1655  Int_t sz = atoi(value);
1656  return sz;
1657 }
1658 
1659 // macro to write content of noncompressed array, not used
1660 #define SQLWriteArrayNoncompress(vname, arrsize) \
1661  { \
1662  for(Int_t indx=0;indx<arrsize;indx++) { \
1663  SqlWriteBasic(vname[indx]); \
1664  Stack()->ChildArrayIndex(indx, 1); \
1665  } \
1666  }
1667 
1668 // macro to write content of compressed array
1669 #define SQLWriteArrayCompress(vname, arrsize) \
1670  { \
1671  Int_t indx = 0; \
1672  while(indx<arrsize) { \
1673  Int_t curr = indx; indx++; \
1674  while ((indx<arrsize) && (vname[indx]==vname[curr])) indx++; \
1675  SqlWriteBasic(vname[curr]); \
1676  Stack()->ChildArrayIndex(curr, indx-curr); \
1677  } \
1678  }
1679 
1680 #define SQLWriteArrayContent(vname, arrsize, withsize) \
1681  { \
1682  PushStack()->SetArray(withsize ? arrsize : -1); \
1683  if (fCompressLevel>0) { \
1684  SQLWriteArrayCompress(vname, arrsize) \
1685  } else { \
1686  SQLWriteArrayNoncompress(vname, arrsize) \
1687  } \
1688  PopStack(); \
1689  }
1690 
1691 // macro to write array, which include size
1692 #define TBufferSQL2_WriteArray(vname) \
1693  { \
1694  SQLWriteArrayContent(vname, n, kTRUE); \
1695  }
1696 
1697 ////////////////////////////////////////////////////////////////////////////////
1698 /// Write array of Bool_t to buffer
1699 
1701 {
1703 }
1704 
1705 ////////////////////////////////////////////////////////////////////////////////
1706 /// Write array of Char_t to buffer
1707 
1709 {
1711 }
1712 
1713 ////////////////////////////////////////////////////////////////////////////////
1714 /// Write array of UChar_t to buffer
1715 
1717 {
1719 }
1720 
1721 ////////////////////////////////////////////////////////////////////////////////
1722 /// Write array of Short_t to buffer
1723 
1725 {
1727 }
1728 
1729 ////////////////////////////////////////////////////////////////////////////////
1730 /// Write array of UShort_t to buffer
1731 
1733 {
1735 }
1736 
1737 ////////////////////////////////////////////////////////////////////////////////
1738 /// Write array of Int_ to buffer
1739 
1741 {
1743 }
1744 
1745 ////////////////////////////////////////////////////////////////////////////////
1746 /// Write array of UInt_t to buffer
1747 
1749 {
1751 }
1752 
1753 ////////////////////////////////////////////////////////////////////////////////
1754 /// Write array of Long_t to buffer
1755 
1757 {
1759 }
1760 
1761 ////////////////////////////////////////////////////////////////////////////////
1762 /// Write array of ULong_t to buffer
1763 
1765 {
1767 }
1768 
1769 ////////////////////////////////////////////////////////////////////////////////
1770 /// Write array of Long64_t to buffer
1771 
1773 {
1775 }
1776 
1777 ////////////////////////////////////////////////////////////////////////////////
1778 /// Write array of ULong64_t to buffer
1779 
1781 {
1783 }
1784 
1785 ////////////////////////////////////////////////////////////////////////////////
1786 /// Write array of Float_t to buffer
1787 
1789 {
1791 }
1792 
1793 ////////////////////////////////////////////////////////////////////////////////
1794 /// Write array of Double_t to buffer
1795 
1797 {
1799 }
1800 
1801 ////////////////////////////////////////////////////////////////////////////////
1802 /// Write array of Float16_t to buffer
1803 
1805 {
1807 }
1808 
1809 ////////////////////////////////////////////////////////////////////////////////
1810 /// Write array of Double32_t to buffer
1811 
1813 {
1815 }
1816 
1817 // write array without size attribute
1818 // macro also treat situation, when instead of one single array chain of several elements should be produced
1819 #define TBufferSQL2_WriteFastArray(vname) \
1820  { \
1821  if (n<=0) return; \
1822  TStreamerElement* elem = Stack(0)->GetElement(); \
1823  if ((elem!=0) && (elem->GetType()>TStreamerInfo::kOffsetL) && \
1824  (elem->GetType()<TStreamerInfo::kOffsetP) && \
1825  (elem->GetArrayLength()!=n)) fExpectedChain = kTRUE; \
1826  if (fExpectedChain) { \
1827  TStreamerInfo* info = Stack(1)->GetStreamerInfo(); \
1828  Int_t startnumber = Stack(0)->GetElementNumber(); \
1829  Int_t index = 0; \
1830  while (index<n) { \
1831  elem = (TStreamerElement*)info->GetElements()->At(startnumber++); \
1832  if (index>0) { PopStack(); WorkWithElement(elem, elem->GetType()); } \
1833  if (elem->GetType()<TStreamerInfo::kOffsetL) { \
1834  SqlWriteBasic(vname[index]); \
1835  index++; \
1836  } else { \
1837  Int_t elemlen = elem->GetArrayLength(); \
1838  SQLWriteArrayContent((vname+index), elemlen, kFALSE); \
1839  index+=elemlen; \
1840  } \
1841  fExpectedChain = kFALSE; \
1842  } \
1843  } else { \
1844  SQLWriteArrayContent(vname, n, kFALSE); \
1845  } \
1846  }
1847 
1848 ////////////////////////////////////////////////////////////////////////////////
1849 /// Write array of Bool_t to buffer
1850 
1852 {
1854 }
1855 
1856 ////////////////////////////////////////////////////////////////////////////////
1857 /// Write array of Char_t to buffer
1858 /// it will be reproduced as CharStar node with string as attribute
1859 
1861 {
1862  Bool_t usedefault = (n==0) || fExpectedChain;
1863 
1864  const Char_t* ccc = c;
1865  // check if no zeros in the array
1866  if (!usedefault)
1867  for (int i=0;i<n;i++)
1868  if (*ccc++==0) { usedefault = kTRUE; break; }
1869 
1870  if (usedefault) {
1872  } else {
1873  Char_t* buf = new Char_t[n+1];
1874  memcpy(buf, c, n);
1875  buf[n] = 0;
1877  delete[] buf;
1878  }
1879 }
1880 
1881 ////////////////////////////////////////////////////////////////////////////////
1882 /// Write array of UChar_t to buffer
1883 
1885 {
1887 }
1888 
1889 ////////////////////////////////////////////////////////////////////////////////
1890 /// Write array of Short_t to buffer
1891 
1893 {
1895 }
1896 
1897 ////////////////////////////////////////////////////////////////////////////////
1898 /// Write array of UShort_t to buffer
1899 
1901 {
1903 }
1904 
1905 ////////////////////////////////////////////////////////////////////////////////
1906 /// Write array of Int_t to buffer
1907 
1909 {
1911 }
1912 
1913 ////////////////////////////////////////////////////////////////////////////////
1914 /// Write array of UInt_t to buffer
1915 
1917 {
1919 }
1920 
1921 ////////////////////////////////////////////////////////////////////////////////
1922 /// Write array of Long_t to buffer
1923 
1925 {
1927 }
1928 
1929 ////////////////////////////////////////////////////////////////////////////////
1930 /// Write array of ULong_t to buffer
1931 
1933 {
1935 }
1936 
1937 ////////////////////////////////////////////////////////////////////////////////
1938 /// Write array of Long64_t to buffer
1939 
1941 {
1943 }
1944 
1945 ////////////////////////////////////////////////////////////////////////////////
1946 /// Write array of ULong64_t to buffer
1947 
1949 {
1951 }
1952 
1953 ////////////////////////////////////////////////////////////////////////////////
1954 /// Write array of Float_t to buffer
1955 
1957 {
1959 }
1960 
1961 ////////////////////////////////////////////////////////////////////////////////
1962 /// Write array of Double_t to buffer
1963 
1965 {
1967 }
1968 
1969 ////////////////////////////////////////////////////////////////////////////////
1970 /// Write array of Float16_t to buffer
1971 
1973 {
1975 }
1976 
1977 ////////////////////////////////////////////////////////////////////////////////
1978 /// Write array of Double32_t to buffer
1979 
1981 {
1983 }
1984 
1985 ////////////////////////////////////////////////////////////////////////////////
1986 /// Same functionality as TBuffer::WriteFastArray(...) but
1987 /// instead of calling cl->Streamer(obj,buf) call here
1988 /// buf.StreamObject(obj, cl). In that case it is easy to understand where
1989 /// object data is started and finished
1990 
1991 void TBufferSQL2::WriteFastArray(void *start, const TClass *cl, Int_t n, TMemberStreamer *streamer)
1992 {
1993  if (streamer) {
1994  StreamObject(start, streamer, cl, 0);
1995 // (*streamer)(*this, start, 0);
1996  return;
1997  }
1998 
1999  char *obj = (char*)start;
2000  if (!n) n=1;
2001  int size = cl->Size();
2002 
2003  for(Int_t j=0; j<n; j++,obj+=size)
2004  StreamObject(obj, cl);
2005 
2006  // TBuffer::WriteFastArray(start, cl, n, s);
2007 }
2008 
2009 ////////////////////////////////////////////////////////////////////////////////
2010 /// Same functionality as TBuffer::WriteFastArray(...) but
2011 /// instead of calling cl->Streamer(obj,buf) call here
2012 /// buf.StreamObject(obj, cl). In that case it is easy to understand where
2013 /// object data is started and finished
2014 
2015 Int_t TBufferSQL2::WriteFastArray(void **start, const TClass *cl, Int_t n, Bool_t isPreAlloc, TMemberStreamer *streamer)
2016 {
2017  if (streamer) {
2018  StreamObject((void*) start, streamer, cl, 0);
2019 // (*streamer)(*this,(void*)start,0);
2020  return 0;
2021  }
2022 
2023  int strInfo = 0;
2024 
2025  Int_t res = 0;
2026 
2027  if (!isPreAlloc) {
2028 
2029  for (Int_t j=0;j<n;j++) {
2030  //must write StreamerInfo if pointer is null
2031  if (!strInfo && !start[j] ) ForceWriteInfo(((TClass*)cl)->GetStreamerInfo(),kFALSE);
2032  strInfo = 2003;
2033  res |= WriteObjectAny(start[j],cl);
2034  }
2035 
2036  } else {
2037  //case //-> in comment
2038 
2039  for (Int_t j=0;j<n;j++) {
2040  if (!start[j]) start[j] = ((TClass*)cl)->New();
2041  StreamObject(start[j], cl);
2042  }
2043 
2044  }
2045  return res;
2046 
2047 // return TBuffer::WriteFastArray(startp, cl, n, isPreAlloc, s);
2048 }
2049 
2050 ////////////////////////////////////////////////////////////////////////////////
2051 /// Stream object to/from buffer
2052 
2053 void TBufferSQL2::StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass)
2054 {
2055  StreamObject(obj, TClass::GetClass(typeinfo), onFileClass);
2056 }
2057 
2058 ////////////////////////////////////////////////////////////////////////////////
2059 /// Stream object to/from buffer
2060 
2061 void TBufferSQL2::StreamObject(void *obj, const char *className, const TClass *onFileClass)
2062 {
2063  StreamObject(obj, TClass::GetClass(className), onFileClass);
2064 }
2065 
2066 ////////////////////////////////////////////////////////////////////////////////
2067 /// Stream object to/from buffer
2068 
2069 void TBufferSQL2::StreamObject(void *obj, const TClass *cl, const TClass *onFileClass)
2070 {
2071  if (gDebug>1)
2072  std::cout << " TBufferSQL2::StreamObject class = " << (cl ? cl->GetName() : "none") << std::endl;
2073  if (IsReading())
2074  SqlReadObject(obj, 0, 0, 0, onFileClass);
2075  else
2076  SqlWriteObject(obj, cl);
2077 }
2078 
2079 ////////////////////////////////////////////////////////////////////////////////
2080 /// Stream object to/from buffer
2081 
2083 {
2084  StreamObject(obj, obj ? obj->IsA() : TObject::Class());
2085 }
2086 
2087 ////////////////////////////////////////////////////////////////////////////////
2088 /// Stream object to/from buffer
2089 
2090 void TBufferSQL2::StreamObject(void *obj, TMemberStreamer *streamer, const TClass *cl, Int_t n, const TClass *onFileClass)
2091 {
2092  if (streamer==0) return;
2093 
2094  if (gDebug>1)
2095  std::cout << "Stream object of class = " << cl->GetName() << std::endl;
2096 // (*streamer)(*this, obj, n);
2097 
2098  if (IsReading())
2099  SqlReadObject(obj, 0, streamer, n, onFileClass);
2100  else
2101  SqlWriteObject(obj, cl, streamer, n);
2102 }
2103 
2104 // macro for right shift operator for basic type
2105 #define TBufferSQL2_operatorin(vname) \
2106  { \
2107  SqlReadBasic(vname); \
2108  }
2109 
2110 ////////////////////////////////////////////////////////////////////////////////
2111 /// Reads Bool_t value from buffer
2112 
2114 {
2116 }
2117 
2118 ////////////////////////////////////////////////////////////////////////////////
2119 /// Reads Char_t value from buffer
2120 
2122 {
2124 }
2125 
2126 ////////////////////////////////////////////////////////////////////////////////
2127 /// Reads UChar_t value from buffer
2128 
2130 {
2132 }
2133 
2134 ////////////////////////////////////////////////////////////////////////////////
2135 /// Reads Short_t value from buffer
2136 
2138 {
2140 }
2141 
2142 ////////////////////////////////////////////////////////////////////////////////
2143 /// Reads UShort_t value from buffer
2144 
2146 {
2148 }
2149 
2150 ////////////////////////////////////////////////////////////////////////////////
2151 /// Reads Int_t value from buffer
2152 
2154 {
2156 }
2157 
2158 ////////////////////////////////////////////////////////////////////////////////
2159 /// Reads UInt_t value from buffer
2160 
2162 {
2164 }
2165 
2166 ////////////////////////////////////////////////////////////////////////////////
2167 /// Reads Long_t value from buffer
2168 
2170 {
2172 }
2173 
2174 ////////////////////////////////////////////////////////////////////////////////
2175 /// Reads ULong_t value from buffer
2176 
2178 {
2180 }
2181 
2182 ////////////////////////////////////////////////////////////////////////////////
2183 /// Reads Long64_t value from buffer
2184 
2186 {
2188 }
2189 
2190 ////////////////////////////////////////////////////////////////////////////////
2191 /// Reads ULong64_t value from buffer
2192 
2194 {
2196 }
2197 
2198 ////////////////////////////////////////////////////////////////////////////////
2199 /// Reads Float_t value from buffer
2200 
2202 {
2204 }
2205 
2206 ////////////////////////////////////////////////////////////////////////////////
2207 /// Reads Double_t value from buffer
2208 
2210 {
2212 }
2213 
2214 ////////////////////////////////////////////////////////////////////////////////
2215 /// Reads array of characters from buffer
2216 
2218 {
2219  const char* buf = SqlReadCharStarValue();
2220  if (buf) strcpy(c, buf);
2221 }
2222 
2223 ////////////////////////////////////////////////////////////////////////////////
2224 /// Read a TString
2225 
2227 {
2229 }
2230 
2231 ////////////////////////////////////////////////////////////////////////////////
2232 /// Write a TString
2233 
2235 {
2237 }
2238 
2239 ////////////////////////////////////////////////////////////////////////////////
2240 /// Read a std::string
2241 
2242 void TBufferSQL2::ReadStdString(std::string *s)
2243 {
2245 }
2246 
2247 ////////////////////////////////////////////////////////////////////////////////
2248 /// Write a std::string
2249 
2250 void TBufferSQL2::WriteStdString(const std::string *s)
2251 {
2253 }
2254 
2255 ////////////////////////////////////////////////////////////////////////////////
2256 /// Read a char* string
2257 
2259 {
2261 }
2262 
2263 ////////////////////////////////////////////////////////////////////////////////
2264 /// Write a char* string
2265 
2267 {
2269 }
2270 
2271 
2272 // macro for right shift operator for basic types
2273 #define TBufferSQL2_operatorout(vname) \
2274  { \
2275  SqlWriteBasic(vname); \
2276  }
2277 
2278 ////////////////////////////////////////////////////////////////////////////////
2279 /// Writes Bool_t value to buffer
2280 
2282 {
2284 }
2285 
2286 ////////////////////////////////////////////////////////////////////////////////
2287 /// Writes Char_t value to buffer
2288 
2290 {
2292 }
2293 
2294 ////////////////////////////////////////////////////////////////////////////////
2295 /// Writes UChar_t value to buffer
2296 
2298 {
2300 }
2301 
2302 ////////////////////////////////////////////////////////////////////////////////
2303 /// Writes Short_t value to buffer
2304 
2306 {
2308 }
2309 
2310 ////////////////////////////////////////////////////////////////////////////////
2311 /// Writes UShort_t value to buffer
2312 
2314 {
2316 }
2317 
2318 ////////////////////////////////////////////////////////////////////////////////
2319 /// Writes Int_t value to buffer
2320 
2322 {
2324 }
2325 
2326 ////////////////////////////////////////////////////////////////////////////////
2327 /// Writes UInt_t value to buffer
2328 
2330 {
2332 }
2333 
2334 ////////////////////////////////////////////////////////////////////////////////
2335 /// Writes Long_t value to buffer
2336 
2338 {
2340 }
2341 
2342 ////////////////////////////////////////////////////////////////////////////////
2343 /// Writes ULong_t value to buffer
2344 
2346 {
2348 }
2349 
2350 ////////////////////////////////////////////////////////////////////////////////
2351 /// Writes Long64_t value to buffer
2352 
2354 {
2356 }
2357 
2358 ////////////////////////////////////////////////////////////////////////////////
2359 /// Writes ULong64_t value to buffer
2360 
2362 {
2364 }
2365 
2366 ////////////////////////////////////////////////////////////////////////////////
2367 /// Writes Float_t value to buffer
2368 
2370 {
2372 }
2373 
2374 ////////////////////////////////////////////////////////////////////////////////
2375 /// Writes Double_t value to buffer
2376 
2378 {
2380 }
2381 
2382 ////////////////////////////////////////////////////////////////////////////////
2383 /// Writes array of characters to buffer
2384 
2386 {
2388 }
2389 
2390 ////////////////////////////////////////////////////////////////////////////////
2391 /// converts Char_t to string and creates correspondent sql structure
2392 
2394 {
2395  char buf[50];
2396  snprintf(buf, sizeof(buf), "%d", value);
2397  return SqlWriteValue(buf, sqlio::Char);
2398 }
2399 
2400 ////////////////////////////////////////////////////////////////////////////////
2401 /// converts Short_t to string and creates correspondent sql structure
2402 
2404 {
2405  char buf[50];
2406  snprintf(buf, sizeof(buf), "%hd", value);
2407  return SqlWriteValue(buf, sqlio::Short);
2408 }
2409 
2410 ////////////////////////////////////////////////////////////////////////////////
2411 /// converts Int_t to string and creates correspondent sql structure
2412 
2414 {
2415  char buf[50];
2416  snprintf(buf, sizeof(buf), "%d", value);
2417  return SqlWriteValue(buf, sqlio::Int);
2418 }
2419 
2420 ////////////////////////////////////////////////////////////////////////////////
2421 /// converts Long_t to string and creates correspondent sql structure
2422 
2424 {
2425  char buf[50];
2426  snprintf(buf, sizeof(buf), "%ld", value);
2427  return SqlWriteValue(buf, sqlio::Long);
2428 }
2429 
2430 ////////////////////////////////////////////////////////////////////////////////
2431 /// converts Long64_t to string and creates correspondent sql structure
2432 
2434 {
2435  char buf[50];
2436  snprintf(buf, sizeof(buf), "%lld", value);
2437  return SqlWriteValue(buf, sqlio::Long64);
2438 }
2439 
2440 ////////////////////////////////////////////////////////////////////////////////
2441 /// converts Float_t to string and creates correspondent sql structure
2442 
2444 {
2445  char buf[200];
2446  snprintf(buf, sizeof(buf), TSQLServer::GetFloatFormat(), value);
2447  return SqlWriteValue(buf, sqlio::Float);
2448 }
2449 
2450 ////////////////////////////////////////////////////////////////////////////////
2451 /// converts Double_t to string and creates correspondent sql structure
2452 
2454 {
2455  char buf[128];
2456  snprintf(buf, sizeof(buf), TSQLServer::GetFloatFormat(), value);
2457  return SqlWriteValue(buf, sqlio::Double);
2458 }
2459 
2460 ////////////////////////////////////////////////////////////////////////////////
2461 /// converts Bool_t to string and creates correspondent sql structure
2462 
2464 {
2466 }
2467 
2468 ////////////////////////////////////////////////////////////////////////////////
2469 /// converts UChar_t to string and creates correspondent sql structure
2470 
2472 {
2473  char buf[50];
2474  snprintf(buf, sizeof(buf), "%u", value);
2475  return SqlWriteValue(buf, sqlio::UChar);
2476 }
2477 
2478 ////////////////////////////////////////////////////////////////////////////////
2479 /// converts UShort_t to string and creates correspondent sql structure
2480 
2482 {
2483  char buf[50];
2484  snprintf(buf, sizeof(buf), "%hu", value);
2485  return SqlWriteValue(buf, sqlio::UShort);
2486 }
2487 
2488 ////////////////////////////////////////////////////////////////////////////////
2489 /// converts UInt_t to string and creates correspondent sql structure
2490 
2492 {
2493  char buf[50];
2494  snprintf(buf, sizeof(buf), "%u", value);
2495  return SqlWriteValue(buf, sqlio::UInt);
2496 }
2497 
2498 ////////////////////////////////////////////////////////////////////////////////
2499 /// converts ULong_t to string and creates correspondent sql structure
2500 
2502 {
2503  char buf[50];
2504  snprintf(buf, sizeof(buf), "%lu", value);
2505  return SqlWriteValue(buf, sqlio::ULong);
2506 }
2507 
2508 ////////////////////////////////////////////////////////////////////////////////
2509 /// converts ULong64_t to string and creates correspondent sql structure
2510 
2512 {
2513  char buf[50];
2514  snprintf(buf, sizeof(buf), FULong64, value);
2515  return SqlWriteValue(buf, sqlio::ULong64);
2516 }
2517 
2518 //______________________________________________________________________________
2519 
2520 Bool_t TBufferSQL2::SqlWriteValue(const char* value, const char* tname)
2521 {
2522  // create structure in stack, which holds specified value
2523 
2524  Stack()->AddValue(value, tname);
2525 
2526  return kTRUE;
2527 }
2528 
2529 ////////////////////////////////////////////////////////////////////////////////
2530 /// Read current value from table and convert it to Char_t value
2531 
2533 {
2534  const char* res = SqlReadValue(sqlio::Char);
2535  if (res) {
2536  int n;
2537  sscanf(res,"%d", &n);
2538  value = n;
2539  } else
2540  value = 0;
2541 }
2542 
2543 ////////////////////////////////////////////////////////////////////////////////
2544 /// Read current value from table and convert it to Short_t value
2545 
2547 {
2548  const char* res = SqlReadValue(sqlio::Short);
2549  if (res)
2550  sscanf(res,"%hd", &value);
2551  else
2552  value = 0;
2553 }
2554 
2555 ////////////////////////////////////////////////////////////////////////////////
2556 /// Read current value from table and convert it to Int_t value
2557 
2559 {
2560  const char* res = SqlReadValue(sqlio::Int);
2561  if (res)
2562  sscanf(res,"%d", &value);
2563  else
2564  value = 0;
2565 }
2566 
2567 ////////////////////////////////////////////////////////////////////////////////
2568 /// Read current value from table and convert it to Long_t value
2569 
2571 {
2572  const char* res = SqlReadValue(sqlio::Long);
2573  if (res)
2574  sscanf(res,"%ld", &value);
2575  else
2576  value = 0;
2577 }
2578 
2579 ////////////////////////////////////////////////////////////////////////////////
2580 /// Read current value from table and convert it to Long64_t value
2581 
2583 {
2584  const char* res = SqlReadValue(sqlio::Long64);
2585  if (res)
2586  sscanf(res, FLong64, &value);
2587  else
2588  value = 0;
2589 }
2590 
2591 ////////////////////////////////////////////////////////////////////////////////
2592 /// Read current value from table and convert it to Float_t value
2593 
2595 {
2596  const char* res = SqlReadValue(sqlio::Float);
2597  if (res)
2598  sscanf(res, "%f", &value);
2599  else
2600  value = 0.;
2601 }
2602 
2603 ////////////////////////////////////////////////////////////////////////////////
2604 /// Read current value from table and convert it to Double_t value
2605 
2607 {
2608  const char* res = SqlReadValue(sqlio::Double);
2609  if (res)
2610  sscanf(res, "%lf", &value);
2611  else
2612  value = 0.;
2613 }
2614 
2615 ////////////////////////////////////////////////////////////////////////////////
2616 /// Read current value from table and convert it to Bool_t value
2617 
2619 {
2620  const char* res = SqlReadValue(sqlio::Bool);
2621  if (res)
2622  value = (strcmp(res, sqlio::True)==0);
2623  else
2624  value = kFALSE;
2625 }
2626 
2627 ////////////////////////////////////////////////////////////////////////////////
2628 /// Read current value from table and convert it to UChar_t value
2629 
2631 {
2632  const char* res = SqlReadValue(sqlio::UChar);
2633  if (res) {
2634  unsigned int n;
2635  sscanf(res,"%ud", &n);
2636  value = n;
2637  } else
2638  value = 0;
2639 }
2640 
2641 ////////////////////////////////////////////////////////////////////////////////
2642 /// Read current value from table and convert it to UShort_t value
2643 
2645 {
2646  const char* res = SqlReadValue(sqlio::UShort);
2647  if (res)
2648  sscanf(res,"%hud", &value);
2649  else
2650  value = 0;
2651 }
2652 
2653 ////////////////////////////////////////////////////////////////////////////////
2654 /// Read current value from table and convert it to UInt_t value
2655 
2657 {
2658  const char* res = SqlReadValue(sqlio::UInt);
2659  if (res)
2660  sscanf(res,"%u", &value);
2661  else
2662  value = 0;
2663 }
2664 
2665 ////////////////////////////////////////////////////////////////////////////////
2666 /// Read current value from table and convert it to ULong_t value
2667 
2669 {
2670  const char* res = SqlReadValue(sqlio::ULong);
2671  if (res)
2672  sscanf(res,"%lu", &value);
2673  else
2674  value = 0;
2675 }
2676 
2677 ////////////////////////////////////////////////////////////////////////////////
2678 /// Read current value from table and convert it to ULong64_t value
2679 
2681 {
2682  const char* res = SqlReadValue(sqlio::ULong64);
2683  if (res)
2684  sscanf(res, FULong64, &value);
2685  else
2686  value = 0;
2687 }
2688 
2689 ////////////////////////////////////////////////////////////////////////////////
2690 /// Read string value from current stack node
2691 
2692 const char* TBufferSQL2::SqlReadValue(const char* tname)
2693 {
2694  if (fErrorFlag>0) return 0;
2695 
2696  if (fCurrentData==0) {
2697  Error("SqlReadValue","No object data to read from");
2698  fErrorFlag = 1;
2699  return 0;
2700  }
2701 
2702  if (!fIgnoreVerification)
2703  if (!fCurrentData->VerifyDataType(tname)) {
2704  fErrorFlag = 1;
2705  return 0;
2706  }
2707 
2709 
2711 
2712  if (gDebug>4)
2713  std::cout << " SqlReadValue " << tname << " = " << fReadBuffer << std::endl;
2714 
2715  return fReadBuffer.Data();
2716 }
2717 
2718 ////////////////////////////////////////////////////////////////////////////////
2719 /// Read CharStar value, if it has special code, request it from large table
2720 
2722 {
2723  const char* res = SqlReadValue(sqlio::CharStar);
2724  if ((res==0) || (fSQL==0)) return 0;
2725 
2726  Long64_t objid = Stack()->DefineObjectId(kTRUE);
2727 
2728  Int_t strid = fSQL->IsLongStringCode(objid, res);
2729  if (strid<=0) return res;
2730 
2731  fSQL->GetLongString(objid, strid, fReadBuffer);
2732 
2733  return fReadBuffer.Data();
2734 }
2735 
2736 
2737 ////////////////////////////////////////////////////////////////////////////////
2738 /// Push stack with structurual information about streamed object
2739 
2741 {
2742  TSQLStructure* res = new TSQLStructure;
2743  if (fStk==0) {
2744  fStructure = res;
2745  } else {
2746  fStk->Add(res);
2747  }
2748 
2749  fStk = res; // add in the stack
2750  return fStk;
2751 }
2752 
2753 ////////////////////////////////////////////////////////////////////////////////
2754 /// Pop stack
2755 
2757 {
2758  if (fStk==0) return 0;
2759  fStk = fStk->GetParent();
2760  return fStk;
2761 }
2762 
2763 ////////////////////////////////////////////////////////////////////////////////
2764 /// returns head of stack
2765 
2767 {
2768  TSQLStructure* curr = fStk;
2769  while ((depth-->0) && (curr!=0)) curr = curr->GetParent();
2770  return curr;
2771 }
2772 
2773 
2774 ////////////////////////////////////////////////////////////////////////////////
2775 /// set printf format for float/double members, default "%e"
2776 /// changes global TSQLServer variable
2777 
2778 void TBufferSQL2::SetFloatFormat(const char* fmt)
2779 {
2781 }
2782 
2783 ////////////////////////////////////////////////////////////////////////////////
2784 /// return current printf format for float/double members, default "%e"
2785 /// return format, hold by TSQLServer
2786 
2788 {
2789  return TSQLServer::GetFloatFormat();
2790 }
2791 
2792 ////////////////////////////////////////////////////////////////////////////////
2793 /// Read one collection of objects from the buffer using the StreamerInfoLoopAction.
2794 /// The collection needs to be a split TClonesArray or a split vector of pointers.
2795 
2797 {
2798  TVirtualStreamerInfo *info = sequence.fStreamerInfo;
2799  IncrementLevel(info);
2800 
2801  if (gDebug) {
2802  //loop on all active members
2803  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
2804  for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
2805  iter != end;
2806  ++iter) {
2807  // Idea: Try to remove this function call as it is really needed only for XML streaming.
2808  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem,(*iter).fConfiguration->fCompInfo->fType);
2809  (*iter).PrintDebug(*this,obj);
2810  (*iter)(*this,obj);
2811  }
2812 
2813  } else {
2814  //loop on all active members
2815  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
2816  for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
2817  iter != end;
2818  ++iter) {
2819  // Idea: Try to remove this function call as it is really needed only for XML streaming.
2820  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem,(*iter).fConfiguration->fCompInfo->fType);
2821  (*iter)(*this,obj);
2822  }
2823  }
2824 
2825  DecrementLevel(info);
2826  return 0;
2827 }
2828 
2829 ////////////////////////////////////////////////////////////////////////////////
2830 /// Read one collection of objects from the buffer using the StreamerInfoLoopAction.
2831 /// The collection needs to be a split TClonesArray or a split vector of pointers.
2832 
2833 Int_t TBufferSQL2::ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection)
2834 {
2835  TVirtualStreamerInfo *info = sequence.fStreamerInfo;
2836  IncrementLevel(info);
2837 
2838  if (gDebug) {
2839  //loop on all active members
2840  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
2841  for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
2842  iter != end;
2843  ++iter) {
2844  // Idea: Try to remove this function call as it is really needed only for XML streaming.
2845  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem,(*iter).fConfiguration->fCompInfo->fType);
2846  (*iter).PrintDebug(*this,*(char**)start_collection); // Warning: This limits us to TClonesArray and vector of pointers.
2847  (*iter)(*this,start_collection,end_collection);
2848  }
2849 
2850  } else {
2851  //loop on all active members
2852  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
2853  for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
2854  iter != end;
2855  ++iter) {
2856  // Idea: Try to remove this function call as it is really needed only for XML streaming.
2857  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem,(*iter).fConfiguration->fCompInfo->fType);
2858  (*iter)(*this,start_collection,end_collection);
2859  }
2860  }
2861 
2862  DecrementLevel(info);
2863  return 0;
2864 }
2865 
2866 ////////////////////////////////////////////////////////////////////////////////
2867 /// Read one collection of objects from the buffer using the StreamerInfoLoopAction.
2868 
2869 Int_t TBufferSQL2::ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection)
2870 {
2871  TVirtualStreamerInfo *info = sequence.fStreamerInfo;
2872  IncrementLevel(info);
2873 
2875  if (gDebug) {
2876 
2877  // Get the address of the first item for the PrintDebug.
2878  // (Performance is not essential here since we are going to print to
2879  // the screen anyway).
2880  void *arr0 = loopconfig->GetFirstAddress(start_collection,end_collection);
2881  // loop on all active members
2882  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
2883  for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
2884  iter != end;
2885  ++iter) {
2886  // Idea: Try to remove this function call as it is really needed only for XML streaming.
2887  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem,(*iter).fConfiguration->fCompInfo->fType);
2888  (*iter).PrintDebug(*this,arr0);
2889  (*iter)(*this,start_collection,end_collection,loopconfig);
2890  }
2891 
2892  } else {
2893  //loop on all active members
2894  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
2895  for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
2896  iter != end;
2897  ++iter) {
2898  // Idea: Try to remove this function call as it is really needed only for XML streaming.
2899  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem,(*iter).fConfiguration->fCompInfo->fType);
2900  (*iter)(*this,start_collection,end_collection,loopconfig);
2901  }
2902  }
2903 
2904  DecrementLevel(info);
2905  return 0;
2906 }
2907 
Describe Streamer information for one class version.
Definition: TStreamerInfo.h:43
virtual void IncrementLevel(TVirtualStreamerInfo *)
Function is called from TStreamerInfo WriteBuffer and Readbuffer functions and indent new level in da...
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
TSQLResult * GetBlobClassData(Long64_t objid, TSQLClassInfo *sqlinfo)
Method return request results for specified objid from streamer classtable.
Definition: TSQLFile.cxx:2486
void * SqlReadAny(Long64_t keyid, Long64_t objid, TClass **cl, void *obj=0)
Recreate object from sql structure.
virtual void ReadFastArrayDouble32(Double_t *d, Int_t n, TStreamerElement *ele=0)
Read array of Double32_t from buffer.
Bool_t IsReading() const
Definition: TBuffer.h:81
static Bool_t CanDelete()
static function returning true if ReadBuffer can delete object
XML object keeper class.
virtual void ReadFloat(Float_t &f)
Reads Float_t value from buffer.
void Add(ULong64_t hash, Long64_t key, Long64_t value)
Add an (key,value) pair to the table. The key should be unique.
Definition: TExMap.cxx:87
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)
Read version value from buffer actually version is normally defined by table name and kept in interme...
#define TBufferSQL2_ReadStaticArray(vname)
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:847
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket...
Definition: TBufferFile.h:47
Info (classname, version) about object in database.
TStreamerInfo * GetStreamerInfo() const
return TStreamerInfo* if type is kSqlStreamerInfo
long long Long64_t
Definition: RtypesCore.h:69
void ShiftToNextValue()
shift to next column or next row in blob data
const char * GetValue() const
TSQLResult * GetNormalClassDataAll(Long64_t minobjid, Long64_t maxobjid, TSQLClassInfo *sqlinfo)
Return data for several objects from the range from normal class table.
Definition: TSQLFile.cxx:2471
const char * GetObjClassName() const
short Version_t
Definition: RtypesCore.h:61
const char * GetClassTableName() const
Definition: TSQLClassInfo.h:61
virtual void WriteCharStar(char *s)
Write a char* string.
virtual TClass * GetClass() const =0
TLoopConfiguration * fLoopConfig
If this is a bundle of memberwise streaming action, this configures the looping.
virtual void ClassBegin(const TClass *, Version_t=-1)
This method inform buffer data of which class now will be streamed.
float Float_t
Definition: RtypesCore.h:53
virtual void WriteFastArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=0)
Write array of Double32_t to buffer.
TExMap * fObjMap
! Map between stored objects and object id
Definition: TBufferSQL2.h:39
void AddValue(const char *value, const char *tname=0)
Add child structure as value.
virtual void ReadFastArrayWithFactor(Float_t *ptr, Int_t n, Double_t factor, Double_t minvalue)
Read array of Float16_t from buffer.
virtual void ClassMember(const char *name, const char *typeName=0, Int_t arrsize1=-1, Int_t arrsize2=-1)
Method indicates name and typename of class memeber, which should be now streamed in custom streamer ...
const char * Int
virtual void WriteLong64(Long64_t l)
Writes Long64_t value to buffer.
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:329
#define TBufferSQL2_WriteFastArray(vname)
virtual void ReadLong64(Long64_t &l)
Reads Long64_t value from buffer.
virtual void ReadDouble32(Double_t *d, TStreamerElement *ele=0)
Read Double32 value.
virtual void ReadTString(TString &s)
Read a TString.
Int_t SqlWriteObject(const void *obj, const TClass *objClass, TMemberStreamer *streamer=0, Int_t streamer_index=0)
Write object to buffer.
static void SetFloatFormat(const char *fmt="%e")
set printf format for float/double members, default "%e" changes global TSQLServer variable ...
virtual void ReadTString(TString &s)
Read TString from TBuffer.
virtual void ReadFastArrayWithNbits(Float_t *ptr, Int_t n, Int_t nbits)
Read array of Float16_t from buffer.
unsigned short UShort_t
Definition: RtypesCore.h:36
TH1 * h
Definition: legend2.C:5
Int_t GetType() const
virtual void ReadFloat16(Float_t *f, TStreamerElement *ele=0)
Read Float16 value.
Int_t fCompressLevel
! compress level used to minimize size of data in database
Definition: TBufferSQL2.h:43
virtual void SkipVersion(const TClass *cl=0)
Skip class version from I/O buffer.
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection)...
Definition: TMap.cxx:53
Int_t IsLongStringCode(Long64_t objid, const char *value)
Checks if this is long string code returns 0, if not or string id.
Definition: TSQLFile.cxx:2257
#define gROOT
Definition: TROOT.h:375
Contains information about tables specific to one class and version.
Definition: TSQLClassInfo.h:44
virtual void ReadUShort(UShort_t &s)
Reads UShort_t value from buffer.
virtual void WriteObjectClass(const void *actualObjStart, const TClass *actualClass)
Write object to buffer. Only used from TBuffer.
const char * Long
Basic string class.
Definition: TString.h:129
virtual void WriteFastArrayFloat16(const Float_t *f, Int_t n, TStreamerElement *ele=0)
Write array of Float16_t to buffer.
virtual void ReadBool(Bool_t &b)
Reads Bool_t value from buffer.
virtual void WriteCharStar(char *s)
Write char* into TBuffer.
int Int_t
Definition: RtypesCore.h:41
const char * ObjectInst
#define TBufferSQL2_WriteArray(vname)
bool Bool_t
Definition: RtypesCore.h:59
Int_t fErrorFlag
! Error id value
Definition: TBufferSQL2.h:41
TSQLStructure * fStructure
! structures, created by object storing
Definition: TBufferSQL2.h:37
void SetParent(TObject *parent)
Set parent owning this buffer.
Definition: TBuffer.cxx:239
const char * Char
const char * Version
void SetObjectRef(Long64_t refid, const TClass *cl)
set structure type as kSqlObject
#define TBufferSQL2_ReadArray(tname, vname)
TSQLObjectData * SqlObjectData(Long64_t objid, TSQLClassInfo *sqlinfo)
Creates TSQLObjectData for specifed object id and specified class.
Type GetType(const std::string &Name)
Definition: Systematics.cxx:34
virtual void SetArrayDim(Int_t dim)
Set number of array dimensions.
virtual void WriteFastArray(const Bool_t *b, Int_t n)
Write array of Bool_t to buffer.
TObject * At(Int_t idx) const
Definition: TObjArray.h:165
const char * UShort
virtual void WriteUChar(UChar_t c)
Writes UChar_t value to buffer.
Bool_t IsBlobData() const
const char * UInt
Int_t SqlReadArraySize()
Reads array size, written in raw data table.
virtual void SetMaxIndex(Int_t dim, Int_t max)
set maximum index for array with dimension dim
Bool_t fIgnoreVerification
! ignore verification of names
Definition: TBufferSQL2.h:46
Int_t fReadVersionBuffer
! buffer, used to by ReadVersion method
Definition: TBufferSQL2.h:44
static const char * GetFloatFormat()
return current printf format for float/double members, default "%e"
Definition: TSQLServer.cxx:269
TSQLStructure * PushStack()
Push stack with structurual information about streamed object.
virtual void WriteStdString(const std::string *s)
Write a std::string.
void SetStreamerInfo(const TStreamerInfo *info)
set structure type as kSqlStreamerInfo
TSQLObjectData is used in TBufferSQL2 class in reading procedure.
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
Definition: TString.cxx:616
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:687
virtual void ReadUInt(UInt_t &i)
Reads UInt_t value from buffer.
void WorkWithElement(TStreamerElement *elem, Int_t comp_type)
This function is a part of SetStreamerElementNumber method.
virtual Int_t ReadArray(Bool_t *&b)
Read array of Bool_t from buffer.
#define FLong64
Definition: TBufferSQL2.cxx:59
virtual void ReadInt(Int_t &i)
Reads Int_t value from buffer.
void Add(TSQLStructure *child)
Add child strucure.
virtual void WriteDouble(Double_t d)
Writes Double_t value to buffer.
TObject * Last() const
Return the object in the last filled slot. Returns 0 if no entries.
Definition: TObjArray.cxx:479
static Bool_t UnpackTObject(TSQLFile *f, TBufferSQL2 *buf, TSQLObjectData *data, Long64_t objid, Int_t clversion)
Unpack TObject data in form, understodable by custom TObject streamer.
const char * True
virtual void * GetFirstAddress(void *start, const void *end) const =0
void SetStreamerElement(const TStreamerElement *elem, Int_t number)
set structure type as kSqlElement
void Class()
Definition: Class.C:29
virtual void ReadCharStar(char *&s)
Read char* from TBuffer.
TSQLFile * fSQL
! instance of TSQLFile
Definition: TBufferSQL2.h:36
virtual void WriteShort(Short_t s)
Writes Short_t value to buffer.
virtual void WriteBool(Bool_t b)
Writes Bool_t value to buffer.
virtual void WriteULong(ULong_t l)
Writes ULong_t value to buffer.
virtual void WriteStdString(const std::string *s)
Write std::string to TBuffer.
void * SqlReadObject(void *obj, TClass **cl=0, TMemberStreamer *streamer=0, Int_t streamer_index=0, const TClass *onFileClass=0)
Read object from the buffer.
This is hierarhical structure, which is created when data is written by TBufferSQL2.
virtual void WriteUShort(UShort_t s)
Writes UShort_t value to buffer.
virtual void Print(Option_t *option="") const
print content of complete structure
Bool_t IsClassTableExist() const
Definition: TSQLClassInfo.h:68
TStreamerElement * GetElement() const
return TStremerElement* if type is kSqlElement
virtual void ReadStdString(std::string *s)
Read std::string from TBuffer.
Base class of the Configurations for the member wise looping routines.
virtual void WriteClass(const TClass *cl)
Suppressed function of TBuffer.
virtual void WriteTString(const TString &s)
Write a TString.
Bool_t GetLongString(Long64_t objid, Int_t strid, TString &value)
Returns value of string, extracted from special table, where long strings are stored.
Definition: TSQLFile.cxx:2294
Bool_t SqlWriteBasic(Char_t value)
converts Char_t to string and creates correspondent sql structure
const char * UChar
const char * Float
virtual void WriteULong64(ULong64_t l)
Writes ULong64_t value to buffer.
Int_t LocateElementColumn(TSQLFile *f, TBufferSQL2 *buf, TSQLObjectData *data)
find column in TSQLObjectData object, which correspond to current element
virtual void WriteTString(const TString &s)
Write TString to TBuffer.
Int_t GetType() const
Definition: TDataType.h:68
virtual Int_t ReadStaticArrayDouble32(Double_t *d, TStreamerElement *ele=0)
Read array of Double32_t from buffer.
TBufferSQL2()
Default constructor, should not be used.
Definition: TBufferSQL2.cxx:68
static const char * GetFloatFormat()
return current printf format for float/double members, default "%e" return format, hold by TSQLServer
static Bool_t UnpackTString(TSQLFile *f, TBufferSQL2 *buf, TSQLObjectData *data, Long64_t objid, Int_t clversion)
Unpack TString data in form, understodable by custom TString streamer.
virtual void ReadCharP(Char_t *c)
Reads array of characters from buffer.
virtual void StreamObject(void *obj, const std::type_info &typeinfo, const TClass *onFileClass=0)
Stream object to/from buffer.
TSQLObjectData * GetObjectData(Bool_t search=false)
searchs for objects data
Int_t GetLast() const
Return index of last object in array.
Definition: TObjArray.cxx:528
virtual void WriteArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=0)
Write array of Double32_t to buffer.
Long64_t GetValue(ULong64_t hash, Long64_t key)
Return the value belonging to specified key and hash value.
Definition: TExMap.cxx:173
TSQLResult * GetClassData() const
Access an SQL db via the TFile interface.
Definition: TSQLFile.h:30
const char * Array
void SetCustomClass(const TClass *cl, Version_t version)
set structure type as kSqlCustomClass
Version_t GetObjVersion() const
Basic data type descriptor (datatype information is obtained from CINT).
Definition: TDataType.h:44
virtual void WriteLong(Long_t l)
Writes Long_t value to buffer.
TSQLStructure * fStk
! pointer on current active structure (stack head)
Definition: TBufferSQL2.h:38
void ChangeValueOnly(const char *value)
change value of this structure used as "workaround" to keep object id in kSqlElement node ...
TSQLClassInfo * FindSQLClassInfo(const char *clname, Int_t version)
Return (if exists) TSQLClassInfo for specified class name and version.
Definition: TSQLFile.cxx:1791
virtual Int_t ReadArrayFloat16(Float_t *&f, TStreamerElement *ele=0)
Read array of Float16_t from buffer.
TSQLStatement * GetBlobClassDataStmt(Long64_t objid, TSQLClassInfo *sqlinfo)
Method return request results for specified objid from streamer classtable Data returned in form of s...
Definition: TSQLFile.cxx:2503
Bool_t VerifyDataType(const char *tname, Bool_t errormsg=kTRUE)
checks if data type corresponds to that stored in raw table
static void SetFloatFormat(const char *fmt="%e")
set printf format for float/double members, default "%e"
Definition: TSQLServer.cxx:260
virtual Int_t ReadArrayDouble32(Double_t *&d, TStreamerElement *ele=0)
Read array of Double32_t from buffer.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2332
unsigned int UInt_t
Definition: RtypesCore.h:42
const char * GetBlobPrefixName() const
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:873
Ssiz_t Length() const
Definition: TString.h:388
Int_t Size() const
Return size of object of this class.
Definition: TClass.cxx:5348
const char * ULong
TSQLClassInfo * GetSqlInfo() const
TSQLStructure * Stack(Int_t depth=0)
returns head of stack
short Short_t
Definition: RtypesCore.h:35
TLine * l
Definition: textangle.C:4
const char * Double
TObjArray * SQLObjectsInfo(Long64_t keyid)
Produce array of TSQLObjectInfo objects for all objects, belong to that key Array should be deleted b...
Definition: TSQLFile.cxx:2394
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:71
void AddObjectData(TSQLObjectData *objdata)
add element with pointer to object data
virtual void WriteArray(const Bool_t *b, Int_t n)
Write array of Bool_t to buffer.
virtual TClass * ReadClass(const TClass *cl=0, UInt_t *objTag=0)
Suppressed function of TBuffer.
virtual Int_t ReadStaticArray(Bool_t *b)
Read array of Bool_t from buffer.
const char * GetLocatedField() const
TSQLRow * GetObjectRow(Long64_t objid)
Returns single sql row with object data for that class.
void Streamer(void *obj, TBuffer &b, const TClass *onfile_class=0) const
Definition: TClass.h:530
virtual void ClassEnd(const TClass *)
Method indicates end of streaming of classdata in custom streamer.
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
const Bool_t kFALSE
Definition: RtypesCore.h:92
virtual void ReadWithFactor(Float_t *ptr, Double_t factor, Double_t minvalue)
Read a Double32_t from the buffer when the factor and minimun value have been specified see comments ...
void SetCustomElement(TStreamerElement *elem)
set structure type as kSqlCustomElement
Bool_t PrepareForRawData()
prepare to read data from raw table
virtual void ReadFastArrayFloat16(Float_t *f, Int_t n, TStreamerElement *ele=0)
Read array of Float16_t from buffer.
Converts data to SQL statements or read data from SQL tables.
Definition: TBufferSQL2.h:30
long Long_t
Definition: RtypesCore.h:50
virtual void ReadDouble(Double_t &d)
Reads Double_t value from buffer.
Version_t GetClassVersion() const
Definition: TClass.h:372
virtual void ReadWithNbits(Float_t *ptr, Int_t nbits)
Read a Float16_t from the buffer when the number of bits is specified (explicitly or not) see comment...
#define FULong64
Definition: TBufferSQL2.cxx:60
#define ClassImp(name)
Definition: Rtypes.h:336
double f(double x)
void SqlReadBasic(Char_t &value)
Read current value from table and convert it to Char_t value.
void SetObjectPointer(Long64_t ptrid)
set structure type as kSqlPointer
void AddVersion(const TClass *cl, Int_t version=-100)
add child as version
double Double_t
Definition: RtypesCore.h:55
virtual void ReadStdString(std::string *s)
Read a std::string.
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:40
unsigned long long ULong64_t
Definition: RtypesCore.h:70
Int_t IndexOf(const TObject *obj) const
Definition: TObjArray.cxx:552
const char * SqlReadCharStarValue()
Read CharStar value, if it has special code, request it from large table.
unsigned long ULong_t
Definition: RtypesCore.h:51
const char * ObjectPtr
Bool_t SqlWriteValue(const char *value, const char *tname)
virtual void SkipObjectAny()
?????? Skip any kind of object from buffer !!!!!! fix me, not yet implemented Should be just skip of ...
virtual void WriteFloat(Float_t f)
Writes Float_t value to buffer.
void WorkWithClass(const char *classname, Version_t classversion)
This function is a part of IncrementLevel method.
virtual void WriteArrayFloat16(const Float_t *f, Int_t n, TStreamerElement *ele=0)
Write array of Float16_t to buffer.
virtual void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force)
force writing the TStreamerInfo to the file
virtual void WriteObject(const TObject *obj)
Write object to I/O buffer.
void SetCompressionLevel(int level)
Definition: TBufferSQL2.h:117
const char * ULong64
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:2885
virtual void WriteDouble32(Double_t *d, TStreamerElement *ele=0)
Write Double32 value.
virtual void ReadChar(Char_t &c)
Reads Char_t value from buffer.
const char * CharStar
const char * Bool
virtual void WriteInt(Int_t i)
Writes Int_t value to buffer.
Mother of all ROOT objects.
Definition: TObject.h:37
TObjArray * GetElements() const
#define TBufferSQL2_operatorin(vname)
char Char_t
Definition: RtypesCore.h:29
Int_t GetClassVersion() const
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Definition: TClass.cxx:5575
virtual void DecrementLevel(TVirtualStreamerInfo *)
Function is called from TStreamerInfo WriteBuffer and Readbuffer functions and decrease level in sql ...
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 ...
virtual void WriteObject(const TObject *obj)
Convert object into sql structures.
Definition: file.py:1
Long64_t DefineObjectId(Bool_t recursive=kTRUE)
defines current object id, to which this structure belong make life complicated, because some objects...
virtual void ReadShort(Short_t &s)
Reads Short_t value from buffer.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
#define snprintf
Definition: civetweb.c:822
Int_t fBufSize
Definition: TBuffer.h:47
R__EXTERN Int_t gDebug
Definition: Rtypes.h:83
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Definition: TMap.cxx:235
Int_t Atoi() const
Return integer value of string.
Definition: TString.cxx:1975
Long64_t fObjIdCounter
! counter of objects id
Definition: TBufferSQL2.h:45
virtual Int_t WriteObjectAny(const void *obj, const TClass *ptrClass)
Write object to I/O buffer.
virtual void * ReadObjectAny(const TClass *clCast)
Read object from buffer. Only used from TBuffer.
#define TBufferSQL2_operatorout(vname)
#define TBufferSQL2_ReadFastArray(vname)
void SetBaseVersion(Int_t v)
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)
Copies class version to buffer, but not writes it to sql immidiately Version will be used to produce ...
unsigned char UChar_t
Definition: RtypesCore.h:34
friend class TSQLStructure
Definition: TBufferSQL2.h:32
Long64_t GetObjId() const
virtual ~TBufferSQL2()
Destroy sql buffer.
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...
virtual void ReadULong(ULong_t &l)
Reads ULong_t value from buffer.
virtual void ReadULong64(ULong64_t &l)
Reads ULong64_t value from buffer.
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)
Suppressed function of TBuffer.
virtual void WriteCharP(const Char_t *c)
Writes array of characters to buffer.
Abstract Interface class describing Streamer information for one class.
virtual void ReadCharStar(char *&s)
Read a char* string.
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)
Suppressed function of TBuffer.
Long64_t fFirstObjId
! id of first object to be read from the database
Definition: TBufferSQL2.h:49
TString fReadBuffer
! Buffer for read value
Definition: TBufferSQL2.h:40
Long64_t fLastObjId
! id of last object correspond to this key
Definition: TBufferSQL2.h:50
const Bool_t kTRUE
Definition: RtypesCore.h:91
TObjArray * fObjectsInfos
! array of objects info for selected key
Definition: TBufferSQL2.h:48
virtual Int_t ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection)
Read one collection of objects from the buffer using the StreamerInfoLoopAction.
Bool_t fExpectedChain
! flag to resolve situation when several elements of same basic type stored as FastArray ...
Definition: TBufferSQL2.h:42
Int_t GetType() const
const char * ObjectRef
const Int_t n
Definition: legend1.C:16
virtual void WriteUInt(UInt_t i)
Writes UInt_t value to buffer.
TMap * fPoolsMap
! map of pools with data from different tables
Definition: TBufferSQL2.h:51
virtual void SetOnFileClass(const TClass *cl)
Int_t GetCompressionLevel() const
Definition: TFile.h:368
This class stores a (key,value) pair using an external hash.
Definition: TExMap.h:33
TSQLStructure * PopStack()
Pop stack.
void * SqlReadObjectDirect(void *obj, TClass **cl, Long64_t objid, TMemberStreamer *streamer=0, Int_t streamer_index=0, const TClass *onFileClass=0)
Read object data.
virtual Int_t ReadStaticArrayFloat16(Float_t *f, TStreamerElement *ele=0)
Read array of Float16_t from buffer.
virtual void ReadUChar(UChar_t &c)
Reads UChar_t value from buffer.
const char * Long64
TSQLStructure * GetParent() const
TSQLObjectData * fCurrentData
!
Definition: TBufferSQL2.h:47
const char * SqlReadValue(const char *tname)
Read string value from current stack node.
const char * False
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Definition: TString.cxx:1069
virtual void WriteFloat16(Float_t *f, TStreamerElement *ele=0)
Write Float16 value.
virtual void ReadFastArray(Bool_t *b, Int_t n)
Read array of Bool_t from buffer.
virtual Int_t ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *object)
Read one collection of objects from the buffer using the StreamerInfoLoopAction.
virtual void ReadLong(Long_t &l)
Reads Long_t value from buffer.
virtual void SetStreamerElementNumber(TStreamerElement *elem, Int_t comp_type)
Function is called from TStreamerInfo WriteBuffer and Readbuffer functions and add/verify next elemen...
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition: TClass.cxx:4706
const char * Data() const
Definition: TString.h:347
virtual void WriteChar(Char_t c)
Writes Char_t value to buffer.
TVirtualStreamerInfo * fStreamerInfo
StreamerInfo used to derive these actions.
const char * Short