00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "TBufferSQL2.h"
00024
00025 #include "TObjArray.h"
00026 #include "TROOT.h"
00027 #include "TDataType.h"
00028 #include "TClass.h"
00029 #include "TClassTable.h"
00030 #include "TMap.h"
00031 #include "TExMap.h"
00032 #include "TMethodCall.h"
00033 #include "TStreamerInfo.h"
00034 #include "TStreamerElement.h"
00035 #include "TProcessID.h"
00036 #include "TFile.h"
00037 #include "TMemberStreamer.h"
00038 #include "TStreamer.h"
00039 #include "Riostream.h"
00040 #include <stdlib.h>
00041 #include "TStreamerInfoActions.h"
00042
00043 #include "TSQLServer.h"
00044 #include "TSQLResult.h"
00045 #include "TSQLRow.h"
00046 #include "TSQLStructure.h"
00047 #include "TSQLObjectData.h"
00048 #include "TSQLFile.h"
00049 #include "TSQLClassInfo.h"
00050
00051 #ifdef R__VISUAL_CPLUSPLUS
00052 #define FLong64 "%I64d"
00053 #define FULong64 "%I64u"
00054 #else
00055 #define FLong64 "%lld"
00056 #define FULong64 "%llu"
00057 #endif
00058
00059 ClassImp(TBufferSQL2);
00060
00061
00062 TBufferSQL2::TBufferSQL2() :
00063 TBufferFile(),
00064 fSQL(0),
00065 fStructure(0),
00066 fStk(0),
00067 fObjMap(0),
00068 fReadBuffer(),
00069 fErrorFlag(0),
00070 fExpectedChain(kFALSE),
00071 fCompressLevel(0),
00072 fReadVersionBuffer(-1),
00073 fObjIdCounter(1),
00074 fIgnoreVerification(kFALSE),
00075 fObjectsInfos(0),
00076 fFirstObjId(0),
00077 fLastObjId(0),
00078 fPoolsMap(0)
00079 {
00080
00081 }
00082
00083
00084 TBufferSQL2::TBufferSQL2(TBuffer::EMode mode) :
00085 TBufferFile(mode),
00086 fSQL(0),
00087 fStructure(0),
00088 fStk(0),
00089 fObjMap(0),
00090 fReadBuffer(),
00091 fErrorFlag(0),
00092 fExpectedChain(kFALSE),
00093 fCompressLevel(0),
00094 fReadVersionBuffer(-1),
00095 fObjIdCounter(1),
00096 fIgnoreVerification(kFALSE),
00097 fObjectsInfos(0),
00098 fFirstObjId(0),
00099 fLastObjId(0),
00100 fPoolsMap(0)
00101 {
00102
00103
00104
00105 SetParent(0);
00106 SetBit(kCannotHandleMemberWiseStreaming);
00107 SetBit(kTextBasedStreaming);
00108 }
00109
00110
00111 TBufferSQL2::TBufferSQL2(TBuffer::EMode mode, TSQLFile* file) :
00112 TBufferFile(mode),
00113 fSQL(0),
00114 fStructure(0),
00115 fStk(0),
00116 fObjMap(0),
00117 fReadBuffer(),
00118 fErrorFlag(0),
00119 fExpectedChain(kFALSE),
00120 fCompressLevel(0),
00121 fReadVersionBuffer(-1),
00122 fObjIdCounter(1),
00123 fIgnoreVerification(kFALSE),
00124 fObjectsInfos(0),
00125 fFirstObjId(0),
00126 fLastObjId(0),
00127 fPoolsMap(0)
00128 {
00129
00130
00131
00132
00133 fBufSize = 1000000000;
00134
00135
00136 SetBit(kCannotHandleMemberWiseStreaming);
00137 SetBit(kTextBasedStreaming);
00138
00139 SetParent(file);
00140 fSQL = file;
00141 if (file!=0)
00142 SetCompressionLevel(file->GetCompressionLevel());
00143 }
00144
00145
00146 TBufferSQL2::~TBufferSQL2()
00147 {
00148
00149 if (fObjMap) delete fObjMap;
00150
00151 if (fStructure!=0) {
00152 delete fStructure;
00153 fStructure = 0;
00154 }
00155
00156 if (fObjectsInfos!=0) {
00157 fObjectsInfos->Delete();
00158 delete fObjectsInfos;
00159 }
00160
00161 if (fPoolsMap!=0) {
00162 fPoolsMap->DeleteValues();
00163 delete fPoolsMap;
00164 }
00165 }
00166
00167
00168 TSQLStructure* TBufferSQL2::SqlWriteAny(const void* obj, const TClass* cl, Long64_t objid)
00169 {
00170
00171
00172
00173
00174 fErrorFlag = 0;
00175
00176 fStructure = 0;
00177
00178 fFirstObjId = objid;
00179 fObjIdCounter = objid;
00180
00181 SqlWriteObject(obj, cl);
00182
00183 if (gDebug>3)
00184 if (fStructure!=0) {
00185 cout << "==== Printout of Sql structures ===== " << endl;
00186 fStructure->Print("*");
00187 cout << "=========== End printout ============ " << endl;
00188 }
00189
00190 return fStructure;
00191 }
00192
00193
00194 void* TBufferSQL2::SqlReadAny(Long64_t keyid, Long64_t objid, TClass** cl, void* obj)
00195 {
00196
00197
00198
00199
00200 if (cl) *cl = 0;
00201 if (fSQL==0) return 0;
00202
00203 fCurrentData = 0;
00204 fErrorFlag = 0;
00205
00206 fReadVersionBuffer = -1;
00207
00208 fObjectsInfos = fSQL->SQLObjectsInfo(keyid);
00209
00210 fFirstObjId = objid;
00211 fLastObjId = objid;
00212 if (fObjectsInfos!=0) {
00213 TSQLObjectInfo* objinfo = (TSQLObjectInfo*) fObjectsInfos->Last();
00214 if (objinfo!=0) fLastObjId = objinfo->GetObjId();
00215 }
00216
00217 return SqlReadObjectDirect(obj, cl, objid);
00218 }
00219
00220
00221 Bool_t TBufferSQL2::SqlObjectInfo(Long64_t objid, TString& clname, Version_t& version)
00222 {
00223
00224
00225
00226 if ((objid<0) || (fObjectsInfos==0)) return kFALSE;
00227
00228
00229
00230
00231
00232 Long64_t shift = objid - fFirstObjId;
00233
00234 TSQLObjectInfo* info = 0;
00235 if ((shift>=0) && (shift<=fObjectsInfos->GetLast())) {
00236 info = (TSQLObjectInfo*) fObjectsInfos->At(shift);
00237 if (info->GetObjId()!=objid) info = 0;
00238 }
00239
00240 if (info==0) {
00241
00242 Info("SqlObjectInfo", "Standard not works %lld", objid);
00243 for (Int_t n=0;n<=fObjectsInfos->GetLast();n++) {
00244 info = (TSQLObjectInfo*) fObjectsInfos->At(n);
00245 if (info->GetObjId()==objid) break;
00246 info = 0;
00247 }
00248 }
00249
00250 if (info==0) return kFALSE;
00251
00252 clname = info->GetObjClassName();
00253 version = info->GetObjVersion();
00254 return kTRUE;
00255 }
00256
00257
00258
00259 TSQLObjectData* TBufferSQL2::SqlObjectData(Long64_t objid, TSQLClassInfo* sqlinfo)
00260 {
00261
00262
00263
00264
00265
00266
00267
00268
00269 TSQLResult *classdata = 0;
00270 TSQLRow *classrow = 0;
00271
00272 if (sqlinfo->IsClassTableExist()) {
00273
00274 TSQLObjectDataPool* pool = 0;
00275
00276 if (fPoolsMap!=0)
00277 pool = (TSQLObjectDataPool*) fPoolsMap->GetValue(sqlinfo);
00278
00279 if ((pool==0) && (fLastObjId>=fFirstObjId)) {
00280 if (gDebug>4) Info("SqlObjectData","Before request to %s",sqlinfo->GetClassTableName());
00281 TSQLResult *alldata = fSQL->GetNormalClassDataAll(fFirstObjId, fLastObjId, sqlinfo);
00282 if (gDebug>4) Info("SqlObjectData","After request res = 0x%lx",(Long_t)alldata);
00283 if (alldata==0) {
00284 Error("SqlObjectData","Cannot get data from table %s",sqlinfo->GetClassTableName());
00285 return 0;
00286 }
00287
00288 if (fPoolsMap==0) fPoolsMap = new TMap();
00289 pool = new TSQLObjectDataPool(sqlinfo, alldata);
00290 fPoolsMap->Add(sqlinfo, pool);
00291 }
00292
00293 if (pool==0) return 0;
00294
00295 if (pool->GetSqlInfo()!=sqlinfo) {
00296 Error("SqlObjectData","Missmatch in pools map !!! CANNOT BE !!!");
00297 return 0;
00298 }
00299
00300 classdata = pool->GetClassData();
00301
00302 classrow = pool->GetObjectRow(objid);
00303 if (classrow==0) {
00304 Error("SqlObjectData","Can not find row for objid = %lld in table %s", objid, sqlinfo->GetClassTableName());
00305 return 0;
00306 }
00307 }
00308
00309 TSQLResult *blobdata = 0;
00310 TSQLStatement* blobstmt = fSQL->GetBlobClassDataStmt(objid, sqlinfo);
00311
00312 if (blobstmt==0) blobdata = fSQL->GetBlobClassData(objid, sqlinfo);
00313
00314 return new TSQLObjectData(sqlinfo, objid, classdata, classrow, blobdata, blobstmt);
00315 }
00316
00317
00318 void TBufferSQL2::WriteObject(const TObject *obj)
00319 {
00320
00321
00322
00323
00324
00325 TBufferFile::WriteObject(obj);
00326 }
00327
00328
00329 Int_t TBufferSQL2::SqlWriteObject(const void* obj, const TClass* cl, TMemberStreamer *streamer, Int_t streamer_index)
00330 {
00331
00332
00333
00334
00335 if (gDebug>1)
00336 cout << " SqlWriteObject " << obj << " : cl = " << (cl ? cl->GetName() : "null") << endl;
00337
00338 PushStack();
00339
00340 Long64_t objid = -1;
00341
00342 if (cl==0) obj = 0;
00343
00344 if (obj==0)
00345 objid = 0;
00346 else
00347 if (fObjMap!=0) {
00348 ULong_t hash = TString::Hash(&obj, sizeof(void*));
00349 Long_t value = fObjMap->GetValue(hash, (Long_t) obj);
00350 if (value>0)
00351 objid = fFirstObjId + value - 1;
00352 }
00353
00354 if (gDebug>1)
00355 cout << " Find objectid = " << objid << endl;
00356
00357 if (objid>=0) {
00358 Stack()->SetObjectPointer(objid);
00359 PopStack();
00360 return objid;
00361 }
00362
00363 objid = fObjIdCounter++;
00364
00365 Stack()->SetObjectRef(objid, cl);
00366
00367 ULong_t hash = TString::Hash(&obj, sizeof(void*));
00368 if (fObjMap==0) fObjMap = new TExMap();
00369 if (fObjMap->GetValue(hash, (Long_t) obj)==0)
00370 fObjMap->Add(hash, (Long_t) obj, (Long_t) objid - fFirstObjId + 1);
00371
00372 if (streamer!=0)
00373 (*streamer)(*this, (void*) obj, streamer_index);
00374 else
00375 ((TClass*)cl)->Streamer((void*)obj, *this);
00376
00377 if (gDebug>1)
00378 cout << "Done write of " << cl->GetName() << endl;
00379
00380 PopStack();
00381
00382 return objid;
00383 }
00384
00385
00386 void* TBufferSQL2::SqlReadObject(void* obj, TClass** cl, TMemberStreamer *streamer, Int_t streamer_index, const TClass *onFileClass)
00387 {
00388
00389
00390 if (cl) *cl = 0;
00391
00392 if (fErrorFlag>0) return obj;
00393
00394 Bool_t findptr = kFALSE;
00395
00396 const char* refid = fCurrentData->GetValue();
00397 if ((refid==0) || (strlen(refid)==0)) {
00398 Error("SqlReadObject","Invalid object reference value");
00399 fErrorFlag = 1;
00400 return obj;
00401 }
00402
00403 Long64_t objid = -1;
00404 sscanf(refid, FLong64, &objid);
00405
00406 if (gDebug>2)
00407 Info("SqlReadObject","Starting objid = %lld column=%s", objid, fCurrentData->GetLocatedField());
00408
00409 if (!fCurrentData->IsBlobData() ||
00410 fCurrentData->VerifyDataType(sqlio::ObjectPtr,kFALSE)) {
00411 if (objid==0) {
00412 obj = 0;
00413 findptr = kTRUE;
00414 } else {
00415 if (objid==-1) {
00416 findptr = kTRUE;
00417 } else {
00418 if ((fObjMap!=0) && (objid>=fFirstObjId)) {
00419 void* obj1 = (void*) (Long_t)fObjMap->GetValue((Long_t) objid - fFirstObjId);
00420 if (obj1!=0) {
00421 obj = obj1;
00422 findptr = kTRUE;
00423 TString clname;
00424 Version_t version;
00425 if ((cl!=0) && SqlObjectInfo(objid, clname, version))
00426 *cl = TClass::GetClass(clname);
00427 }
00428 }
00429 }
00430 }
00431 }
00432
00433 if ((gDebug>3) && findptr)
00434 cout << " Found pointer " << (obj ? obj : 0)
00435 << " class = " << ((cl && *cl) ? (*cl)->GetName() : "null") << endl;
00436
00437 if (findptr) {
00438 fCurrentData->ShiftToNextValue();
00439 return obj;
00440 }
00441
00442 if (fCurrentData->IsBlobData())
00443 if (!fCurrentData->VerifyDataType(sqlio::ObjectRef)) {
00444 Error("SqlReadObject","Object reference or pointer is not found in blob data");
00445 fErrorFlag = 1;
00446 return obj;
00447 }
00448
00449 fCurrentData->ShiftToNextValue();
00450
00451 if ((gDebug>2) || (objid<0))
00452 cout << "Found object reference " << objid << endl;
00453
00454 return SqlReadObjectDirect(obj, cl, objid, streamer, streamer_index, onFileClass);
00455 }
00456
00457
00458 void* TBufferSQL2::SqlReadObjectDirect(void* obj, TClass** cl, Long64_t objid, TMemberStreamer *streamer, Int_t streamer_index, const TClass *onFileClass)
00459 {
00460
00461
00462
00463 TString clname;
00464 Version_t version;
00465
00466 if (!SqlObjectInfo(objid, clname, version)) return obj;
00467
00468 if (gDebug>2)
00469 Info("SqlReadObjectDirect","objid = %lld clname = %s ver = %d",objid, clname.Data(), version);
00470
00471 TSQLClassInfo* sqlinfo = fSQL->FindSQLClassInfo(clname.Data(), version);
00472
00473 TClass* objClass = TClass::GetClass(clname);
00474 if (objClass == TDirectory::Class()) objClass = TDirectoryFile::Class();
00475
00476 if ((objClass==0) || (sqlinfo==0)) {
00477 Error("SqlReadObjectDirect","Class %s is not known", clname.Data());
00478 return obj;
00479 }
00480
00481 if (obj==0) obj = objClass->New();
00482
00483 if (fObjMap==0) fObjMap = new TExMap();
00484
00485 fObjMap->Add((Long_t) objid - fFirstObjId, (Long_t) obj);
00486
00487 PushStack()->SetObjectRef(objid, objClass);
00488
00489 TSQLObjectData* olddata = fCurrentData;
00490
00491 if (sqlinfo->IsClassTableExist()) {
00492
00493 if ((objClass==TObject::Class()) || (objClass==TString::Class())) {
00494
00495 TSQLObjectData* objdata = new TSQLObjectData;
00496 if (objClass==TObject::Class())
00497 TSQLStructure::UnpackTObject(fSQL, this, objdata, objid, version);
00498 else
00499 if (objClass==TString::Class())
00500 TSQLStructure::UnpackTString(fSQL, this, objdata, objid, version);
00501
00502 Stack()->AddObjectData(objdata);
00503 fCurrentData = objdata;
00504 } else
00505
00506
00507 fReadVersionBuffer = version;
00508 } else {
00509 TSQLObjectData* objdata = SqlObjectData(objid, sqlinfo);
00510 if ((objdata==0) || !objdata->PrepareForRawData()) {
00511 Error("SqlReadObjectDirect","No found raw data for obj %lld in class %s version %d table", objid, clname.Data(), version);
00512 fErrorFlag = 1;
00513 return obj;
00514 }
00515
00516 Stack()->AddObjectData(objdata);
00517
00518 fCurrentData = objdata;
00519 }
00520
00521 if (streamer!=0) {
00522 streamer->SetOnFileClass( onFileClass );
00523 (*streamer)(*this, (void*)obj, streamer_index);
00524 } else {
00525 objClass->Streamer((void*)obj, *this, onFileClass);
00526 }
00527
00528 PopStack();
00529
00530 if (gDebug>1)
00531 cout << "Read object of class " << objClass->GetName() << " done" << endl << endl;
00532
00533 if (cl!=0) *cl = objClass;
00534
00535 fCurrentData = olddata;
00536
00537 return obj;
00538 }
00539
00540
00541 void TBufferSQL2::IncrementLevel(TVirtualStreamerInfo* info)
00542 {
00543
00544
00545
00546
00547
00548 if (info==0) return;
00549
00550 PushStack()->SetStreamerInfo((TStreamerInfo*)info);
00551
00552 if (gDebug>2)
00553 cout << " IncrementLevel " << info->GetName() << endl;
00554
00555 WorkWithClass(info->GetName(), info->GetClassVersion());
00556 }
00557
00558
00559 void TBufferSQL2::DecrementLevel(TVirtualStreamerInfo* info)
00560 {
00561
00562
00563
00564 TSQLStructure* curr = Stack();
00565 if (curr->GetType()==TSQLStructure::kSqlElement) PopStack();
00566 PopStack();
00567
00568
00569 fCurrentData = Stack()->GetObjectData(kTRUE);
00570
00571 fExpectedChain = kFALSE;
00572
00573 if (gDebug>2)
00574 cout << " DecrementLevel " << info->GetClass()->GetName() << endl;
00575 }
00576
00577
00578 void TBufferSQL2::SetStreamerElementNumber(Int_t number)
00579 {
00580
00581
00582
00583
00584 if (number>0) PopStack();
00585 TSQLStructure* curr = Stack();
00586
00587 TStreamerInfo* info = curr->GetStreamerInfo();
00588 if (info==0) {
00589 Error("SetStreamerElementNumber","Error in structures stack");
00590 return;
00591 }
00592 TStreamerElement* elem = info->GetStreamerElementReal(number, 0);
00593
00594 Int_t comp_type = info->GetTypes()[number];
00595
00596 Int_t elem_type = elem->GetType();
00597
00598 fExpectedChain = ((elem_type>0) && (elem_type<20)) &&
00599 (comp_type - elem_type == TStreamerInfo::kOffsetL);
00600
00601 WorkWithElement(elem, number);
00602 }
00603
00604
00605 void TBufferSQL2::ClassBegin(const TClass* cl, Version_t classversion)
00606 {
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638 if (classversion<0) classversion = cl->GetClassVersion();
00639
00640 PushStack()->SetCustomClass(cl, classversion);
00641
00642 if (gDebug>2) Info("ClassBegin", "%s", cl->GetName());
00643
00644 WorkWithClass(cl->GetName(), classversion);
00645 }
00646
00647
00648 void TBufferSQL2::ClassEnd(const TClass* cl)
00649 {
00650
00651
00652
00653 TSQLStructure* curr = Stack();
00654 if (curr->GetType()==TSQLStructure::kSqlCustomElement) PopStack();
00655 PopStack();
00656
00657
00658 fCurrentData = Stack()->GetObjectData(kTRUE);
00659
00660 fExpectedChain = kFALSE;
00661
00662 if (gDebug>2) Info("ClassEnd","%s",cl->GetName());
00663 }
00664
00665
00666 void TBufferSQL2::ClassMember(const char* name, const char* typeName, Int_t arrsize1, Int_t arrsize2)
00667 {
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693 if (typeName==0) typeName = name;
00694
00695 if ((name==0) || (strlen(name)==0)) {
00696 Error("ClassMember","Invalid member name");
00697 fErrorFlag = 1;
00698 return;
00699 }
00700
00701 TString tname = typeName;
00702
00703 Int_t typ_id = -1;
00704
00705 if (strcmp(typeName,"raw:data")==0)
00706 typ_id = TStreamerInfo::kMissing;
00707
00708 if (typ_id<0) {
00709 TDataType *dt = gROOT->GetType(typeName);
00710 if (dt!=0)
00711 if ((dt->GetType()>0) && (dt->GetType()<20))
00712 typ_id = dt->GetType();
00713 }
00714
00715 if (typ_id<0)
00716 if (strcmp(name, typeName)==0) {
00717 TClass* cl = TClass::GetClass(tname.Data());
00718 if (cl!=0) typ_id = TStreamerInfo::kBase;
00719 }
00720
00721 if (typ_id<0) {
00722 Bool_t isptr = kFALSE;
00723 if (tname[tname.Length()-1]=='*') {
00724 tname.Resize(tname.Length()-1);
00725 isptr = kTRUE;
00726 }
00727 TClass* cl = TClass::GetClass(tname.Data());
00728 if (cl==0) {
00729 Error("ClassMember","Invalid class specifier %s", typeName);
00730 fErrorFlag = 1;
00731 return;
00732 }
00733
00734 if (cl->IsTObject())
00735 typ_id = isptr ? TStreamerInfo::kObjectp : TStreamerInfo::kObject;
00736 else
00737 typ_id = isptr ? TStreamerInfo::kAnyp : TStreamerInfo::kAny;
00738
00739 if ((cl==TString::Class()) && !isptr)
00740 typ_id = TStreamerInfo::kTString;
00741 }
00742
00743 TStreamerElement* elem = 0;
00744
00745 if (typ_id == TStreamerInfo::kMissing) {
00746 elem = new TStreamerElement(name,"title",0, typ_id, "raw:data");
00747 } else
00748
00749 if (typ_id==TStreamerInfo::kBase) {
00750 TClass* cl = TClass::GetClass(tname.Data());
00751 if (cl!=0) {
00752 TStreamerBase* b = new TStreamerBase(tname.Data(), "title", 0);
00753 b->SetBaseVersion(cl->GetClassVersion());
00754 elem = b;
00755 }
00756 } else
00757
00758 if ((typ_id>0) && (typ_id<20)) {
00759 elem = new TStreamerBasicType(name, "title", 0, typ_id, typeName);
00760 } else
00761
00762 if ((typ_id==TStreamerInfo::kObject) ||
00763 (typ_id==TStreamerInfo::kTObject) ||
00764 (typ_id==TStreamerInfo::kTNamed)) {
00765 elem = new TStreamerObject(name, "title", 0, tname.Data());
00766 } else
00767
00768 if (typ_id==TStreamerInfo::kObjectp) {
00769 elem = new TStreamerObjectPointer(name, "title", 0, tname.Data());
00770 } else
00771
00772 if (typ_id==TStreamerInfo::kAny) {
00773 elem = new TStreamerObjectAny(name, "title", 0, tname.Data());
00774 } else
00775
00776 if (typ_id==TStreamerInfo::kAnyp) {
00777 elem = new TStreamerObjectAnyPointer(name, "title", 0, tname.Data());
00778 } else
00779
00780 if (typ_id==TStreamerInfo::kTString) {
00781 elem = new TStreamerString(name, "title", 0);
00782 }
00783
00784 if (elem==0) {
00785 Error("ClassMember","Invalid combination name = %s type = %s", name, typeName);
00786 fErrorFlag = 1;
00787 return;
00788 }
00789
00790 if (arrsize1>0) {
00791 elem->SetArrayDim(arrsize2>0 ? 2 : 1);
00792 elem->SetMaxIndex(0, arrsize1);
00793 if (arrsize2>0)
00794 elem->SetMaxIndex(1, arrsize2);
00795 }
00796
00797
00798 if (Stack()->GetType()==TSQLStructure::kSqlCustomElement) PopStack();
00799
00800 fExpectedChain = kFALSE;
00801
00802
00803 WorkWithElement(elem, -1);
00804 }
00805
00806
00807 void TBufferSQL2::WorkWithClass(const char* classname, Version_t classversion)
00808 {
00809
00810
00811
00812 fExpectedChain = kFALSE;
00813
00814 if (IsReading()) {
00815 Long64_t objid = 0;
00816
00817
00818
00819
00820 if ((fCurrentData!=0) && fCurrentData->IsBlobData() &&
00821 fCurrentData->VerifyDataType(sqlio::ObjectInst, kFALSE)) {
00822 objid = atoi(fCurrentData->GetValue());
00823 fCurrentData->ShiftToNextValue();
00824 TString sobjid;
00825 sobjid.Form("%lld",objid);
00826 Stack()->ChangeValueOnly(sobjid.Data());
00827 } else
00828 objid = Stack()->DefineObjectId(kTRUE);
00829 if (objid<0) {
00830 Error("WorkWithClass","cannot define object id");
00831 fErrorFlag = 1;
00832 return;
00833 }
00834
00835 TSQLClassInfo* sqlinfo = fSQL->FindSQLClassInfo(classname, classversion);
00836 if (sqlinfo==0) {
00837 Error("WorkWithClass","Can not find table for class %s version %d", classname, classversion);
00838 fErrorFlag = 1;
00839 return;
00840 }
00841
00842 TSQLObjectData* objdata = SqlObjectData(objid, sqlinfo);
00843 if (objdata==0) {
00844 Error("WorkWithClass","Request error for data of object %lld for class %s version %d", objid, classname, classversion);
00845 fErrorFlag = 1;
00846 return;
00847 }
00848
00849 Stack()->AddObjectData(objdata);
00850
00851 fCurrentData = objdata;
00852 }
00853 }
00854
00855
00856 void TBufferSQL2::WorkWithElement(TStreamerElement* elem, Int_t number)
00857 {
00858
00859
00860
00861
00862
00863 if (gDebug>2)
00864 Info("WorkWithElement","elem = %s",elem->GetName());
00865
00866 if (number>=0)
00867 PushStack()->SetStreamerElement(elem, number);
00868 else
00869 PushStack()->SetCustomElement(elem);
00870
00871 if (IsReading()) {
00872
00873 if (fCurrentData==0) {
00874 Error("WorkWithElement","Object data is lost");
00875 fErrorFlag = 1;
00876 return;
00877 }
00878
00879 fCurrentData = Stack()->GetObjectData(kTRUE);
00880
00881 Int_t located = Stack()->LocateElementColumn(fSQL, this, fCurrentData);
00882
00883 if (located==TSQLStructure::kColUnknown) {
00884 Error("WorkWithElement","Cannot locate correct column in the table");
00885 fErrorFlag = 1;
00886 return;
00887 } else
00888 if ((located==TSQLStructure::kColObject) ||
00889 (located==TSQLStructure::kColObjectArray) ||
00890 (located==TSQLStructure::kColParent)) {
00891
00892 fCurrentData = Stack()->GetObjectData(kTRUE);
00893 }
00894 }
00895 }
00896
00897
00898 TClass* TBufferSQL2::ReadClass(const TClass*, UInt_t*)
00899 {
00900
00901
00902 return 0;
00903 }
00904
00905
00906 void TBufferSQL2::WriteClass(const TClass*)
00907 {
00908
00909 }
00910
00911
00912 Int_t TBufferSQL2::CheckByteCount(UInt_t , UInt_t , const TClass* )
00913 {
00914
00915
00916 return 0;
00917 }
00918
00919
00920 Int_t TBufferSQL2::CheckByteCount(UInt_t, UInt_t, const char*)
00921 {
00922
00923
00924 return 0;
00925 }
00926
00927
00928 void TBufferSQL2::SetByteCount(UInt_t, Bool_t)
00929 {
00930
00931 }
00932
00933
00934 void TBufferSQL2::SkipVersion(const TClass *cl)
00935 {
00936
00937 ReadVersion(0,0,cl);
00938 }
00939
00940
00941 Version_t TBufferSQL2::ReadVersion(UInt_t *start, UInt_t *bcnt, const TClass *)
00942 {
00943
00944
00945
00946
00947 Version_t res = 0;
00948
00949 if (start) *start = 0;
00950 if (bcnt) *bcnt = 0;
00951
00952 if (fReadVersionBuffer>=0) {
00953 res = fReadVersionBuffer;
00954 fReadVersionBuffer = -1;
00955 if (gDebug>3)
00956 cout << "TBufferSQL2::ReadVersion from buffer = " << res << endl;
00957 } else
00958 if ((fCurrentData!=0) && fCurrentData->IsBlobData() &&
00959 fCurrentData->VerifyDataType(sqlio::Version)) {
00960 TString value = fCurrentData->GetValue();
00961 res = value.Atoi();
00962 if (gDebug>3)
00963 cout << "TBufferSQL2::ReadVersion from blob " << fCurrentData->GetBlobPrefixName() << " = " << res << endl;
00964 fCurrentData->ShiftToNextValue();
00965 } else {
00966 Error("ReadVersion", "No correspondent tags to read version");
00967 fErrorFlag = 1;
00968 }
00969
00970 return res;
00971 }
00972
00973
00974 UInt_t TBufferSQL2::WriteVersion(const TClass *cl, Bool_t )
00975 {
00976
00977
00978
00979
00980 if (gDebug>2)
00981 cout << "TBufferSQL2::WriteVersion " << (cl ? cl->GetName() : "null") << " ver = " << (cl ? cl->GetClassVersion() : 0) << endl;
00982
00983 if (cl)
00984 Stack()->AddVersion(cl);
00985
00986 return 0;
00987 }
00988
00989
00990 void* TBufferSQL2::ReadObjectAny(const TClass*)
00991 {
00992
00993
00994 return SqlReadObject(0);
00995 }
00996
00997
00998 void TBufferSQL2::SkipObjectAny()
00999 {
01000
01001
01002
01003 }
01004
01005
01006 void TBufferSQL2::WriteObjectClass(const void *actualObjStart, const TClass *actualClass)
01007 {
01008
01009
01010 if (gDebug>2)
01011 cout << "TBufferSQL2::WriteObject of class " << (actualClass ? actualClass->GetName() : " null") << endl;
01012 SqlWriteObject(actualObjStart, actualClass);
01013 }
01014
01015 #define SQLReadArrayUncompress(vname, arrsize) \
01016 { \
01017 while(indx<arrsize) \
01018 SqlReadBasic(vname[indx++]); \
01019 }
01020
01021
01022 #define SQLReadArrayCompress(vname, arrsize) \
01023 { \
01024 while(indx<arrsize) { \
01025 const char* name = fCurrentData->GetBlobPrefixName(); \
01026 Int_t first, last, res; \
01027 if (strstr(name,sqlio::IndexSepar)==0) { \
01028 res = sscanf(name,"[%d", &first); last = first; \
01029 } else res = sscanf(name,"[%d..%d", &first, &last); \
01030 if (gDebug>5) cout << name << " first = " << first << " last = " << last << " res = " << res << endl; \
01031 if ((first!=indx) || (last<first) || (last>=arrsize)) { \
01032 Error("SQLReadArrayCompress","Error reading array content %s", name); \
01033 fErrorFlag = 1; \
01034 break; \
01035 } \
01036 SqlReadBasic(vname[indx]); indx++; \
01037 while(indx<=last) \
01038 vname[indx++] = vname[first]; \
01039 } \
01040 }
01041
01042
01043
01044 #define SQLReadArrayContent(vname, arrsize, withsize) \
01045 { \
01046 if (gDebug>3) cout << "SQLReadArrayContent " << (arrsize) << endl; \
01047 PushStack()->SetArray(withsize ? arrsize : -1); \
01048 Int_t indx = 0; \
01049 if (fCurrentData->IsBlobData()) \
01050 SQLReadArrayCompress(vname, arrsize) \
01051 else \
01052 SQLReadArrayUncompress(vname, arrsize) \
01053 PopStack(); \
01054 if (gDebug>3) cout << "SQLReadArrayContent done " << endl; \
01055 }
01056
01057
01058 #define TBufferSQL2_ReadArray(tname, vname) \
01059 { \
01060 Int_t n = SqlReadArraySize(); \
01061 if (n<=0) return 0; \
01062 if (!vname) vname = new tname[n]; \
01063 SQLReadArrayContent(vname, n, kTRUE); \
01064 return n; \
01065 }
01066
01067
01068 void TBufferSQL2::ReadFloat16 (Float_t *f, TStreamerElement * )
01069 {
01070
01071
01072 SqlReadBasic(*f);
01073 }
01074
01075
01076 void TBufferSQL2::ReadDouble32 (Double_t *d, TStreamerElement * )
01077 {
01078
01079
01080 SqlReadBasic(*d);
01081 }
01082
01083
01084 void TBufferSQL2::ReadWithFactor(Float_t *ptr, Double_t , Double_t )
01085 {
01086
01087
01088
01089
01090 SqlReadBasic(*ptr);
01091 }
01092
01093
01094 void TBufferSQL2::ReadWithNbits(Float_t *ptr, Int_t )
01095 {
01096
01097
01098
01099
01100 SqlReadBasic(*ptr);
01101 }
01102
01103
01104 void TBufferSQL2::ReadWithFactor(Double_t *ptr, Double_t , Double_t )
01105 {
01106
01107
01108
01109
01110 SqlReadBasic(*ptr);
01111 }
01112
01113
01114 void TBufferSQL2::ReadWithNbits(Double_t *ptr, Int_t )
01115 {
01116
01117
01118
01119
01120 SqlReadBasic(*ptr);
01121 }
01122
01123
01124 void TBufferSQL2::WriteFloat16 (Float_t *f, TStreamerElement * )
01125 {
01126
01127
01128 SqlWriteBasic(*f);
01129 }
01130
01131
01132 void TBufferSQL2::WriteDouble32 (Double_t *d, TStreamerElement * )
01133 {
01134
01135
01136 SqlWriteBasic(*d);
01137 }
01138
01139
01140 Int_t TBufferSQL2::ReadArray(Bool_t *&b)
01141 {
01142
01143
01144 TBufferSQL2_ReadArray(Bool_t,b);
01145 }
01146
01147
01148 Int_t TBufferSQL2::ReadArray(Char_t *&c)
01149 {
01150
01151
01152 TBufferSQL2_ReadArray(Char_t,c);
01153 }
01154
01155
01156 Int_t TBufferSQL2::ReadArray(UChar_t *&c)
01157 {
01158
01159
01160 TBufferSQL2_ReadArray(UChar_t,c);
01161 }
01162
01163
01164 Int_t TBufferSQL2::ReadArray(Short_t *&h)
01165 {
01166
01167
01168 TBufferSQL2_ReadArray(Short_t,h);
01169 }
01170
01171
01172 Int_t TBufferSQL2::ReadArray(UShort_t *&h)
01173 {
01174
01175
01176 TBufferSQL2_ReadArray(UShort_t,h);
01177 }
01178
01179
01180 Int_t TBufferSQL2::ReadArray(Int_t *&i)
01181 {
01182
01183
01184 TBufferSQL2_ReadArray(Int_t,i);
01185 }
01186
01187
01188 Int_t TBufferSQL2::ReadArray(UInt_t *&i)
01189 {
01190
01191
01192 TBufferSQL2_ReadArray(UInt_t,i);
01193 }
01194
01195
01196 Int_t TBufferSQL2::ReadArray(Long_t *&l)
01197 {
01198
01199
01200 TBufferSQL2_ReadArray(Long_t,l);
01201 }
01202
01203
01204 Int_t TBufferSQL2::ReadArray(ULong_t *&l)
01205 {
01206
01207
01208 TBufferSQL2_ReadArray(ULong_t,l);
01209 }
01210
01211
01212 Int_t TBufferSQL2::ReadArray(Long64_t *&l)
01213 {
01214
01215
01216 TBufferSQL2_ReadArray(Long64_t,l);
01217 }
01218
01219
01220 Int_t TBufferSQL2::ReadArray(ULong64_t *&l)
01221 {
01222
01223
01224 TBufferSQL2_ReadArray(ULong64_t,l);
01225 }
01226
01227
01228 Int_t TBufferSQL2::ReadArray(Float_t *&f)
01229 {
01230
01231
01232 TBufferSQL2_ReadArray(Float_t,f);
01233 }
01234
01235
01236 Int_t TBufferSQL2::ReadArray(Double_t *&d)
01237 {
01238
01239
01240 TBufferSQL2_ReadArray(Double_t,d);
01241 }
01242
01243
01244 Int_t TBufferSQL2::ReadArrayFloat16(Float_t *&f, TStreamerElement * )
01245 {
01246
01247
01248 TBufferSQL2_ReadArray(Float_t,f);
01249 }
01250
01251
01252 Int_t TBufferSQL2::ReadArrayDouble32(Double_t *&d, TStreamerElement * )
01253 {
01254
01255
01256 TBufferSQL2_ReadArray(Double_t,d);
01257 }
01258
01259
01260 #define TBufferSQL2_ReadStaticArray(vname) \
01261 { \
01262 Int_t n = SqlReadArraySize(); \
01263 if (n<=0) return 0; \
01264 if (!vname) return 0; \
01265 SQLReadArrayContent(vname, n, kTRUE); \
01266 return n; \
01267 }
01268
01269
01270 Int_t TBufferSQL2::ReadStaticArray(Bool_t *b)
01271 {
01272
01273
01274 TBufferSQL2_ReadStaticArray(b);
01275 }
01276
01277
01278 Int_t TBufferSQL2::ReadStaticArray(Char_t *c)
01279 {
01280
01281
01282 TBufferSQL2_ReadStaticArray(c);
01283 }
01284
01285
01286 Int_t TBufferSQL2::ReadStaticArray(UChar_t *c)
01287 {
01288
01289
01290 TBufferSQL2_ReadStaticArray(c);
01291 }
01292
01293
01294 Int_t TBufferSQL2::ReadStaticArray(Short_t *h)
01295 {
01296
01297
01298 TBufferSQL2_ReadStaticArray(h);
01299 }
01300
01301
01302 Int_t TBufferSQL2::ReadStaticArray(UShort_t *h)
01303 {
01304
01305
01306 TBufferSQL2_ReadStaticArray(h);
01307 }
01308
01309
01310 Int_t TBufferSQL2::ReadStaticArray(Int_t *i)
01311 {
01312
01313
01314 TBufferSQL2_ReadStaticArray(i);
01315 }
01316
01317
01318 Int_t TBufferSQL2::ReadStaticArray(UInt_t *i)
01319 {
01320
01321
01322 TBufferSQL2_ReadStaticArray(i);
01323 }
01324
01325
01326 Int_t TBufferSQL2::ReadStaticArray(Long_t *l)
01327 {
01328
01329
01330 TBufferSQL2_ReadStaticArray(l);
01331 }
01332
01333
01334 Int_t TBufferSQL2::ReadStaticArray(ULong_t *l)
01335 {
01336
01337
01338 TBufferSQL2_ReadStaticArray(l);
01339 }
01340
01341
01342 Int_t TBufferSQL2::ReadStaticArray(Long64_t *l)
01343 {
01344
01345
01346 TBufferSQL2_ReadStaticArray(l);
01347 }
01348
01349
01350 Int_t TBufferSQL2::ReadStaticArray(ULong64_t *l)
01351 {
01352
01353
01354 TBufferSQL2_ReadStaticArray(l);
01355 }
01356
01357
01358 Int_t TBufferSQL2::ReadStaticArray(Float_t *f)
01359 {
01360
01361
01362 TBufferSQL2_ReadStaticArray(f);
01363 }
01364
01365
01366 Int_t TBufferSQL2::ReadStaticArray(Double_t *d)
01367 {
01368
01369
01370 TBufferSQL2_ReadStaticArray(d);
01371 }
01372
01373
01374 Int_t TBufferSQL2::ReadStaticArrayFloat16(Float_t *f, TStreamerElement * )
01375 {
01376
01377
01378 TBufferSQL2_ReadStaticArray(f);
01379 }
01380
01381
01382 Int_t TBufferSQL2::ReadStaticArrayDouble32(Double_t *d, TStreamerElement * )
01383 {
01384
01385
01386 TBufferSQL2_ReadStaticArray(d);
01387 }
01388
01389
01390
01391 #define TBufferSQL2_ReadFastArray(vname) \
01392 { \
01393 if (n<=0) return; \
01394 TStreamerElement* elem = Stack(0)->GetElement(); \
01395 if ((elem!=0) && (elem->GetType()>TStreamerInfo::kOffsetL) && \
01396 (elem->GetType()<TStreamerInfo::kOffsetP) && \
01397 (elem->GetArrayLength()!=n)) fExpectedChain = kTRUE; \
01398 if (fExpectedChain) { \
01399 fExpectedChain = kFALSE; \
01400 Int_t startnumber = Stack(0)->GetElementNumber(); \
01401 TStreamerInfo* info = Stack(1)->GetStreamerInfo(); \
01402 Int_t number = 0; \
01403 Int_t index = 0; \
01404 while (index<n) { \
01405 elem = info->GetStreamerElementReal(startnumber, number++); \
01406 if (number>1) { PopStack(); WorkWithElement(elem, startnumber); } \
01407 if (elem->GetType()<TStreamerInfo::kOffsetL) { \
01408 SqlReadBasic(vname[index]); \
01409 index++; \
01410 } else { \
01411 Int_t elemlen = elem->GetArrayLength(); \
01412 SQLReadArrayContent((vname+index), elemlen, kFALSE); \
01413 index+=elemlen; \
01414 } \
01415 } \
01416 } else { \
01417 SQLReadArrayContent(vname, n, kFALSE); \
01418 } \
01419 }
01420
01421 void TBufferSQL2::ReadFastArray(Bool_t *b, Int_t n)
01422 {
01423
01424
01425 TBufferSQL2_ReadFastArray(b);
01426 }
01427
01428
01429 void TBufferSQL2::ReadFastArray(Char_t *c, Int_t n)
01430 {
01431
01432
01433
01434 if ((n>0) && fCurrentData->IsBlobData() &&
01435 fCurrentData->VerifyDataType(sqlio::CharStar, kFALSE)) {
01436 const char* buf = SqlReadCharStarValue();
01437 if ((buf==0) || (n<=0)) return;
01438 Int_t size = strlen(buf);
01439 if (size<n) size = n;
01440 memcpy(c, buf, size);
01441 } else {
01442
01443 TBufferSQL2_ReadFastArray(c);
01444 }
01445 }
01446
01447
01448 void TBufferSQL2::ReadFastArray(UChar_t *c, Int_t n)
01449 {
01450
01451
01452 TBufferSQL2_ReadFastArray(c);
01453 }
01454
01455
01456 void TBufferSQL2::ReadFastArray(Short_t *h, Int_t n)
01457 {
01458
01459
01460 TBufferSQL2_ReadFastArray(h);
01461 }
01462
01463
01464 void TBufferSQL2::ReadFastArray(UShort_t *h, Int_t n)
01465 {
01466
01467
01468 TBufferSQL2_ReadFastArray(h);
01469 }
01470
01471
01472 void TBufferSQL2::ReadFastArray(Int_t *i, Int_t n)
01473 {
01474
01475
01476 TBufferSQL2_ReadFastArray(i);
01477 }
01478
01479
01480 void TBufferSQL2::ReadFastArray(UInt_t *i, Int_t n)
01481 {
01482
01483
01484 TBufferSQL2_ReadFastArray(i);
01485 }
01486
01487
01488 void TBufferSQL2::ReadFastArray(Long_t *l, Int_t n)
01489 {
01490
01491
01492 TBufferSQL2_ReadFastArray(l);
01493 }
01494
01495
01496 void TBufferSQL2::ReadFastArray(ULong_t *l, Int_t n)
01497 {
01498
01499
01500 TBufferSQL2_ReadFastArray(l);
01501 }
01502
01503
01504 void TBufferSQL2::ReadFastArray(Long64_t *l, Int_t n)
01505 {
01506
01507
01508 TBufferSQL2_ReadFastArray(l);
01509 }
01510
01511
01512 void TBufferSQL2::ReadFastArray(ULong64_t *l, Int_t n)
01513 {
01514
01515
01516 TBufferSQL2_ReadFastArray(l);
01517 }
01518
01519
01520 void TBufferSQL2::ReadFastArray(Float_t *f, Int_t n)
01521 {
01522
01523
01524 TBufferSQL2_ReadFastArray(f);
01525 }
01526
01527
01528 void TBufferSQL2::ReadFastArray(Double_t *d, Int_t n)
01529 {
01530
01531
01532 TBufferSQL2_ReadFastArray(d);
01533 }
01534
01535
01536 void TBufferSQL2::ReadFastArrayFloat16(Float_t *f, Int_t n, TStreamerElement * )
01537 {
01538
01539
01540 TBufferSQL2_ReadFastArray(f);
01541 }
01542
01543
01544 void TBufferSQL2::ReadFastArrayDouble32(Double_t *d, Int_t n, TStreamerElement * )
01545 {
01546
01547
01548 TBufferSQL2_ReadFastArray(d);
01549 }
01550
01551
01552 void TBufferSQL2::ReadFastArray(void *start, const TClass *cl, Int_t n, TMemberStreamer *streamer, const TClass* onFileClass )
01553 {
01554
01555
01556
01557
01558
01559 if (gDebug>2)
01560 Info("ReadFastArray","(void *");
01561
01562 if (streamer) {
01563 StreamObject(start, streamer, cl, 0, onFileClass);
01564
01565 return;
01566 }
01567
01568 int objectSize = cl->Size();
01569 char *obj = (char*)start;
01570 char *end = obj + n*objectSize;
01571
01572 for(; obj<end; obj+=objectSize) {
01573 StreamObject(obj, cl, onFileClass);
01574 }
01575
01576 }
01577
01578
01579 void TBufferSQL2::ReadFastArray(void **start, const TClass *cl, Int_t n, Bool_t isPreAlloc, TMemberStreamer *streamer, const TClass* onFileClass )
01580 {
01581
01582
01583
01584
01585
01586 if (gDebug>2)
01587 Info("ReadFastArray","(void ** pre = %d n = %d", isPreAlloc, n);
01588
01589 if (streamer) {
01590 if (isPreAlloc) {
01591 for (Int_t j=0;j<n;j++) {
01592 if (!start[j]) start[j] = ((TClass*)cl)->New();
01593 }
01594 }
01595 StreamObject((void*)start, streamer, cl, 0, onFileClass);
01596
01597 return;
01598 }
01599
01600 if (!isPreAlloc) {
01601
01602 for (Int_t j=0; j<n; j++){
01603
01604 if (start[j] && TStreamerInfo::CanDelete()) ((TClass*)cl)->Destructor(start[j],kFALSE);
01605 start[j] = ReadObjectAny(cl);
01606 }
01607
01608 } else {
01609
01610 for (Int_t j=0; j<n; j++) {
01611 if (!start[j]) start[j] = ((TClass*)cl)->New();
01612 StreamObject(start[j], cl, onFileClass);
01613 }
01614 }
01615
01616 if (gDebug>2)
01617 Info("ReadFastArray","(void ** Done" );
01618
01619
01620 }
01621
01622
01623 Int_t TBufferSQL2::SqlReadArraySize()
01624 {
01625
01626
01627
01628 const char* value = SqlReadValue(sqlio::Array);
01629 if ((value==0) || (strlen(value)==0)) return 0;
01630 Int_t sz = atoi(value);
01631 return sz;
01632 }
01633
01634
01635 #define SQLWriteArrayNoncompress(vname, arrsize) \
01636 { \
01637 for(Int_t indx=0;indx<arrsize;indx++) { \
01638 SqlWriteBasic(vname[indx]); \
01639 Stack()->ChildArrayIndex(indx, 1); \
01640 } \
01641 }
01642
01643
01644 #define SQLWriteArrayCompress(vname, arrsize) \
01645 { \
01646 Int_t indx = 0; \
01647 while(indx<arrsize) { \
01648 Int_t curr = indx; indx++; \
01649 while ((indx<arrsize) && (vname[indx]==vname[curr])) indx++; \
01650 SqlWriteBasic(vname[curr]); \
01651 Stack()->ChildArrayIndex(curr, indx-curr); \
01652 } \
01653 }
01654
01655 #define SQLWriteArrayContent(vname, arrsize, withsize) \
01656 { \
01657 PushStack()->SetArray(withsize ? arrsize : -1); \
01658 if (fCompressLevel>0) { \
01659 SQLWriteArrayCompress(vname, arrsize) \
01660 } else { \
01661 SQLWriteArrayNoncompress(vname, arrsize) \
01662 } \
01663 PopStack(); \
01664 }
01665
01666
01667 #define TBufferSQL2_WriteArray(vname) \
01668 { \
01669 SQLWriteArrayContent(vname, n, kTRUE); \
01670 }
01671
01672
01673 void TBufferSQL2::WriteArray(const Bool_t *b, Int_t n)
01674 {
01675
01676
01677 TBufferSQL2_WriteArray(b);
01678 }
01679
01680
01681 void TBufferSQL2::WriteArray(const Char_t *c, Int_t n)
01682 {
01683
01684
01685 TBufferSQL2_WriteArray(c);
01686 }
01687
01688
01689 void TBufferSQL2::WriteArray(const UChar_t *c, Int_t n)
01690 {
01691
01692
01693 TBufferSQL2_WriteArray(c);
01694 }
01695
01696
01697 void TBufferSQL2::WriteArray(const Short_t *h, Int_t n)
01698 {
01699
01700
01701 TBufferSQL2_WriteArray(h);
01702 }
01703
01704
01705 void TBufferSQL2::WriteArray(const UShort_t *h, Int_t n)
01706 {
01707
01708
01709 TBufferSQL2_WriteArray(h);
01710 }
01711
01712
01713 void TBufferSQL2::WriteArray(const Int_t *i, Int_t n)
01714 {
01715
01716
01717 TBufferSQL2_WriteArray(i);
01718 }
01719
01720
01721 void TBufferSQL2::WriteArray(const UInt_t *i, Int_t n)
01722 {
01723
01724
01725 TBufferSQL2_WriteArray(i);
01726 }
01727
01728
01729 void TBufferSQL2::WriteArray(const Long_t *l, Int_t n)
01730 {
01731
01732
01733 TBufferSQL2_WriteArray(l);
01734 }
01735
01736
01737 void TBufferSQL2::WriteArray(const ULong_t *l, Int_t n)
01738 {
01739
01740
01741 TBufferSQL2_WriteArray(l);
01742 }
01743
01744
01745 void TBufferSQL2::WriteArray(const Long64_t *l, Int_t n)
01746 {
01747
01748
01749 TBufferSQL2_WriteArray(l);
01750 }
01751
01752
01753 void TBufferSQL2::WriteArray(const ULong64_t *l, Int_t n)
01754 {
01755
01756
01757 TBufferSQL2_WriteArray(l);
01758 }
01759
01760
01761 void TBufferSQL2::WriteArray(const Float_t *f, Int_t n)
01762 {
01763
01764
01765 TBufferSQL2_WriteArray(f);
01766 }
01767
01768
01769 void TBufferSQL2::WriteArray(const Double_t *d, Int_t n)
01770 {
01771
01772
01773 TBufferSQL2_WriteArray(d);
01774 }
01775
01776
01777 void TBufferSQL2::WriteArrayFloat16(const Float_t *f, Int_t n, TStreamerElement * )
01778 {
01779
01780
01781 TBufferSQL2_WriteArray(f);
01782 }
01783
01784
01785 void TBufferSQL2::WriteArrayDouble32(const Double_t *d, Int_t n, TStreamerElement * )
01786 {
01787
01788
01789 TBufferSQL2_WriteArray(d);
01790 }
01791
01792
01793
01794 #define TBufferSQL2_WriteFastArray(vname) \
01795 { \
01796 if (n<=0) return; \
01797 TStreamerElement* elem = Stack(0)->GetElement(); \
01798 if ((elem!=0) && (elem->GetType()>TStreamerInfo::kOffsetL) && \
01799 (elem->GetType()<TStreamerInfo::kOffsetP) && \
01800 (elem->GetArrayLength()!=n)) fExpectedChain = kTRUE; \
01801 if (fExpectedChain) { \
01802 TStreamerInfo* info = Stack(1)->GetStreamerInfo(); \
01803 Int_t startnumber = Stack(0)->GetElementNumber(); \
01804 Int_t number = 0; \
01805 Int_t index = 0; \
01806 while (index<n) { \
01807 elem = info->GetStreamerElementReal(startnumber, number++); \
01808 if (number>1) { PopStack(); WorkWithElement(elem, startnumber + number); } \
01809 if (elem->GetType()<TStreamerInfo::kOffsetL) { \
01810 SqlWriteBasic(vname[index]); \
01811 index++; \
01812 } else { \
01813 Int_t elemlen = elem->GetArrayLength(); \
01814 SQLWriteArrayContent((vname+index), elemlen, kFALSE); \
01815 index+=elemlen; \
01816 } \
01817 fExpectedChain = kFALSE; \
01818 } \
01819 } else { \
01820 SQLWriteArrayContent(vname, n, kFALSE); \
01821 } \
01822 }
01823
01824
01825 void TBufferSQL2::WriteFastArray(const Bool_t *b, Int_t n)
01826 {
01827
01828
01829 TBufferSQL2_WriteFastArray(b);
01830 }
01831
01832
01833 void TBufferSQL2::WriteFastArray(const Char_t *c, Int_t n)
01834 {
01835
01836
01837
01838 Bool_t usedefault = (n==0) || fExpectedChain;
01839
01840 const Char_t* ccc = c;
01841
01842 if (!usedefault)
01843 for (int i=0;i<n;i++)
01844 if (*ccc++==0) { usedefault = kTRUE; break; }
01845
01846 if (usedefault) {
01847 TBufferSQL2_WriteFastArray(c);
01848 } else {
01849 Char_t* buf = new Char_t[n+1];
01850 memcpy(buf, c, n);
01851 buf[n] = 0;
01852 SqlWriteValue(buf, sqlio::CharStar);
01853 delete[] buf;
01854 }
01855 }
01856
01857
01858 void TBufferSQL2::WriteFastArray(const UChar_t *c, Int_t n)
01859 {
01860
01861
01862 TBufferSQL2_WriteFastArray(c);
01863 }
01864
01865
01866 void TBufferSQL2::WriteFastArray(const Short_t *h, Int_t n)
01867 {
01868
01869
01870 TBufferSQL2_WriteFastArray(h);
01871 }
01872
01873
01874 void TBufferSQL2::WriteFastArray(const UShort_t *h, Int_t n)
01875 {
01876
01877
01878 TBufferSQL2_WriteFastArray(h);
01879 }
01880
01881
01882 void TBufferSQL2::WriteFastArray(const Int_t *i, Int_t n)
01883 {
01884
01885
01886 TBufferSQL2_WriteFastArray(i);
01887 }
01888
01889
01890 void TBufferSQL2::WriteFastArray(const UInt_t *i, Int_t n)
01891 {
01892
01893
01894 TBufferSQL2_WriteFastArray(i);
01895 }
01896
01897
01898 void TBufferSQL2::WriteFastArray(const Long_t *l, Int_t n)
01899 {
01900
01901
01902 TBufferSQL2_WriteFastArray(l);
01903 }
01904
01905
01906 void TBufferSQL2::WriteFastArray(const ULong_t *l, Int_t n)
01907 {
01908
01909
01910 TBufferSQL2_WriteFastArray(l);
01911 }
01912
01913
01914 void TBufferSQL2::WriteFastArray(const Long64_t *l, Int_t n)
01915 {
01916
01917
01918 TBufferSQL2_WriteFastArray(l);
01919 }
01920
01921
01922 void TBufferSQL2::WriteFastArray(const ULong64_t *l, Int_t n)
01923 {
01924
01925
01926 TBufferSQL2_WriteFastArray(l);
01927 }
01928
01929
01930 void TBufferSQL2::WriteFastArray(const Float_t *f, Int_t n)
01931 {
01932
01933
01934 TBufferSQL2_WriteFastArray(f);
01935 }
01936
01937
01938 void TBufferSQL2::WriteFastArray(const Double_t *d, Int_t n)
01939 {
01940
01941
01942 TBufferSQL2_WriteFastArray(d);
01943 }
01944
01945
01946 void TBufferSQL2::WriteFastArrayFloat16(const Float_t *f, Int_t n, TStreamerElement * )
01947 {
01948
01949
01950 TBufferSQL2_WriteFastArray(f);
01951 }
01952
01953
01954 void TBufferSQL2::WriteFastArrayDouble32(const Double_t *d, Int_t n, TStreamerElement * )
01955 {
01956
01957
01958 TBufferSQL2_WriteFastArray(d);
01959 }
01960
01961
01962 void TBufferSQL2::WriteFastArray(void *start, const TClass *cl, Int_t n, TMemberStreamer *streamer)
01963 {
01964
01965
01966
01967
01968
01969 if (streamer) {
01970 StreamObject(start, streamer, cl, 0);
01971
01972 return;
01973 }
01974
01975 char *obj = (char*)start;
01976 if (!n) n=1;
01977 int size = cl->Size();
01978
01979 for(Int_t j=0; j<n; j++,obj+=size)
01980 StreamObject(obj, cl);
01981
01982
01983 }
01984
01985
01986 Int_t TBufferSQL2::WriteFastArray(void **start, const TClass *cl, Int_t n, Bool_t isPreAlloc, TMemberStreamer *streamer)
01987 {
01988
01989
01990
01991
01992
01993 if (streamer) {
01994 StreamObject((void*) start, streamer, cl, 0);
01995
01996 return 0;
01997 }
01998
01999 int strInfo = 0;
02000
02001 Int_t res = 0;
02002
02003 if (!isPreAlloc) {
02004
02005 for (Int_t j=0;j<n;j++) {
02006
02007 if (!strInfo && !start[j] ) ForceWriteInfo(((TClass*)cl)->GetStreamerInfo(),kFALSE);
02008 strInfo = 2003;
02009 res |= WriteObjectAny(start[j],cl);
02010 }
02011
02012 } else {
02013
02014 for (Int_t j=0;j<n;j++) {
02015 if (!start[j]) start[j] = ((TClass*)cl)->New();
02016 StreamObject(start[j], cl);
02017 }
02018
02019 }
02020 return res;
02021
02022
02023 }
02024
02025
02026 void TBufferSQL2::StreamObject(void *obj, const type_info &typeinfo, const TClass *onFileClass)
02027 {
02028
02029
02030 StreamObject(obj, TClass::GetClass(typeinfo), onFileClass);
02031 }
02032
02033
02034 void TBufferSQL2::StreamObject(void *obj, const char *className, const TClass *onFileClass)
02035 {
02036
02037
02038 StreamObject(obj, TClass::GetClass(className), onFileClass);
02039 }
02040
02041
02042 void TBufferSQL2::StreamObject(void *obj, const TClass *cl, const TClass *onFileClass)
02043 {
02044
02045
02046 if (gDebug>1)
02047 cout << " TBufferSQL2::StreamObject class = " << (cl ? cl->GetName() : "none") << endl;
02048 if (IsReading())
02049 SqlReadObject(obj, 0, 0, 0, onFileClass);
02050 else
02051 SqlWriteObject(obj, cl);
02052 }
02053
02054
02055 void TBufferSQL2::StreamObject(TObject *obj)
02056 {
02057
02058
02059 StreamObject(obj, obj ? obj->IsA() : TObject::Class());
02060 }
02061
02062
02063 void TBufferSQL2::StreamObject(void *obj, TMemberStreamer *streamer, const TClass *cl, Int_t n, const TClass *onFileClass)
02064 {
02065
02066
02067 if (streamer==0) return;
02068
02069 if (gDebug>1)
02070 cout << "Stream object of class = " << cl->GetName() << endl;
02071
02072
02073 if (IsReading())
02074 SqlReadObject(obj, 0, streamer, n, onFileClass);
02075 else
02076 SqlWriteObject(obj, cl, streamer, n);
02077 }
02078
02079
02080 #define TBufferSQL2_operatorin(vname) \
02081 { \
02082 SqlReadBasic(vname); \
02083 }
02084
02085
02086 void TBufferSQL2::ReadBool(Bool_t &b)
02087 {
02088
02089
02090 TBufferSQL2_operatorin(b);
02091 }
02092
02093
02094 void TBufferSQL2::ReadChar(Char_t &c)
02095 {
02096
02097
02098 TBufferSQL2_operatorin(c);
02099 }
02100
02101
02102 void TBufferSQL2::ReadUChar(UChar_t &c)
02103 {
02104
02105
02106 TBufferSQL2_operatorin(c);
02107 }
02108
02109
02110 void TBufferSQL2::ReadShort(Short_t &h)
02111 {
02112
02113
02114 TBufferSQL2_operatorin(h);
02115 }
02116
02117
02118 void TBufferSQL2::ReadUShort(UShort_t &h)
02119 {
02120
02121
02122 TBufferSQL2_operatorin(h);
02123 }
02124
02125
02126 void TBufferSQL2::ReadInt(Int_t &i)
02127 {
02128
02129
02130 TBufferSQL2_operatorin(i);
02131 }
02132
02133
02134 void TBufferSQL2::ReadUInt(UInt_t &i)
02135 {
02136
02137
02138 TBufferSQL2_operatorin(i);
02139 }
02140
02141
02142 void TBufferSQL2::ReadLong(Long_t &l)
02143 {
02144
02145
02146 TBufferSQL2_operatorin(l);
02147 }
02148
02149
02150 void TBufferSQL2::ReadULong(ULong_t &l)
02151 {
02152
02153
02154 TBufferSQL2_operatorin(l);
02155 }
02156
02157
02158 void TBufferSQL2::ReadLong64(Long64_t &l)
02159 {
02160
02161
02162 TBufferSQL2_operatorin(l);
02163 }
02164
02165
02166 void TBufferSQL2::ReadULong64(ULong64_t &l)
02167 {
02168
02169
02170 TBufferSQL2_operatorin(l);
02171 }
02172
02173
02174 void TBufferSQL2::ReadFloat(Float_t &f)
02175 {
02176
02177
02178 TBufferSQL2_operatorin(f);
02179 }
02180
02181
02182 void TBufferSQL2::ReadDouble(Double_t &d)
02183 {
02184
02185
02186 TBufferSQL2_operatorin(d);
02187 }
02188
02189
02190 void TBufferSQL2::ReadCharP(Char_t *c)
02191 {
02192
02193
02194 const char* buf = SqlReadCharStarValue();
02195 strcpy(c, buf);
02196 }
02197
02198
02199 void TBufferSQL2::ReadTString(TString &)
02200 {
02201
02202
02203
02204
02205 printf("ERROR NOT IMPLEMENTED\n");
02206 }
02207
02208
02209 void TBufferSQL2::WriteTString(const TString &)
02210 {
02211
02212
02213
02214
02215 printf("ERROR NOT IMPLEMENTED\n");
02216 }
02217
02218
02219 #define TBufferSQL2_operatorout(vname) \
02220 { \
02221 SqlWriteBasic(vname); \
02222 }
02223
02224
02225 void TBufferSQL2::WriteBool(Bool_t b)
02226 {
02227
02228
02229 TBufferSQL2_operatorout(b);
02230 }
02231
02232
02233 void TBufferSQL2::WriteChar(Char_t c)
02234 {
02235
02236
02237 TBufferSQL2_operatorout(c);
02238 }
02239
02240
02241 void TBufferSQL2::WriteUChar(UChar_t c)
02242 {
02243
02244
02245 TBufferSQL2_operatorout(c);
02246 }
02247
02248
02249 void TBufferSQL2::WriteShort(Short_t h)
02250 {
02251
02252
02253 TBufferSQL2_operatorout(h);
02254 }
02255
02256
02257 void TBufferSQL2::WriteUShort(UShort_t h)
02258 {
02259
02260
02261 TBufferSQL2_operatorout(h);
02262 }
02263
02264
02265 void TBufferSQL2::WriteInt(Int_t i)
02266 {
02267
02268
02269 TBufferSQL2_operatorout(i);
02270 }
02271
02272
02273 void TBufferSQL2::WriteUInt(UInt_t i)
02274 {
02275
02276
02277 TBufferSQL2_operatorout(i);
02278 }
02279
02280
02281 void TBufferSQL2::WriteLong(Long_t l)
02282 {
02283
02284
02285 TBufferSQL2_operatorout(l);
02286 }
02287
02288
02289 void TBufferSQL2::WriteULong(ULong_t l)
02290 {
02291
02292
02293 TBufferSQL2_operatorout(l);
02294 }
02295
02296
02297 void TBufferSQL2::WriteLong64(Long64_t l)
02298 {
02299
02300
02301 TBufferSQL2_operatorout(l);
02302 }
02303
02304
02305 void TBufferSQL2::WriteULong64(ULong64_t l)
02306 {
02307
02308
02309 TBufferSQL2_operatorout(l);
02310 }
02311
02312
02313 void TBufferSQL2::WriteFloat(Float_t f)
02314 {
02315
02316
02317 TBufferSQL2_operatorout(f);
02318 }
02319
02320
02321 void TBufferSQL2::WriteDouble(Double_t d)
02322 {
02323
02324
02325 TBufferSQL2_operatorout(d);
02326 }
02327
02328
02329 void TBufferSQL2::WriteCharP(const Char_t *c)
02330 {
02331
02332
02333 SqlWriteValue(c, sqlio::CharStar);
02334 }
02335
02336
02337 Bool_t TBufferSQL2::SqlWriteBasic(Char_t value)
02338 {
02339
02340
02341 char buf[50];
02342 snprintf(buf, sizeof(buf), "%d", value);
02343 return SqlWriteValue(buf, sqlio::Char);
02344 }
02345
02346
02347 Bool_t TBufferSQL2::SqlWriteBasic(Short_t value)
02348 {
02349
02350
02351 char buf[50];
02352 snprintf(buf, sizeof(buf), "%hd", value);
02353 return SqlWriteValue(buf, sqlio::Short);
02354 }
02355
02356
02357 Bool_t TBufferSQL2::SqlWriteBasic(Int_t value)
02358 {
02359
02360
02361 char buf[50];
02362 snprintf(buf, sizeof(buf), "%d", value);
02363 return SqlWriteValue(buf, sqlio::Int);
02364 }
02365
02366
02367 Bool_t TBufferSQL2::SqlWriteBasic(Long_t value)
02368 {
02369
02370
02371 char buf[50];
02372 snprintf(buf, sizeof(buf), "%ld", value);
02373 return SqlWriteValue(buf, sqlio::Long);
02374 }
02375
02376
02377 Bool_t TBufferSQL2::SqlWriteBasic(Long64_t value)
02378 {
02379
02380
02381 char buf[50];
02382 snprintf(buf, sizeof(buf), "%lld", value);
02383 return SqlWriteValue(buf, sqlio::Long64);
02384 }
02385
02386
02387 Bool_t TBufferSQL2::SqlWriteBasic(Float_t value)
02388 {
02389
02390
02391 char buf[200];
02392 snprintf(buf, sizeof(buf), TSQLServer::GetFloatFormat(), value);
02393 return SqlWriteValue(buf, sqlio::Float);
02394 }
02395
02396
02397 Bool_t TBufferSQL2::SqlWriteBasic(Double_t value)
02398 {
02399
02400
02401 char buf[128];
02402 snprintf(buf, sizeof(buf), TSQLServer::GetFloatFormat(), value);
02403 return SqlWriteValue(buf, sqlio::Double);
02404 }
02405
02406
02407 Bool_t TBufferSQL2::SqlWriteBasic(Bool_t value)
02408 {
02409
02410
02411 return SqlWriteValue(value ? sqlio::True : sqlio::False, sqlio::Bool);
02412 }
02413
02414
02415 Bool_t TBufferSQL2::SqlWriteBasic(UChar_t value)
02416 {
02417
02418
02419 char buf[50];
02420 snprintf(buf, sizeof(buf), "%u", value);
02421 return SqlWriteValue(buf, sqlio::UChar);
02422 }
02423
02424
02425 Bool_t TBufferSQL2::SqlWriteBasic(UShort_t value)
02426 {
02427
02428
02429 char buf[50];
02430 snprintf(buf, sizeof(buf), "%hu", value);
02431 return SqlWriteValue(buf, sqlio::UShort);
02432 }
02433
02434
02435 Bool_t TBufferSQL2::SqlWriteBasic(UInt_t value)
02436 {
02437
02438
02439 char buf[50];
02440 snprintf(buf, sizeof(buf), "%u", value);
02441 return SqlWriteValue(buf, sqlio::UInt);
02442 }
02443
02444
02445 Bool_t TBufferSQL2::SqlWriteBasic(ULong_t value)
02446 {
02447
02448
02449 char buf[50];
02450 snprintf(buf, sizeof(buf), "%lu", value);
02451 return SqlWriteValue(buf, sqlio::ULong);
02452 }
02453
02454
02455 Bool_t TBufferSQL2::SqlWriteBasic(ULong64_t value)
02456 {
02457
02458
02459 char buf[50];
02460 snprintf(buf, sizeof(buf), FULong64, value);
02461 return SqlWriteValue(buf, sqlio::ULong64);
02462 }
02463
02464
02465
02466 Bool_t TBufferSQL2::SqlWriteValue(const char* value, const char* tname)
02467 {
02468
02469
02470 Stack()->AddValue(value, tname);
02471
02472 return kTRUE;
02473 }
02474
02475
02476 void TBufferSQL2::SqlReadBasic(Char_t& value)
02477 {
02478
02479
02480 const char* res = SqlReadValue(sqlio::Char);
02481 if (res) {
02482 int n;
02483 sscanf(res,"%d", &n);
02484 value = n;
02485 } else
02486 value = 0;
02487 }
02488
02489
02490 void TBufferSQL2::SqlReadBasic(Short_t& value)
02491 {
02492
02493
02494 const char* res = SqlReadValue(sqlio::Short);
02495 if (res)
02496 sscanf(res,"%hd", &value);
02497 else
02498 value = 0;
02499 }
02500
02501
02502 void TBufferSQL2::SqlReadBasic(Int_t& value)
02503 {
02504
02505
02506 const char* res = SqlReadValue(sqlio::Int);
02507 if (res)
02508 sscanf(res,"%d", &value);
02509 else
02510 value = 0;
02511 }
02512
02513
02514 void TBufferSQL2::SqlReadBasic(Long_t& value)
02515 {
02516
02517
02518 const char* res = SqlReadValue(sqlio::Long);
02519 if (res)
02520 sscanf(res,"%ld", &value);
02521 else
02522 value = 0;
02523 }
02524
02525
02526 void TBufferSQL2::SqlReadBasic(Long64_t& value)
02527 {
02528
02529
02530 const char* res = SqlReadValue(sqlio::Long64);
02531 if (res)
02532 sscanf(res, FLong64, &value);
02533 else
02534 value = 0;
02535 }
02536
02537
02538 void TBufferSQL2::SqlReadBasic(Float_t& value)
02539 {
02540
02541
02542 const char* res = SqlReadValue(sqlio::Float);
02543 if (res)
02544 sscanf(res, "%f", &value);
02545 else
02546 value = 0.;
02547 }
02548
02549
02550 void TBufferSQL2::SqlReadBasic(Double_t& value)
02551 {
02552
02553
02554 const char* res = SqlReadValue(sqlio::Double);
02555 if (res)
02556 sscanf(res, "%lf", &value);
02557 else
02558 value = 0.;
02559 }
02560
02561
02562 void TBufferSQL2::SqlReadBasic(Bool_t& value)
02563 {
02564
02565
02566 const char* res = SqlReadValue(sqlio::Bool);
02567 if (res)
02568 value = (strcmp(res, sqlio::True)==0);
02569 else
02570 value = kFALSE;
02571 }
02572
02573
02574 void TBufferSQL2::SqlReadBasic(UChar_t& value)
02575 {
02576
02577
02578 const char* res = SqlReadValue(sqlio::UChar);
02579 if (res) {
02580 unsigned int n;
02581 sscanf(res,"%ud", &n);
02582 value = n;
02583 } else
02584 value = 0;
02585 }
02586
02587
02588 void TBufferSQL2::SqlReadBasic(UShort_t& value)
02589 {
02590
02591
02592 const char* res = SqlReadValue(sqlio::UShort);
02593 if (res)
02594 sscanf(res,"%hud", &value);
02595 else
02596 value = 0;
02597 }
02598
02599
02600 void TBufferSQL2::SqlReadBasic(UInt_t& value)
02601 {
02602
02603
02604 const char* res = SqlReadValue(sqlio::UInt);
02605 if (res)
02606 sscanf(res,"%u", &value);
02607 else
02608 value = 0;
02609 }
02610
02611
02612 void TBufferSQL2::SqlReadBasic(ULong_t& value)
02613 {
02614
02615
02616 const char* res = SqlReadValue(sqlio::ULong);
02617 if (res)
02618 sscanf(res,"%lu", &value);
02619 else
02620 value = 0;
02621 }
02622
02623
02624 void TBufferSQL2::SqlReadBasic(ULong64_t& value)
02625 {
02626
02627
02628 const char* res = SqlReadValue(sqlio::ULong64);
02629 if (res)
02630 sscanf(res, FULong64, &value);
02631 else
02632 value = 0;
02633 }
02634
02635
02636 const char* TBufferSQL2::SqlReadValue(const char* tname)
02637 {
02638
02639
02640 if (fErrorFlag>0) return 0;
02641
02642 if (fCurrentData==0) {
02643 Error("SqlReadValue","No object data to read from");
02644 fErrorFlag = 1;
02645 return 0;
02646 }
02647
02648 if (!fIgnoreVerification)
02649 if (!fCurrentData->VerifyDataType(tname)) {
02650 fErrorFlag = 1;
02651 return 0;
02652 }
02653
02654 fReadBuffer = fCurrentData->GetValue();
02655
02656 fCurrentData->ShiftToNextValue();
02657
02658 if (gDebug>4)
02659 cout << " SqlReadValue " << tname << " = " << fReadBuffer << endl;
02660
02661 return fReadBuffer.Data();
02662 }
02663
02664
02665 const char* TBufferSQL2::SqlReadCharStarValue()
02666 {
02667
02668 const char* res = SqlReadValue(sqlio::CharStar);
02669 if ((res==0) || (fSQL==0)) return 0;
02670
02671 Long64_t objid = Stack()->DefineObjectId(kTRUE);
02672
02673 Int_t strid = fSQL->IsLongStringCode(objid, res);
02674 if (strid<=0) return res;
02675
02676 fSQL->GetLongString(objid, strid, fReadBuffer);
02677
02678 return fReadBuffer.Data();
02679 }
02680
02681
02682
02683 TSQLStructure* TBufferSQL2::PushStack()
02684 {
02685
02686
02687 TSQLStructure* res = new TSQLStructure;
02688 if (fStk==0) {
02689 fStructure = res;
02690 } else {
02691 fStk->Add(res);
02692 }
02693
02694 fStk = res;
02695 return fStk;
02696 }
02697
02698
02699 TSQLStructure* TBufferSQL2::PopStack()
02700 {
02701
02702
02703 if (fStk==0) return 0;
02704 fStk = fStk->GetParent();
02705 return fStk;
02706 }
02707
02708
02709 TSQLStructure* TBufferSQL2::Stack(Int_t depth)
02710 {
02711
02712
02713 TSQLStructure* curr = fStk;
02714 while ((depth-->0) && (curr!=0)) curr = curr->GetParent();
02715 return curr;
02716 }
02717
02718
02719
02720 void TBufferSQL2::SetFloatFormat(const char* fmt)
02721 {
02722
02723
02724
02725 TSQLServer::SetFloatFormat(fmt);
02726 }
02727
02728
02729 const char* TBufferSQL2::GetFloatFormat()
02730 {
02731
02732
02733
02734 return TSQLServer::GetFloatFormat();
02735 }
02736
02737
02738 Int_t TBufferSQL2::ReadSequence(const TStreamerInfoActions::TActionSequence &sequence, void *obj)
02739 {
02740
02741
02742
02743 TVirtualStreamerInfo *info = sequence.fStreamerInfo;
02744 IncrementLevel(info);
02745
02746 if (gDebug) {
02747
02748 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
02749 for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
02750 iter != end;
02751 ++iter) {
02752
02753 SetStreamerElementNumber((*iter).fConfiguration->fElemId);
02754 (*iter).PrintDebug(*this,obj);
02755 (*iter)(*this,obj);
02756 }
02757
02758 } else {
02759
02760 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
02761 for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
02762 iter != end;
02763 ++iter) {
02764
02765 SetStreamerElementNumber((*iter).fConfiguration->fElemId);
02766 (*iter)(*this,obj);
02767 }
02768 }
02769
02770 DecrementLevel(info);
02771 return 0;
02772 }
02773
02774
02775 Int_t TBufferSQL2::ReadSequenceVecPtr(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection)
02776 {
02777
02778
02779
02780 TVirtualStreamerInfo *info = sequence.fStreamerInfo;
02781 IncrementLevel(info);
02782
02783 if (gDebug) {
02784
02785 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
02786 for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
02787 iter != end;
02788 ++iter) {
02789
02790 SetStreamerElementNumber((*iter).fConfiguration->fElemId);
02791 (*iter).PrintDebug(*this,*(char**)start_collection);
02792 (*iter)(*this,start_collection,end_collection);
02793 }
02794
02795 } else {
02796
02797 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
02798 for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
02799 iter != end;
02800 ++iter) {
02801
02802 SetStreamerElementNumber((*iter).fConfiguration->fElemId);
02803 (*iter)(*this,start_collection,end_collection);
02804 }
02805 }
02806
02807 DecrementLevel(info);
02808 return 0;
02809 }
02810
02811
02812 Int_t TBufferSQL2::ReadSequence(const TStreamerInfoActions::TActionSequence &sequence, void *start_collection, void *end_collection)
02813 {
02814
02815
02816 TVirtualStreamerInfo *info = sequence.fStreamerInfo;
02817 IncrementLevel(info);
02818
02819 TStreamerInfoActions::TLoopConfiguration *loopconfig = sequence.fLoopConfig;
02820 if (gDebug) {
02821
02822
02823
02824
02825 void *arr0 = loopconfig->GetFirstAddress(start_collection,end_collection);
02826
02827 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
02828 for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
02829 iter != end;
02830 ++iter) {
02831
02832 SetStreamerElementNumber((*iter).fConfiguration->fElemId);
02833 (*iter).PrintDebug(*this,arr0);
02834 (*iter)(*this,start_collection,end_collection,loopconfig);
02835 }
02836
02837 } else {
02838
02839 TStreamerInfoActions::ActionContainer_t::const_iterator end = sequence.fActions.end();
02840 for(TStreamerInfoActions::ActionContainer_t::const_iterator iter = sequence.fActions.begin();
02841 iter != end;
02842 ++iter) {
02843
02844 SetStreamerElementNumber((*iter).fConfiguration->fElemId);
02845 (*iter)(*this,start_collection,end_collection,loopconfig);
02846 }
02847 }
02848
02849 DecrementLevel(info);
02850 return 0;
02851 }
02852