ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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),
101  fExpectedChain(kFALSE),
102  fCompressLevel(0),
103  fReadVersionBuffer(-1),
104  fObjIdCounter(1),
105  fIgnoreVerification(kFALSE),
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),
130  fExpectedChain(kFALSE),
131  fCompressLevel(0),
132  fReadVersionBuffer(-1),
133  fObjIdCounter(1),
134  fIgnoreVerification(kFALSE),
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 
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() &&
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 
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 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 // macro for right shift operator for basic types
2256 #define TBufferSQL2_operatorout(vname) \
2257  { \
2258  SqlWriteBasic(vname); \
2259  }
2260 
2261 ////////////////////////////////////////////////////////////////////////////////
2262 /// Writes Bool_t value to buffer
2263 
2265 {
2267 }
2268 
2269 ////////////////////////////////////////////////////////////////////////////////
2270 /// Writes Char_t value to buffer
2271 
2273 {
2275 }
2276 
2277 ////////////////////////////////////////////////////////////////////////////////
2278 /// Writes UChar_t value to buffer
2279 
2281 {
2283 }
2284 
2285 ////////////////////////////////////////////////////////////////////////////////
2286 /// Writes Short_t value to buffer
2287 
2289 {
2291 }
2292 
2293 ////////////////////////////////////////////////////////////////////////////////
2294 /// Writes UShort_t value to buffer
2295 
2297 {
2299 }
2300 
2301 ////////////////////////////////////////////////////////////////////////////////
2302 /// Writes Int_t value to buffer
2303 
2305 {
2307 }
2308 
2309 ////////////////////////////////////////////////////////////////////////////////
2310 /// Writes UInt_t value to buffer
2311 
2313 {
2315 }
2316 
2317 ////////////////////////////////////////////////////////////////////////////////
2318 /// Writes Long_t value to buffer
2319 
2321 {
2323 }
2324 
2325 ////////////////////////////////////////////////////////////////////////////////
2326 /// Writes ULong_t value to buffer
2327 
2329 {
2331 }
2332 
2333 ////////////////////////////////////////////////////////////////////////////////
2334 /// Writes Long64_t value to buffer
2335 
2337 {
2339 }
2340 
2341 ////////////////////////////////////////////////////////////////////////////////
2342 /// Writes ULong64_t value to buffer
2343 
2345 {
2347 }
2348 
2349 ////////////////////////////////////////////////////////////////////////////////
2350 /// Writes Float_t value to buffer
2351 
2353 {
2355 }
2356 
2357 ////////////////////////////////////////////////////////////////////////////////
2358 /// Writes Double_t value to buffer
2359 
2361 {
2363 }
2364 
2365 ////////////////////////////////////////////////////////////////////////////////
2366 /// Writes array of characters to buffer
2367 
2369 {
2371 }
2372 
2373 ////////////////////////////////////////////////////////////////////////////////
2374 /// converts Char_t to string and creates correspondent sql structure
2375 
2377 {
2378  char buf[50];
2379  snprintf(buf, sizeof(buf), "%d", value);
2380  return SqlWriteValue(buf, sqlio::Char);
2381 }
2382 
2383 ////////////////////////////////////////////////////////////////////////////////
2384 /// converts Short_t to string and creates correspondent sql structure
2385 
2387 {
2388  char buf[50];
2389  snprintf(buf, sizeof(buf), "%hd", value);
2390  return SqlWriteValue(buf, sqlio::Short);
2391 }
2392 
2393 ////////////////////////////////////////////////////////////////////////////////
2394 /// converts Int_t to string and creates correspondent sql structure
2395 
2397 {
2398  char buf[50];
2399  snprintf(buf, sizeof(buf), "%d", value);
2400  return SqlWriteValue(buf, sqlio::Int);
2401 }
2402 
2403 ////////////////////////////////////////////////////////////////////////////////
2404 /// converts Long_t to string and creates correspondent sql structure
2405 
2407 {
2408  char buf[50];
2409  snprintf(buf, sizeof(buf), "%ld", value);
2410  return SqlWriteValue(buf, sqlio::Long);
2411 }
2412 
2413 ////////////////////////////////////////////////////////////////////////////////
2414 /// converts Long64_t to string and creates correspondent sql structure
2415 
2417 {
2418  char buf[50];
2419  snprintf(buf, sizeof(buf), "%lld", value);
2420  return SqlWriteValue(buf, sqlio::Long64);
2421 }
2422 
2423 ////////////////////////////////////////////////////////////////////////////////
2424 /// converts Float_t to string and creates correspondent sql structure
2425 
2427 {
2428  char buf[200];
2429  snprintf(buf, sizeof(buf), TSQLServer::GetFloatFormat(), value);
2430  return SqlWriteValue(buf, sqlio::Float);
2431 }
2432 
2433 ////////////////////////////////////////////////////////////////////////////////
2434 /// converts Double_t to string and creates correspondent sql structure
2435 
2437 {
2438  char buf[128];
2439  snprintf(buf, sizeof(buf), TSQLServer::GetFloatFormat(), value);
2440  return SqlWriteValue(buf, sqlio::Double);
2441 }
2442 
2443 ////////////////////////////////////////////////////////////////////////////////
2444 /// converts Bool_t to string and creates correspondent sql structure
2445 
2447 {
2449 }
2450 
2451 ////////////////////////////////////////////////////////////////////////////////
2452 /// converts UChar_t to string and creates correspondent sql structure
2453 
2455 {
2456  char buf[50];
2457  snprintf(buf, sizeof(buf), "%u", value);
2458  return SqlWriteValue(buf, sqlio::UChar);
2459 }
2460 
2461 ////////////////////////////////////////////////////////////////////////////////
2462 /// converts UShort_t to string and creates correspondent sql structure
2463 
2465 {
2466  char buf[50];
2467  snprintf(buf, sizeof(buf), "%hu", value);
2468  return SqlWriteValue(buf, sqlio::UShort);
2469 }
2470 
2471 ////////////////////////////////////////////////////////////////////////////////
2472 /// converts UInt_t to string and creates correspondent sql structure
2473 
2475 {
2476  char buf[50];
2477  snprintf(buf, sizeof(buf), "%u", value);
2478  return SqlWriteValue(buf, sqlio::UInt);
2479 }
2480 
2481 ////////////////////////////////////////////////////////////////////////////////
2482 /// converts ULong_t to string and creates correspondent sql structure
2483 
2485 {
2486  char buf[50];
2487  snprintf(buf, sizeof(buf), "%lu", value);
2488  return SqlWriteValue(buf, sqlio::ULong);
2489 }
2490 
2491 ////////////////////////////////////////////////////////////////////////////////
2492 /// converts ULong64_t to string and creates correspondent sql structure
2493 
2495 {
2496  char buf[50];
2497  snprintf(buf, sizeof(buf), FULong64, value);
2498  return SqlWriteValue(buf, sqlio::ULong64);
2499 }
2500 
2501 //______________________________________________________________________________
2502 
2503 Bool_t TBufferSQL2::SqlWriteValue(const char* value, const char* tname)
2504 {
2505  // create structure in stack, which holds specified value
2506 
2507  Stack()->AddValue(value, tname);
2508 
2509  return kTRUE;
2510 }
2511 
2512 ////////////////////////////////////////////////////////////////////////////////
2513 /// Read current value from table and convert it to Char_t value
2514 
2516 {
2517  const char* res = SqlReadValue(sqlio::Char);
2518  if (res) {
2519  int n;
2520  sscanf(res,"%d", &n);
2521  value = n;
2522  } else
2523  value = 0;
2524 }
2525 
2526 ////////////////////////////////////////////////////////////////////////////////
2527 /// Read current value from table and convert it to Short_t value
2528 
2530 {
2531  const char* res = SqlReadValue(sqlio::Short);
2532  if (res)
2533  sscanf(res,"%hd", &value);
2534  else
2535  value = 0;
2536 }
2537 
2538 ////////////////////////////////////////////////////////////////////////////////
2539 /// Read current value from table and convert it to Int_t value
2540 
2542 {
2543  const char* res = SqlReadValue(sqlio::Int);
2544  if (res)
2545  sscanf(res,"%d", &value);
2546  else
2547  value = 0;
2548 }
2549 
2550 ////////////////////////////////////////////////////////////////////////////////
2551 /// Read current value from table and convert it to Long_t value
2552 
2554 {
2555  const char* res = SqlReadValue(sqlio::Long);
2556  if (res)
2557  sscanf(res,"%ld", &value);
2558  else
2559  value = 0;
2560 }
2561 
2562 ////////////////////////////////////////////////////////////////////////////////
2563 /// Read current value from table and convert it to Long64_t value
2564 
2566 {
2567  const char* res = SqlReadValue(sqlio::Long64);
2568  if (res)
2569  sscanf(res, FLong64, &value);
2570  else
2571  value = 0;
2572 }
2573 
2574 ////////////////////////////////////////////////////////////////////////////////
2575 /// Read current value from table and convert it to Float_t value
2576 
2578 {
2579  const char* res = SqlReadValue(sqlio::Float);
2580  if (res)
2581  sscanf(res, "%f", &value);
2582  else
2583  value = 0.;
2584 }
2585 
2586 ////////////////////////////////////////////////////////////////////////////////
2587 /// Read current value from table and convert it to Double_t value
2588 
2590 {
2591  const char* res = SqlReadValue(sqlio::Double);
2592  if (res)
2593  sscanf(res, "%lf", &value);
2594  else
2595  value = 0.;
2596 }
2597 
2598 ////////////////////////////////////////////////////////////////////////////////
2599 /// Read current value from table and convert it to Bool_t value
2600 
2602 {
2603  const char* res = SqlReadValue(sqlio::Bool);
2604  if (res)
2605  value = (strcmp(res, sqlio::True)==0);
2606  else
2607  value = kFALSE;
2608 }
2609 
2610 ////////////////////////////////////////////////////////////////////////////////
2611 /// Read current value from table and convert it to UChar_t value
2612 
2614 {
2615  const char* res = SqlReadValue(sqlio::UChar);
2616  if (res) {
2617  unsigned int n;
2618  sscanf(res,"%ud", &n);
2619  value = n;
2620  } else
2621  value = 0;
2622 }
2623 
2624 ////////////////////////////////////////////////////////////////////////////////
2625 /// Read current value from table and convert it to UShort_t value
2626 
2628 {
2629  const char* res = SqlReadValue(sqlio::UShort);
2630  if (res)
2631  sscanf(res,"%hud", &value);
2632  else
2633  value = 0;
2634 }
2635 
2636 ////////////////////////////////////////////////////////////////////////////////
2637 /// Read current value from table and convert it to UInt_t value
2638 
2640 {
2641  const char* res = SqlReadValue(sqlio::UInt);
2642  if (res)
2643  sscanf(res,"%u", &value);
2644  else
2645  value = 0;
2646 }
2647 
2648 ////////////////////////////////////////////////////////////////////////////////
2649 /// Read current value from table and convert it to ULong_t value
2650 
2652 {
2653  const char* res = SqlReadValue(sqlio::ULong);
2654  if (res)
2655  sscanf(res,"%lu", &value);
2656  else
2657  value = 0;
2658 }
2659 
2660 ////////////////////////////////////////////////////////////////////////////////
2661 /// Read current value from table and convert it to ULong64_t value
2662 
2664 {
2665  const char* res = SqlReadValue(sqlio::ULong64);
2666  if (res)
2667  sscanf(res, FULong64, &value);
2668  else
2669  value = 0;
2670 }
2671 
2672 ////////////////////////////////////////////////////////////////////////////////
2673 /// Read string value from current stack node
2674 
2675 const char* TBufferSQL2::SqlReadValue(const char* tname)
2676 {
2677  if (fErrorFlag>0) return 0;
2678 
2679  if (fCurrentData==0) {
2680  Error("SqlReadValue","No object data to read from");
2681  fErrorFlag = 1;
2682  return 0;
2683  }
2684 
2685  if (!fIgnoreVerification)
2686  if (!fCurrentData->VerifyDataType(tname)) {
2687  fErrorFlag = 1;
2688  return 0;
2689  }
2690 
2692 
2694 
2695  if (gDebug>4)
2696  std::cout << " SqlReadValue " << tname << " = " << fReadBuffer << std::endl;
2697 
2698  return fReadBuffer.Data();
2699 }
2700 
2701 ////////////////////////////////////////////////////////////////////////////////
2702 /// Read CharStar value, if it has special code, request it from large table
2703 
2705 {
2706  const char* res = SqlReadValue(sqlio::CharStar);
2707  if ((res==0) || (fSQL==0)) return 0;
2708 
2709  Long64_t objid = Stack()->DefineObjectId(kTRUE);
2710 
2711  Int_t strid = fSQL->IsLongStringCode(objid, res);
2712  if (strid<=0) return res;
2713 
2714  fSQL->GetLongString(objid, strid, fReadBuffer);
2715 
2716  return fReadBuffer.Data();
2717 }
2718 
2719 
2720 ////////////////////////////////////////////////////////////////////////////////
2721 /// Push stack with structurual information about streamed object
2722 
2724 {
2725  TSQLStructure* res = new TSQLStructure;
2726  if (fStk==0) {
2727  fStructure = res;
2728  } else {
2729  fStk->Add(res);
2730  }
2731 
2732  fStk = res; // add in the stack
2733  return fStk;
2734 }
2735 
2736 ////////////////////////////////////////////////////////////////////////////////
2737 /// Pop stack
2738 
2740 {
2741  if (fStk==0) return 0;
2742  fStk = fStk->GetParent();
2743  return fStk;
2744 }
2745 
2746 ////////////////////////////////////////////////////////////////////////////////
2747 /// returns head of stack
2748 
2750 {
2751  TSQLStructure* curr = fStk;
2752  while ((depth-->0) && (curr!=0)) curr = curr->GetParent();
2753  return curr;
2754 }
2755 
2756 
2757 ////////////////////////////////////////////////////////////////////////////////
2758 /// set printf format for float/double members, default "%e"
2759 /// changes global TSQLServer variable
2760 
2761 void TBufferSQL2::SetFloatFormat(const char* fmt)
2762 {
2764 }
2765 
2766 ////////////////////////////////////////////////////////////////////////////////
2767 /// return current printf format for float/double members, default "%e"
2768 /// return format, hold by TSQLServer
2769 
2771 {
2772  return TSQLServer::GetFloatFormat();
2773 }
2774 
2775 ////////////////////////////////////////////////////////////////////////////////
2776 /// Read one collection of objects from the buffer using the StreamerInfoLoopAction.
2777 /// The collection needs to be a split TClonesArray or a split vector of pointers.
2778 
2780 {
2781  TVirtualStreamerInfo *info = sequence.fStreamerInfo;
2782  IncrementLevel(info);
2783 
2784  if (gDebug) {
2785  //loop on all active members
2786  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
2787  for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
2788  iter != end;
2789  ++iter) {
2790  // Idea: Try to remove this function call as it is really needed only for XML streaming.
2791  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem,(*iter).fConfiguration->fCompInfo->fType);
2792  (*iter).PrintDebug(*this,obj);
2793  (*iter)(*this,obj);
2794  }
2795 
2796  } else {
2797  //loop on all active members
2798  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
2799  for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
2800  iter != end;
2801  ++iter) {
2802  // Idea: Try to remove this function call as it is really needed only for XML streaming.
2803  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem,(*iter).fConfiguration->fCompInfo->fType);
2804  (*iter)(*this,obj);
2805  }
2806  }
2807 
2808  DecrementLevel(info);
2809  return 0;
2810 }
2811 
2812 ////////////////////////////////////////////////////////////////////////////////
2813 /// Read one collection of objects from the buffer using the StreamerInfoLoopAction.
2814 /// The collection needs to be a split TClonesArray or a split vector of pointers.
2815 
2816 Int_t TBufferSQL2::ApplySequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection)
2817 {
2818  TVirtualStreamerInfo *info = sequence.fStreamerInfo;
2819  IncrementLevel(info);
2820 
2821  if (gDebug) {
2822  //loop on all active members
2823  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
2824  for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
2825  iter != end;
2826  ++iter) {
2827  // Idea: Try to remove this function call as it is really needed only for XML streaming.
2828  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem,(*iter).fConfiguration->fCompInfo->fType);
2829  (*iter).PrintDebug(*this,*(char**)start_collection); // Warning: This limits us to TClonesArray and vector of pointers.
2830  (*iter)(*this,start_collection,end_collection);
2831  }
2832 
2833  } else {
2834  //loop on all active members
2835  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
2836  for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
2837  iter != end;
2838  ++iter) {
2839  // Idea: Try to remove this function call as it is really needed only for XML streaming.
2840  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem,(*iter).fConfiguration->fCompInfo->fType);
2841  (*iter)(*this,start_collection,end_collection);
2842  }
2843  }
2844 
2845  DecrementLevel(info);
2846  return 0;
2847 }
2848 
2849 ////////////////////////////////////////////////////////////////////////////////
2850 /// Read one collection of objects from the buffer using the StreamerInfoLoopAction.
2851 
2852 Int_t TBufferSQL2::ApplySequence(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection)
2853 {
2854  TVirtualStreamerInfo *info = sequence.fStreamerInfo;
2855  IncrementLevel(info);
2856 
2858  if (gDebug) {
2859 
2860  // Get the address of the first item for the PrintDebug.
2861  // (Performance is not essential here since we are going to print to
2862  // the screen anyway).
2863  void *arr0 = loopconfig->GetFirstAddress(start_collection,end_collection);
2864  // loop on all active members
2865  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
2866  for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
2867  iter != end;
2868  ++iter) {
2869  // Idea: Try to remove this function call as it is really needed only for XML streaming.
2870  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem,(*iter).fConfiguration->fCompInfo->fType);
2871  (*iter).PrintDebug(*this,arr0);
2872  (*iter)(*this,start_collection,end_collection,loopconfig);
2873  }
2874 
2875  } else {
2876  //loop on all active members
2877  TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
2878  for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
2879  iter != end;
2880  ++iter) {
2881  // Idea: Try to remove this function call as it is really needed only for XML streaming.
2882  SetStreamerElementNumber((*iter).fConfiguration->fCompInfo->fElem,(*iter).fConfiguration->fCompInfo->fType);
2883  (*iter)(*this,start_collection,end_collection,loopconfig);
2884  }
2885  }
2886 
2887  DecrementLevel(info);
2888  return 0;
2889 }
2890 
Describe Streamer information for one class version.
Definition: TStreamerInfo.h:47
virtual void IncrementLevel(TVirtualStreamerInfo *)
Function is called from TStreamerInfo WriteBuffer and Readbuffer functions and indent new level in da...
TSQLResult * GetBlobClassData(Long64_t objid, TSQLClassInfo *sqlinfo)
Method return request results for specified objid from streamer classtable.
Definition: TSQLFile.cxx:2485
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.
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)
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket...
Definition: TBufferFile.h:51
Info (classname, version) about object in database.
TStreamerInfo * GetStreamerInfo() const
return TStreamerInfo* if type is kSqlStreamerInfo
long long Long64_t
Definition: RtypesCore.h:69
TSQLResult * GetClassData() const
void ShiftToNextValue()
shift to next column or next row in blob data
Bool_t IsReading() const
Definition: TBuffer.h:83
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:2470
short Version_t
Definition: RtypesCore.h:61
Int_t GetType() const
Definition: TDataType.h:70
Ssiz_t Length() const
Definition: TString.h:390
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:45
Int_t GetLast() const
Return index of last object in array.
Definition: TObjArray.cxx:528
Version_t GetObjVersion() const
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.
return c
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 ...
TSQLStructure * GetParent() const
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
Bool_t IsClassTableExist() const
Definition: TSQLClassInfo.h:72
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Definition: TClass.cxx:5462
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:892
virtual void ReadFloat16(Float_t *f, TStreamerElement *ele=0)
Read Float16 value.
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:2256
#define gROOT
Definition: TROOT.h:344
Contains information about tables specific to one class and version.
Definition: TSQLClassInfo.h:48
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:137
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.
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:47
const Bool_t kFALSE
Definition: Rtypes.h:92
TSQLStructure * fStructure
! structures, created by object storing
Definition: TBufferSQL2.h:43
void SetParent(TObject *parent)
Set parent owning this buffer.
Definition: TBuffer.cxx:237
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.
const char * UShort
virtual void ReadStdString(std::string &s)
Read a std::string.
virtual void WriteUChar(UChar_t c)
Writes UChar_t value to buffer.
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:52
Int_t fReadVersionBuffer
! buffer, used to by ReadVersion method
Definition: TBufferSQL2.h:50
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.
TFile * f
void SetStreamerInfo(const TStreamerInfo *info)
set structure type as kSqlStreamerInfo
TSQLObjectData is used in TBufferSQL2 class in reading procedure.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:732
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.
const char * Data() const
Definition: TString.h:349
void Add(TSQLStructure *child)
Add child strucure.
virtual void WriteDouble(Double_t d)
Writes Double_t value to buffer.
virtual Int_t GetClassVersion() const =0
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
Int_t GetCompressionLevel() const
Definition: TFile.h:357
void Class()
Definition: Class.C:29
TSQLFile * fSQL
! instance of TSQLFile
Definition: TBufferSQL2.h:42
int d
Definition: tornado.py:11
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition: TClass.cxx:4602
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.
void * SqlReadObject(void *obj, TClass **cl=0, TMemberStreamer *streamer=0, Int_t streamer_index=0, const TClass *onFileClass=0)
Read object from the buffer.
std::map< std::string, std::string >::const_iterator iter
Definition: TAlienJob.cxx:54
This is hierarhical structure, which is created when data is written by TBufferSQL2.
TSQLClassInfo * GetSqlInfo() const
const char * GetBlobPrefixName() const
virtual void WriteUShort(UShort_t s)
Writes UShort_t value to buffer.
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:1951
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
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:2293
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.
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.
TSQLObjectData * GetObjectData(Bool_t search=false)
searchs for objects data
virtual void WriteArrayDouble32(const Double_t *d, Int_t n, TStreamerElement *ele=0)
Write array of Double32_t to buffer.
Int_t IndexOf(const TObject *obj) const
Definition: TObjArray.cxx:552
Int_t GetType() const
Long64_t GetValue(ULong64_t hash, Long64_t key)
Return the value belonging to specified key and hash value.
Definition: TExMap.cxx:173
TObjArray * GetElements() const
Access an SQL db via the TFile interface.
Definition: TSQLFile.h:32
const char * Array
const char * GetObjClassName() const
void SetCustomClass(const TClass *cl, Version_t version)
set structure type as kSqlCustomClass
Basic data type descriptor (datatype information is obtained from CINT).
Definition: TDataType.h:46
virtual void WriteLong(Long_t l)
Writes Long_t value to buffer.
virtual void ReadStdString(std::string &s)
Read std::string from TBuffer.
TSQLStructure * fStk
! pointer on current active structure (stack head)
Definition: TBufferSQL2.h:44
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:1790
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:2502
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:2308
unsigned int UInt_t
Definition: RtypesCore.h:42
const char * ULong
TSQLStructure * Stack(Int_t depth=0)
returns head of stack
short Short_t
Definition: RtypesCore.h:35
TLine * l
Definition: textangle.C:4
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
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:2393
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
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.
Bool_t IsBlobData() const
Version_t GetClassVersion() const
Definition: TClass.h:381
ClassImp(TBufferSQL2)
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.
TSQLRow * GetObjectRow(Long64_t objid)
Returns single sql row with object data for that class.
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
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:36
long Long_t
Definition: RtypesCore.h:50
virtual void ReadDouble(Double_t &d)
Reads Double_t value from buffer.
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
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
const char * GetLocatedField() const
tuple file
Definition: fildir.py:20
const char * GetValue() const
Long64_t GetObjId() const
double Double_t
Definition: RtypesCore.h:55
const char * GetClassTableName() const
Definition: TSQLClassInfo.h:65
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition: TMap.h:44
unsigned long long ULong64_t
Definition: RtypesCore.h:70
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)
TStreamerElement * GetElement() const
return TStremerElement* if type is kSqlElement
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:123
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:2801
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
#define name(a, b)
Definition: linkTestLib0.cpp:5
const char * Bool
virtual void WriteInt(Int_t i)
Writes Int_t value to buffer.
Mother of all ROOT objects.
Definition: TObject.h:58
#define TBufferSQL2_operatorin(vname)
char Char_t
Definition: RtypesCore.h:29
TObject * Last() const
Return the object in the last filled slot. Returns 0 if no entries.
Definition: TObjArray.cxx:479
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.
tuple obj1
Definition: fildir.py:72
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.
virtual void WriteStdString(const std::string &s)
Write std::string to TBuffer.
Int_t fBufSize
Definition: TBuffer.h:49
Int_t GetType() const
R__EXTERN Int_t gDebug
Definition: Rtypes.h:128
Long64_t fObjIdCounter
! counter of objects id
Definition: TBufferSQL2.h:51
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:38
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.
TObject * At(Int_t idx) const
Definition: TObjArray.h:167
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)
Suppressed function of TBuffer.
void Streamer(void *obj, TBuffer &b, const TClass *onfile_class=0) const
Definition: TClass.h:539
virtual void WriteStdString(const std::string &s)
Write a std::string.
virtual void WriteCharP(const Char_t *c)
Writes array of characters to buffer.
Abstract Interface class describing Streamer information for one class.
const Bool_t kTRUE
Definition: Rtypes.h:91
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:55
TString fReadBuffer
! Buffer for read value
Definition: TBufferSQL2.h:46
TObject * obj
Long64_t fLastObjId
! id of last object correspond to this key
Definition: TBufferSQL2.h:56
float value
Definition: math.cpp:443
TObjArray * fObjectsInfos
! array of objects info for selected key
Definition: TBufferSQL2.h:54
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:48
const char * ObjectRef
const Int_t n
Definition: legend1.C:16
virtual void Print(Option_t *option="") const
print content of complete structure
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:57
virtual void SetOnFileClass(const TClass *cl)
Int_t Size() const
Return size of object of this class.
Definition: TClass.cxx:5243
This class stores a (key,value) pair using an external hash.
Definition: TExMap.h:35
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
TSQLObjectData * fCurrentData
!
Definition: TBufferSQL2.h:53
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:1045
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...
virtual void StreamObject(void *obj, const type_info &typeinfo, const TClass *onFileClass=0)
Stream object to/from buffer.
virtual void WriteChar(Char_t c)
Writes Char_t value to buffer.
TVirtualStreamerInfo * fStreamerInfo
StreamerInfo used to derive these actions.
const char * Short
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
Definition: TString.cxx:592