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