TBufferSQL2.cxx

Go to the documentation of this file.
00001 // @(#)root/sql:$Id: TBufferSQL2.cxx 36061 2010-10-04 16:05:51Z pcanal $
00002 // Author: Sergey Linev  20/11/2005
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //________________________________________________________________________
00013 //
00014 // Class for serializing/deserializing object to/from SQL data base.
00015 // It redefines most of TBuffer class function to convert simple types,
00016 // array of simple types and objects to/from TSQLStructure objects.
00017 // TBufferSQL2 class uses streaming mechanism, provided by ROOT system,
00018 // therefore most of ROOT and user classes can be stored. There are
00019 // limitations for complex objects like TTree, TClonesArray, TDirectory and
00020 // few other, which can not be converted to SQL (yet).
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    // Default constructor, should not be used
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    // Creates buffer object to serailize/deserialize data to/from sql.
00103    // Mode should be either TBuffer::kRead or TBuffer::kWrite.
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    // Creates buffer object to serailize/deserialize data to/from sql.
00130    // This constructor should be used, if data from buffer supposed to be stored in file.
00131    // Mode should be either TBuffer::kRead or TBuffer::kWrite.
00132 
00133    fBufSize = 1000000000;
00134 
00135    // for TClonesArray recognize if this is special case
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    // destroy sql buffer
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    // Convert object of any class to sql structures
00171    // Return pointer on created TSQLStructure
00172    // TSQLStructure object will be owned by TBufferSQL2
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    // Recreate object from sql structure.
00197    // Return pointer to read object.
00198    // if (cl!=0) returns pointer to class of object
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 //   fObjectsInfos = 0;
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 // Returns object info like classname and version
00224 // Should be taken from buffer, which is produced in the begginnig
00225 
00226    if ((objid<0) || (fObjectsInfos==0)) return kFALSE;
00227 
00228  //  if (fObjectsInfos==0) return fSQL->SQLObjectInfo(objid, clname, version);
00229 
00230    // suppose that objects info are sorted out
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       // I hope, i will never get inside it
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    // creates TSQLObjectData for specifed object id and specified class
00262    // Object data for each class can be stored in two different tables.
00263    // First table contains data in column-wise form for simple types like integer,
00264    // strings and so on when second table contains any other data which cannot
00265    // be converted into column-wise representation.
00266    // TSQLObjectData will contain results of the requests to both such tables for
00267    // concrete object id.
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    // Convert object into sql structures.
00321    // !!! Should be used only by TBufferSQL2 itself.
00322    // Use SqlWrite() functions to convert your object to sql
00323    // Redefined here to avoid gcc 3.x warning
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    // Write object to buffer
00332    // If object was written before, only pointer will be stored
00333    // Return id of saved object
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    // Read object from the buffer
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    // Read object data.
00461    // Class name and version are taken from special objects table.
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       // TObject and TString classes treated differently
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          // before normal streamer first version will be read and
00506          // then streamer functions of TStreamerInfo class
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    // Function is called from TStreamerInfo WriteBuffer and Readbuffer functions
00544    // and indent new level in data structure.
00545    // This call indicates, that TStreamerInfo functions starts streaming
00546    // object data of correspondent class
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    // Function is called from TStreamerInfo WriteBuffer and Readbuffer functions
00562    // and decrease level in sql structure.
00563 
00564    TSQLStructure* curr = Stack();
00565    if (curr->GetType()==TSQLStructure::kSqlElement) PopStack(); // for element
00566    PopStack();  // for streamerinfo
00567 
00568    // restore value of object data
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    // Function is called from TStreamerInfo WriteBuffer and Readbuffer functions
00581    // and add/verify next element in sql tables
00582    // This calls allows separate data, correspondent to one class member, from another
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    // This method inform buffer data of which class now
00608    // will be streamed. When reading, classversion should be specified
00609    // as was read by TBuffer::ReadVersion() call
00610    //
00611    // ClassBegin(), ClassEnd() & ClassMemeber() should be used in
00612    // custom class streamers to specify which kind of data are
00613    // now streamed to/from buffer. That information is used to correctly
00614    // convert class data to/from "normal" sql tables with meaningfull names
00615    // and correct datatypes. Without that functions data from custom streamer
00616    // will be saved as "raw" data in special _streamer_ table one value after another
00617    // Such MUST be used when object is written with standard ROOT streaming
00618    // procedure, but should be read back in custom streamer.
00619    // For example, custom streamer of TNamed class may look like:
00620 
00621 // void TNamed::Streamer(TBuffer &b)
00622 //   UInt_t R__s, R__c;
00623 //   if (b.IsReading()) {
00624 //      Version_t R__v = b.ReadVersion(&R__s, &R__c);
00625 //      b.ClassBegin(TNamed::Class(), R__v);
00626 //      b.ClassMember("TObject");
00627 //      TObject::Streamer(b);
00628 //      b.ClassMember("fName","TString");
00629 //      fName.Streamer(b);
00630 //      b.ClassMember("fTitle","TString");
00631 //      fTitle.Streamer(b);
00632 //      b.ClassEnd(TNamed::Class());
00633 //      b.SetBufferOffset(R__s+R__c+sizeof(UInt_t));
00634 //   } else {
00635 //      TNamed::Class()->WriteBuffer(b,this);
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    // Method indicates end of streaming of classdata in custom streamer.
00651    // See ClassBegin() method for more details.
00652 
00653    TSQLStructure* curr = Stack();
00654    if (curr->GetType()==TSQLStructure::kSqlCustomElement) PopStack(); // for element
00655    PopStack();  // for streamerinfo
00656 
00657    // restore value of object data
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    // Method indicates name and typename of class memeber,
00669    // which should be now streamed in custom streamer
00670    // Following combinations are supported:
00671    // 1. name = "ClassName", typeName = 0 or typename==ClassName
00672    //    This is a case, when data of parent class "ClassName" should be streamed.
00673    //    For instance, if class directly inherited from TObject, custom
00674    //    streamer should include following code:
00675    //    b.ClassMember("TObject");
00676    //    TObject::Streamer(b);
00677    // 2. Basic data type
00678    //      b.ClassMember("fInt","Int_t");
00679    //      b >> fInt;
00680    // 3. Array of basic data types
00681    //      b.ClassMember("fArr","Int_t", 5);
00682    //      b.ReadFastArray(fArr, 5);
00683    // 4. Object as data member
00684    //      b.ClassMemeber("fName","TString");
00685    //      fName.Streamer(b);
00686    // 5. Pointer on object as datamember
00687    //      b.ClassMemeber("fObj","TObject*");
00688    //      b.StreamObject(b);
00689    // arrsize1 and arrsize2 arguments (when specified) indicate first and
00690    // second dimension of array. Can be used for array of basic types.
00691    // For more details see ClassBegin() method description.
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    // return stack to CustomClass node
00798    if (Stack()->GetType()==TSQLStructure::kSqlCustomElement) PopStack();
00799 
00800    fExpectedChain = kFALSE;
00801 
00802    // we indicate that there is no streamerinfo
00803    WorkWithElement(elem, -1);
00804 }
00805 
00806 //______________________________________________________________________________
00807 void TBufferSQL2::WorkWithClass(const char* classname, Version_t classversion)
00808 {
00809    // This function is a part of IncrementLevel method.
00810    // Also used in StartClass method
00811 
00812    fExpectedChain = kFALSE;
00813 
00814    if (IsReading()) {
00815       Long64_t objid = 0;
00816 
00817 //      if ((fCurrentData!=0) && fCurrentData->VerifyDataType(sqlio::ObjectInst, kFALSE))
00818 //        if (!fCurrentData->IsBlobData()) Info("WorkWithClass","Big problem %s", fCurrentData->GetValue());
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    // This function is a part of SetStreamerElementNumber method.
00859    // It is introduced for reading of data for specified data memeber of class.
00860    // Used also in ReadFastArray methods to resolve problem of compressed data,
00861    // when several data memebers of the same basic type streamed with single ...FastArray call
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             // search again for object data while for BLOB it should be already assign
00892             fCurrentData = Stack()->GetObjectData(kTRUE);
00893          }
00894    }
00895 }
00896 
00897 //______________________________________________________________________________
00898 TClass* TBufferSQL2::ReadClass(const TClass*, UInt_t*)
00899 {
00900    // suppressed function of TBuffer
00901 
00902    return 0;
00903 }
00904 
00905 //______________________________________________________________________________
00906 void TBufferSQL2::WriteClass(const TClass*)
00907 {
00908    // suppressed function of TBuffer
00909 }
00910 
00911 //______________________________________________________________________________
00912 Int_t TBufferSQL2::CheckByteCount(UInt_t /*r_s */, UInt_t /*r_c*/, const TClass* /*cl*/)
00913 {
00914    // suppressed function of TBuffer
00915 
00916    return 0;
00917 }
00918 
00919 //______________________________________________________________________________
00920 Int_t  TBufferSQL2::CheckByteCount(UInt_t, UInt_t, const char*)
00921 {
00922    // suppressed function of TBuffer
00923 
00924    return 0;
00925 }
00926 
00927 //______________________________________________________________________________
00928 void TBufferSQL2::SetByteCount(UInt_t, Bool_t)
00929 {
00930    // suppressed function of TBuffer
00931 }
00932 
00933 //______________________________________________________________________________
00934 void TBufferSQL2::SkipVersion(const TClass *cl)
00935 {
00936    // Skip class version from I/O buffer.
00937    ReadVersion(0,0,cl);
00938 }
00939 
00940 //______________________________________________________________________________
00941 Version_t TBufferSQL2::ReadVersion(UInt_t *start, UInt_t *bcnt, const TClass *)
00942 {
00943    // read version value from buffer
00944    // actually version is normally defined by table name
00945    // and kept in intermediate variable fReadVersionBuffer
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 /* useBcnt */)
00975 {
00976    // Copies class version to buffer, but not writes it to sql immidiately
00977    // Version will be used to produce complete table
00978    // name, which will include class version
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    // Read object from buffer. Only used from TBuffer.
00993 
00994    return SqlReadObject(0);
00995 }
00996 
00997 //______________________________________________________________________________
00998 void TBufferSQL2::SkipObjectAny()
00999 {
01000    // ?????? Skip any kind of object from buffer
01001    // !!!!!! fix me, not yet implemented
01002    // Should be just skip of current column later
01003 }
01004 
01005 //______________________________________________________________________________
01006 void TBufferSQL2::WriteObjectClass(const void *actualObjStart, const TClass *actualClass)
01007 {
01008    // Write object to buffer. Only used from TBuffer
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 // macro to read content of array with compression
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 // macro to read array, which include size attribute
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 * /*ele*/)
01069 {
01070    // Read Float16 value
01071 
01072    SqlReadBasic(*f);
01073 }
01074 
01075 //______________________________________________________________________________
01076 void TBufferSQL2::ReadDouble32 (Double_t *d, TStreamerElement * /*ele*/)
01077 {
01078    // Read Double32 value
01079 
01080    SqlReadBasic(*d);
01081 }
01082 
01083 //______________________________________________________________________________
01084 void TBufferSQL2::ReadWithFactor(Float_t *ptr, Double_t /* factor */, Double_t /* minvalue */)
01085 {
01086    // Read a Double32_t from the buffer when the factor and minimun value have been specified
01087    // see comments about Double32_t encoding at TBufferFile::WriteDouble32().
01088    // Currently TBufferXML does not optimize space in this case.
01089    
01090    SqlReadBasic(*ptr);
01091 }
01092 
01093 //______________________________________________________________________________
01094 void TBufferSQL2::ReadWithNbits(Float_t *ptr, Int_t /* nbits */) 
01095 {
01096    // Read a Float16_t from the buffer when the number of bits is specified (explicitly or not)
01097    // see comments about Float16_t encoding at TBufferFile::WriteFloat16().
01098    // Currently TBufferXML does not optimize space in this case.
01099    
01100    SqlReadBasic(*ptr);
01101 }
01102 
01103 //______________________________________________________________________________
01104 void TBufferSQL2::ReadWithFactor(Double_t *ptr, Double_t /* factor */, Double_t /* minvalue */) 
01105 {
01106    // Read a Double32_t from the buffer when the factor and minimun value have been specified
01107    // see comments about Double32_t encoding at TBufferFile::WriteDouble32().   
01108    // Currently TBufferXML does not optimize space in this case.
01109    
01110    SqlReadBasic(*ptr);
01111 }
01112 
01113 //______________________________________________________________________________
01114 void TBufferSQL2::ReadWithNbits(Double_t *ptr, Int_t /* nbits */) 
01115 {
01116    // Read a Double32_t from the buffer when the number of bits is specified (explicitly or not)
01117    // see comments about Double32_t encoding at TBufferFile::WriteDouble32().   
01118    // Currently TBufferXML does not optimize space in this case.
01119    
01120    SqlReadBasic(*ptr);
01121 }
01122 
01123 //______________________________________________________________________________
01124 void TBufferSQL2::WriteFloat16 (Float_t *f, TStreamerElement * /*ele*/)
01125 {
01126    // Write Float16 value
01127 
01128    SqlWriteBasic(*f);
01129 }
01130 
01131 //______________________________________________________________________________
01132 void TBufferSQL2::WriteDouble32 (Double_t *d, TStreamerElement * /*ele*/)
01133 {
01134    // Write Double32 value
01135 
01136    SqlWriteBasic(*d);
01137 }
01138 
01139 //______________________________________________________________________________
01140 Int_t TBufferSQL2::ReadArray(Bool_t    *&b)
01141 {
01142    // Read array of Bool_t from buffer
01143 
01144    TBufferSQL2_ReadArray(Bool_t,b);
01145 }
01146 
01147 //______________________________________________________________________________
01148 Int_t TBufferSQL2::ReadArray(Char_t    *&c)
01149 {
01150    // Read array of Char_t from buffer
01151 
01152    TBufferSQL2_ReadArray(Char_t,c);
01153 }
01154 
01155 //______________________________________________________________________________
01156 Int_t TBufferSQL2::ReadArray(UChar_t   *&c)
01157 {
01158    // Read array of UChar_t from buffer
01159 
01160    TBufferSQL2_ReadArray(UChar_t,c);
01161 }
01162 
01163 //______________________________________________________________________________
01164 Int_t TBufferSQL2::ReadArray(Short_t   *&h)
01165 {
01166    // Read array of Short_t from buffer
01167 
01168    TBufferSQL2_ReadArray(Short_t,h);
01169 }
01170 
01171 //______________________________________________________________________________
01172 Int_t TBufferSQL2::ReadArray(UShort_t  *&h)
01173 {
01174    // Read array of UShort_t from buffer
01175 
01176    TBufferSQL2_ReadArray(UShort_t,h);
01177 }
01178 
01179 //______________________________________________________________________________
01180 Int_t TBufferSQL2::ReadArray(Int_t     *&i)
01181 {
01182    // Read array of Int_t from buffer
01183 
01184    TBufferSQL2_ReadArray(Int_t,i);
01185 }
01186 
01187 //______________________________________________________________________________
01188 Int_t TBufferSQL2::ReadArray(UInt_t    *&i)
01189 {
01190    // Read array of UInt_t from buffer
01191 
01192    TBufferSQL2_ReadArray(UInt_t,i);
01193 }
01194 
01195 //______________________________________________________________________________
01196 Int_t TBufferSQL2::ReadArray(Long_t    *&l)
01197 {
01198    // Read array of Long_t from buffer
01199 
01200    TBufferSQL2_ReadArray(Long_t,l);
01201 }
01202 
01203 //______________________________________________________________________________
01204 Int_t TBufferSQL2::ReadArray(ULong_t   *&l)
01205 {
01206    // Read array of ULong_t from buffer
01207 
01208    TBufferSQL2_ReadArray(ULong_t,l);
01209 }
01210 
01211 //______________________________________________________________________________
01212 Int_t TBufferSQL2::ReadArray(Long64_t  *&l)
01213 {
01214    // Read array of Long64_t from buffer
01215 
01216    TBufferSQL2_ReadArray(Long64_t,l);
01217 }
01218 
01219 //______________________________________________________________________________
01220 Int_t TBufferSQL2::ReadArray(ULong64_t *&l)
01221 {
01222    // Read array of ULong64_t from buffer
01223 
01224    TBufferSQL2_ReadArray(ULong64_t,l);
01225 }
01226 
01227 //______________________________________________________________________________
01228 Int_t TBufferSQL2::ReadArray(Float_t   *&f)
01229 {
01230    // Read array of Float_t from buffer
01231 
01232    TBufferSQL2_ReadArray(Float_t,f);
01233 }
01234 
01235 //______________________________________________________________________________
01236 Int_t TBufferSQL2::ReadArray(Double_t  *&d)
01237 {
01238    // Read array of Double_t from buffer
01239 
01240    TBufferSQL2_ReadArray(Double_t,d);
01241 }
01242 
01243 //______________________________________________________________________________
01244 Int_t TBufferSQL2::ReadArrayFloat16(Float_t  *&f, TStreamerElement * /*ele*/)
01245 {
01246    // Read array of Float16_t from buffer
01247 
01248    TBufferSQL2_ReadArray(Float_t,f);
01249 }
01250 
01251 //______________________________________________________________________________
01252 Int_t TBufferSQL2::ReadArrayDouble32(Double_t  *&d, TStreamerElement * /*ele*/)
01253 {
01254    // Read array of Double32_t from buffer
01255 
01256    TBufferSQL2_ReadArray(Double_t,d);
01257 }
01258 
01259 // macro to read static array, which include size attribute
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    // Read array of Bool_t from buffer
01273 
01274    TBufferSQL2_ReadStaticArray(b);
01275 }
01276 
01277 //______________________________________________________________________________
01278 Int_t TBufferSQL2::ReadStaticArray(Char_t    *c)
01279 {
01280    // Read array of Char_t from buffer
01281 
01282    TBufferSQL2_ReadStaticArray(c);
01283 }
01284 
01285 //______________________________________________________________________________
01286 Int_t TBufferSQL2::ReadStaticArray(UChar_t   *c)
01287 {
01288    // Read array of UChar_t from buffer
01289 
01290    TBufferSQL2_ReadStaticArray(c);
01291 }
01292 
01293 //______________________________________________________________________________
01294 Int_t TBufferSQL2::ReadStaticArray(Short_t   *h)
01295 {
01296    // Read array of Short_t from buffer
01297 
01298    TBufferSQL2_ReadStaticArray(h);
01299 }
01300 
01301 //______________________________________________________________________________
01302 Int_t TBufferSQL2::ReadStaticArray(UShort_t  *h)
01303 {
01304    // Read array of UShort_t from buffer
01305 
01306    TBufferSQL2_ReadStaticArray(h);
01307 }
01308 
01309 //______________________________________________________________________________
01310 Int_t TBufferSQL2::ReadStaticArray(Int_t     *i)
01311 {
01312    // Read array of Int_t from buffer
01313 
01314    TBufferSQL2_ReadStaticArray(i);
01315 }
01316 
01317 //______________________________________________________________________________
01318 Int_t TBufferSQL2::ReadStaticArray(UInt_t    *i)
01319 {
01320    // Read array of UInt_t from buffer
01321 
01322    TBufferSQL2_ReadStaticArray(i);
01323 }
01324 
01325 //______________________________________________________________________________
01326 Int_t TBufferSQL2::ReadStaticArray(Long_t    *l)
01327 {
01328    // Read array of Long_t from buffer
01329 
01330    TBufferSQL2_ReadStaticArray(l);
01331 }
01332 
01333 //______________________________________________________________________________
01334 Int_t TBufferSQL2::ReadStaticArray(ULong_t   *l)
01335 {
01336    // Read array of ULong_t from buffer
01337 
01338    TBufferSQL2_ReadStaticArray(l);
01339 }
01340 
01341 //______________________________________________________________________________
01342 Int_t TBufferSQL2::ReadStaticArray(Long64_t  *l)
01343 {
01344    // Read array of Long64_t from buffer
01345 
01346    TBufferSQL2_ReadStaticArray(l);
01347 }
01348 
01349 //______________________________________________________________________________
01350 Int_t TBufferSQL2::ReadStaticArray(ULong64_t *l)
01351 {
01352    // Read array of ULong64_t from buffer
01353 
01354    TBufferSQL2_ReadStaticArray(l);
01355 }
01356 
01357 //______________________________________________________________________________
01358 Int_t TBufferSQL2::ReadStaticArray(Float_t   *f)
01359 {
01360    // Read array of Float_t from buffer
01361 
01362    TBufferSQL2_ReadStaticArray(f);
01363 }
01364 
01365 //______________________________________________________________________________
01366 Int_t TBufferSQL2::ReadStaticArray(Double_t  *d)
01367 {
01368    // Read array of Double_t from buffer
01369 
01370    TBufferSQL2_ReadStaticArray(d);
01371 }
01372 
01373 //______________________________________________________________________________
01374 Int_t TBufferSQL2::ReadStaticArrayFloat16(Float_t  *f, TStreamerElement * /*ele*/)
01375 {
01376    // Read array of Float16_t from buffer
01377 
01378    TBufferSQL2_ReadStaticArray(f);
01379 }
01380 
01381 //______________________________________________________________________________
01382 Int_t TBufferSQL2::ReadStaticArrayDouble32(Double_t  *d, TStreamerElement * /*ele*/)
01383 {
01384    // Read array of Double32_t from buffer
01385 
01386    TBufferSQL2_ReadStaticArray(d);
01387 }
01388 
01389 // macro to read content of array, which not include size of array
01390 // macro also treat situation, when instead of one single array chain of several elements should be produced
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    // read array of Bool_t from buffer
01424 
01425    TBufferSQL2_ReadFastArray(b);
01426 }
01427 
01428 //______________________________________________________________________________
01429 void TBufferSQL2::ReadFastArray(Char_t    *c, Int_t n)
01430 {
01431    // read array of Char_t from buffer
01432    // if nodename==CharStar, read all array as string
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       //     cout << "call standard macro TBufferSQL2_ReadFastArray" << endl;
01443       TBufferSQL2_ReadFastArray(c);
01444    }
01445 }
01446 
01447 //______________________________________________________________________________
01448 void TBufferSQL2::ReadFastArray(UChar_t   *c, Int_t n)
01449 {
01450    // read array of UChar_t from buffer
01451 
01452    TBufferSQL2_ReadFastArray(c);
01453 }
01454 
01455 //______________________________________________________________________________
01456 void TBufferSQL2::ReadFastArray(Short_t   *h, Int_t n)
01457 {
01458    // read array of Short_t from buffer
01459 
01460    TBufferSQL2_ReadFastArray(h);
01461 }
01462 
01463 //______________________________________________________________________________
01464 void TBufferSQL2::ReadFastArray(UShort_t  *h, Int_t n)
01465 {
01466    // read array of UShort_t from buffer
01467 
01468    TBufferSQL2_ReadFastArray(h);
01469 }
01470 
01471 //______________________________________________________________________________
01472 void TBufferSQL2::ReadFastArray(Int_t     *i, Int_t n)
01473 {
01474    // read array of Int_t from buffer
01475 
01476    TBufferSQL2_ReadFastArray(i);
01477 }
01478 
01479 //______________________________________________________________________________
01480 void TBufferSQL2::ReadFastArray(UInt_t    *i, Int_t n)
01481 {
01482    // read array of UInt_t from buffer
01483 
01484    TBufferSQL2_ReadFastArray(i);
01485 }
01486 
01487 //______________________________________________________________________________
01488 void TBufferSQL2::ReadFastArray(Long_t    *l, Int_t n)
01489 {
01490    // read array of Long_t from buffer
01491 
01492    TBufferSQL2_ReadFastArray(l);
01493 }
01494 
01495 //______________________________________________________________________________
01496 void TBufferSQL2::ReadFastArray(ULong_t   *l, Int_t n)
01497 {
01498    // read array of ULong_t from buffer
01499 
01500    TBufferSQL2_ReadFastArray(l);
01501 }
01502 
01503 //______________________________________________________________________________
01504 void TBufferSQL2::ReadFastArray(Long64_t  *l, Int_t n)
01505 {
01506    // read array of Long64_t from buffer
01507 
01508    TBufferSQL2_ReadFastArray(l);
01509 }
01510 
01511 //______________________________________________________________________________
01512 void TBufferSQL2::ReadFastArray(ULong64_t *l, Int_t n)
01513 {
01514    // read array of ULong64_t from buffer
01515 
01516    TBufferSQL2_ReadFastArray(l);
01517 }
01518 
01519 //______________________________________________________________________________
01520 void TBufferSQL2::ReadFastArray(Float_t   *f, Int_t n)
01521 {
01522    // read array of Float_t from buffer
01523 
01524    TBufferSQL2_ReadFastArray(f);
01525 }
01526 
01527 //______________________________________________________________________________
01528 void TBufferSQL2::ReadFastArray(Double_t  *d, Int_t n)
01529 {
01530    // read array of Double_t from buffer
01531 
01532    TBufferSQL2_ReadFastArray(d);
01533 }
01534 
01535 //______________________________________________________________________________
01536 void TBufferSQL2::ReadFastArrayFloat16(Float_t  *f, Int_t n, TStreamerElement * /*ele*/)
01537 {
01538    // read array of Float16_t from buffer
01539 
01540    TBufferSQL2_ReadFastArray(f);
01541 }
01542 
01543 //______________________________________________________________________________
01544 void TBufferSQL2::ReadFastArrayDouble32(Double_t  *d, Int_t n, TStreamerElement * /*ele*/)
01545 {
01546    // read array of Double32_t from buffer
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    // Same functionality as TBuffer::ReadFastArray(...) but
01555    // instead of calling cl->Streamer(obj,buf) call here
01556    // buf.StreamObject(obj, cl). In that case it is easy to understand where
01557    // object data is started and finished
01558 
01559    if (gDebug>2)
01560       Info("ReadFastArray","(void *");
01561 
01562    if (streamer) {
01563       StreamObject(start, streamer, cl, 0, onFileClass);
01564 //      (*streamer)(*this,start,0);
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    //   TBuffer::ReadFastArray(start, cl, n, s);
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    // Same functionality as TBuffer::ReadFastArray(...) but
01582    // instead of calling cl->Streamer(obj,buf) call here
01583    // buf.StreamObject(obj, cl). In that case it is easy to understand where
01584    // object data is started and finished
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 //      (*streamer)(*this,(void*)start,0);
01597       return;
01598    }
01599 
01600    if (!isPreAlloc) {
01601 
01602       for (Int_t j=0; j<n; j++){
01603          //delete the object or collection
01604          if (start[j] && TStreamerInfo::CanDelete()) ((TClass*)cl)->Destructor(start[j],kFALSE); // call delete and desctructor
01605          start[j] = ReadObjectAny(cl);
01606       }
01607 
01608    } else {   //case //-> in comment
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    //   TBuffer::ReadFastArray(startp, cl, n, isPreAlloc, s);
01620 }
01621 
01622 //______________________________________________________________________________
01623 Int_t TBufferSQL2::SqlReadArraySize()
01624 {
01625    // Reads array size, written in raw data table.
01626    // Used in ReadArray methods, where TBuffer need to read array size first.
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 // macro to write content of noncompressed array, not used
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 // macro to write content of compressed array
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 // macro to write array, which include size
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    // Write array of Bool_t to buffer
01676 
01677    TBufferSQL2_WriteArray(b);
01678 }
01679 
01680 //______________________________________________________________________________
01681 void TBufferSQL2::WriteArray(const Char_t    *c, Int_t n)
01682 {
01683    // Write array of Char_t to buffer
01684 
01685    TBufferSQL2_WriteArray(c);
01686 }
01687 
01688 //______________________________________________________________________________
01689 void TBufferSQL2::WriteArray(const UChar_t   *c, Int_t n)
01690 {
01691    // Write array of UChar_t to buffer
01692 
01693    TBufferSQL2_WriteArray(c);
01694 }
01695 
01696 //______________________________________________________________________________
01697 void TBufferSQL2::WriteArray(const Short_t   *h, Int_t n)
01698 {
01699    // Write array of Short_t to buffer
01700 
01701    TBufferSQL2_WriteArray(h);
01702 }
01703 
01704 //______________________________________________________________________________
01705 void TBufferSQL2::WriteArray(const UShort_t  *h, Int_t n)
01706 {
01707    // Write array of UShort_t to buffer
01708 
01709    TBufferSQL2_WriteArray(h);
01710 }
01711 
01712 //______________________________________________________________________________
01713 void TBufferSQL2::WriteArray(const Int_t     *i, Int_t n)
01714 {
01715    // Write array of Int_ to buffer
01716 
01717    TBufferSQL2_WriteArray(i);
01718 }
01719 
01720 //______________________________________________________________________________
01721 void TBufferSQL2::WriteArray(const UInt_t    *i, Int_t n)
01722 {
01723    // Write array of UInt_t to buffer
01724 
01725    TBufferSQL2_WriteArray(i);
01726 }
01727 
01728 //______________________________________________________________________________
01729 void TBufferSQL2::WriteArray(const Long_t    *l, Int_t n)
01730 {
01731    // Write array of Long_t to buffer
01732 
01733    TBufferSQL2_WriteArray(l);
01734 }
01735 
01736 //______________________________________________________________________________
01737 void TBufferSQL2::WriteArray(const ULong_t   *l, Int_t n)
01738 {
01739    // Write array of ULong_t to buffer
01740 
01741    TBufferSQL2_WriteArray(l);
01742 }
01743 
01744 //______________________________________________________________________________
01745 void TBufferSQL2::WriteArray(const Long64_t  *l, Int_t n)
01746 {
01747    // Write array of Long64_t to buffer
01748 
01749    TBufferSQL2_WriteArray(l);
01750 }
01751 
01752 //______________________________________________________________________________
01753 void TBufferSQL2::WriteArray(const ULong64_t *l, Int_t n)
01754 {
01755    // Write array of ULong64_t to buffer
01756 
01757    TBufferSQL2_WriteArray(l);
01758 }
01759 
01760 //______________________________________________________________________________
01761 void TBufferSQL2::WriteArray(const Float_t   *f, Int_t n)
01762 {
01763    // Write array of Float_t to buffer
01764 
01765    TBufferSQL2_WriteArray(f);
01766 }
01767 
01768 //______________________________________________________________________________
01769 void TBufferSQL2::WriteArray(const Double_t  *d, Int_t n)
01770 {
01771    // Write array of Double_t to buffer
01772 
01773    TBufferSQL2_WriteArray(d);
01774 }
01775 
01776 //______________________________________________________________________________
01777 void TBufferSQL2::WriteArrayFloat16(const Float_t  *f, Int_t n, TStreamerElement * /*ele*/)
01778 {
01779    // Write array of Float16_t to buffer
01780 
01781    TBufferSQL2_WriteArray(f);
01782 }
01783 
01784 //______________________________________________________________________________
01785 void TBufferSQL2::WriteArrayDouble32(const Double_t  *d, Int_t n, TStreamerElement * /*ele*/)
01786 {
01787    // Write array of Double32_t to buffer
01788 
01789    TBufferSQL2_WriteArray(d);
01790 }
01791 
01792 // write array without size attribute
01793 // macro also treat situation, when instead of one single array chain of several elements should be produced
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    // Write array of Bool_t to buffer
01828 
01829    TBufferSQL2_WriteFastArray(b);
01830 }
01831 
01832 //______________________________________________________________________________
01833 void TBufferSQL2::WriteFastArray(const Char_t    *c, Int_t n)
01834 {
01835    // Write array of Char_t to buffer
01836    // it will be reproduced as CharStar node with string as attribute
01837 
01838    Bool_t usedefault = (n==0) || fExpectedChain;
01839 
01840    const Char_t* ccc = c;
01841    // check if no zeros in the array
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    // Write array of UChar_t to buffer
01861 
01862    TBufferSQL2_WriteFastArray(c);
01863 }
01864 
01865 //______________________________________________________________________________
01866 void TBufferSQL2::WriteFastArray(const Short_t   *h, Int_t n)
01867 {
01868    // Write array of Short_t to buffer
01869 
01870    TBufferSQL2_WriteFastArray(h);
01871 }
01872 
01873 //______________________________________________________________________________
01874 void TBufferSQL2::WriteFastArray(const UShort_t  *h, Int_t n)
01875 {
01876    // Write array of UShort_t to buffer
01877 
01878    TBufferSQL2_WriteFastArray(h);
01879 }
01880 
01881 //______________________________________________________________________________
01882 void TBufferSQL2::WriteFastArray(const Int_t     *i, Int_t n)
01883 {
01884    // Write array of Int_t to buffer
01885 
01886    TBufferSQL2_WriteFastArray(i);
01887 }
01888 
01889 //______________________________________________________________________________
01890 void TBufferSQL2::WriteFastArray(const UInt_t    *i, Int_t n)
01891 {
01892    // Write array of UInt_t to buffer
01893 
01894    TBufferSQL2_WriteFastArray(i);
01895 }
01896 
01897 //______________________________________________________________________________
01898 void TBufferSQL2::WriteFastArray(const Long_t    *l, Int_t n)
01899 {
01900    // Write array of Long_t to buffer
01901 
01902    TBufferSQL2_WriteFastArray(l);
01903 }
01904 
01905 //______________________________________________________________________________
01906 void TBufferSQL2::WriteFastArray(const ULong_t   *l, Int_t n)
01907 {
01908    // Write array of ULong_t to buffer
01909 
01910    TBufferSQL2_WriteFastArray(l);
01911 }
01912 
01913 //______________________________________________________________________________
01914 void TBufferSQL2::WriteFastArray(const Long64_t  *l, Int_t n)
01915 {
01916    // Write array of Long64_t to buffer
01917 
01918    TBufferSQL2_WriteFastArray(l);
01919 }
01920 
01921 //______________________________________________________________________________
01922 void TBufferSQL2::WriteFastArray(const ULong64_t *l, Int_t n)
01923 {
01924    // Write array of ULong64_t to buffer
01925 
01926    TBufferSQL2_WriteFastArray(l);
01927 }
01928 
01929 //______________________________________________________________________________
01930 void TBufferSQL2::WriteFastArray(const Float_t   *f, Int_t n)
01931 {
01932    // Write array of Float_t to buffer
01933 
01934    TBufferSQL2_WriteFastArray(f);
01935 }
01936 
01937 //______________________________________________________________________________
01938 void TBufferSQL2::WriteFastArray(const Double_t  *d, Int_t n)
01939 {
01940    // Write array of Double_t to buffer
01941 
01942    TBufferSQL2_WriteFastArray(d);
01943 }
01944 
01945 //______________________________________________________________________________
01946 void TBufferSQL2::WriteFastArrayFloat16(const Float_t  *f, Int_t n, TStreamerElement * /*ele*/)
01947 {
01948    // Write array of Float16_t to buffer
01949 
01950    TBufferSQL2_WriteFastArray(f);
01951 }
01952 
01953 //______________________________________________________________________________
01954 void TBufferSQL2::WriteFastArrayDouble32(const Double_t  *d, Int_t n, TStreamerElement * /*ele*/)
01955 {
01956    // Write array of Double32_t to buffer
01957 
01958    TBufferSQL2_WriteFastArray(d);
01959 }
01960 
01961 //______________________________________________________________________________
01962 void  TBufferSQL2::WriteFastArray(void  *start,  const TClass *cl, Int_t n, TMemberStreamer *streamer)
01963 {
01964    // Same functionality as TBuffer::WriteFastArray(...) but
01965    // instead of calling cl->Streamer(obj,buf) call here
01966    // buf.StreamObject(obj, cl). In that case it is easy to understand where
01967    // object data is started and finished
01968 
01969    if (streamer) {
01970       StreamObject(start, streamer, cl, 0);
01971 //      (*streamer)(*this, start, 0);
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    //   TBuffer::WriteFastArray(start, cl, n, s);
01983 }
01984 
01985 //______________________________________________________________________________
01986 Int_t TBufferSQL2::WriteFastArray(void **start, const TClass *cl, Int_t n, Bool_t isPreAlloc, TMemberStreamer *streamer)
01987 {
01988    // Same functionality as TBuffer::WriteFastArray(...) but
01989    // instead of calling cl->Streamer(obj,buf) call here
01990    // buf.StreamObject(obj, cl). In that case it is easy to understand where
01991    // object data is started and finished
01992 
01993    if (streamer) {
01994       StreamObject((void*) start, streamer, cl, 0);
01995 //      (*streamer)(*this,(void*)start,0);
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          //must write StreamerInfo if pointer is null
02007          if (!strInfo && !start[j] ) ForceWriteInfo(((TClass*)cl)->GetStreamerInfo(),kFALSE);
02008          strInfo = 2003;
02009          res |= WriteObjectAny(start[j],cl);
02010       }
02011 
02012    } else {     //case //-> in comment
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 //   return TBuffer::WriteFastArray(startp, cl, n, isPreAlloc, s);
02023 }
02024 
02025 //______________________________________________________________________________
02026 void TBufferSQL2::StreamObject(void *obj, const type_info &typeinfo, const TClass *onFileClass)
02027 {
02028    // steram object to/from buffer
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    // steram object to/from buffer
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    // steram object to/from buffer
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    // steram object to/from buffer
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    // steram object to/from buffer
02066 
02067    if (streamer==0) return;
02068 
02069    if (gDebug>1)
02070       cout << "Stream object of class = " << cl->GetName() << endl;
02071 //   (*streamer)(*this, obj, n);
02072 
02073    if (IsReading())
02074       SqlReadObject(obj, 0, streamer, n, onFileClass);
02075    else
02076       SqlWriteObject(obj, cl, streamer, n);
02077 }
02078 
02079 // macro for right shift operator for basic type
02080 #define TBufferSQL2_operatorin(vname)           \
02081    {                                            \
02082       SqlReadBasic(vname);                      \
02083    }
02084 
02085 //______________________________________________________________________________
02086 void TBufferSQL2::ReadBool(Bool_t    &b)
02087 {
02088    // Reads Bool_t value from buffer
02089 
02090    TBufferSQL2_operatorin(b);
02091 }
02092 
02093 //______________________________________________________________________________
02094 void TBufferSQL2::ReadChar(Char_t    &c)
02095 {
02096    // Reads Char_t value from buffer
02097 
02098    TBufferSQL2_operatorin(c);
02099 }
02100 
02101 //______________________________________________________________________________
02102 void TBufferSQL2::ReadUChar(UChar_t   &c)
02103 {
02104    // Reads UChar_t value from buffer
02105 
02106    TBufferSQL2_operatorin(c);
02107 }
02108 
02109 //______________________________________________________________________________
02110 void TBufferSQL2::ReadShort(Short_t   &h)
02111 {
02112    // Reads Short_t value from buffer
02113 
02114    TBufferSQL2_operatorin(h);
02115 }
02116 
02117 //______________________________________________________________________________
02118 void TBufferSQL2::ReadUShort(UShort_t  &h)
02119 {
02120    // Reads UShort_t value from buffer
02121 
02122    TBufferSQL2_operatorin(h);
02123 }
02124 
02125 //______________________________________________________________________________
02126 void TBufferSQL2::ReadInt(Int_t     &i)
02127 {
02128    // Reads Int_t value from buffer
02129 
02130    TBufferSQL2_operatorin(i);
02131 }
02132 
02133 //______________________________________________________________________________
02134 void TBufferSQL2::ReadUInt(UInt_t    &i)
02135 {
02136    // Reads UInt_t value from buffer
02137 
02138    TBufferSQL2_operatorin(i);
02139 }
02140 
02141 //______________________________________________________________________________
02142 void TBufferSQL2::ReadLong(Long_t    &l)
02143 {
02144    // Reads Long_t value from buffer
02145 
02146    TBufferSQL2_operatorin(l);
02147 }
02148 
02149 //______________________________________________________________________________
02150 void TBufferSQL2::ReadULong(ULong_t   &l)
02151 {
02152    // Reads ULong_t value from buffer
02153 
02154    TBufferSQL2_operatorin(l);
02155 }
02156 
02157 //______________________________________________________________________________
02158 void TBufferSQL2::ReadLong64(Long64_t  &l)
02159 {
02160    // Reads Long64_t value from buffer
02161 
02162    TBufferSQL2_operatorin(l);
02163 }
02164 
02165 //______________________________________________________________________________
02166 void TBufferSQL2::ReadULong64(ULong64_t &l)
02167 {
02168    // Reads ULong64_t value from buffer
02169 
02170    TBufferSQL2_operatorin(l);
02171 }
02172 
02173 //______________________________________________________________________________
02174 void TBufferSQL2::ReadFloat(Float_t   &f)
02175 {
02176    // Reads Float_t value from buffer
02177 
02178    TBufferSQL2_operatorin(f);
02179 }
02180 
02181 //______________________________________________________________________________
02182 void TBufferSQL2::ReadDouble(Double_t  &d)
02183 {
02184    // Reads Double_t value from buffer
02185 
02186    TBufferSQL2_operatorin(d);
02187 }
02188 
02189 //______________________________________________________________________________
02190 void TBufferSQL2::ReadCharP(Char_t    *c)
02191 {
02192    // Reads array of characters from buffer
02193 
02194    const char* buf = SqlReadCharStarValue();
02195    strcpy(c, buf);
02196 }
02197 
02198 //________________________________________________________________________
02199 void TBufferSQL2::ReadTString(TString   &)
02200 {
02201    // Operator>>
02202 
02203    //strcpy(str,(*fRowPtr)->GetField(*fIter));
02204    //if (fIter != fColumnVec->end()) ++fIter;
02205    printf("ERROR NOT IMPLEMENTED\n");
02206 }
02207 
02208 //________________________________________________________________________
02209 void TBufferSQL2::WriteTString(const TString   &)
02210 {
02211    // Operator>>
02212 
02213    //strcpy(str,(*fRowPtr)->GetField(*fIter));
02214    //if (fIter != fColumnVec->end()) ++fIter;
02215    printf("ERROR NOT IMPLEMENTED\n");
02216 }
02217 
02218 // macro for right shift operator for basic types
02219 #define TBufferSQL2_operatorout(vname)          \
02220    {                                            \
02221       SqlWriteBasic(vname);                     \
02222    }
02223 
02224 //______________________________________________________________________________
02225 void TBufferSQL2::WriteBool(Bool_t    b)
02226 {
02227    // Writes Bool_t value to buffer
02228 
02229    TBufferSQL2_operatorout(b);
02230 }
02231 
02232 //______________________________________________________________________________
02233 void TBufferSQL2::WriteChar(Char_t    c)
02234 {
02235    // Writes Char_t value to buffer
02236 
02237    TBufferSQL2_operatorout(c);
02238 }
02239 
02240 //______________________________________________________________________________
02241 void TBufferSQL2::WriteUChar(UChar_t   c)
02242 {
02243    // Writes UChar_t value to buffer
02244 
02245    TBufferSQL2_operatorout(c);
02246 }
02247 
02248 //______________________________________________________________________________
02249 void TBufferSQL2::WriteShort(Short_t   h)
02250 {
02251    // Writes Short_t value to buffer
02252 
02253    TBufferSQL2_operatorout(h);
02254 }
02255 
02256 //______________________________________________________________________________
02257 void TBufferSQL2::WriteUShort(UShort_t  h)
02258 {
02259    // Writes UShort_t value to buffer
02260 
02261    TBufferSQL2_operatorout(h);
02262 }
02263 
02264 //______________________________________________________________________________
02265 void TBufferSQL2::WriteInt(Int_t     i)
02266 {
02267    // Writes Int_t value to buffer
02268 
02269    TBufferSQL2_operatorout(i);
02270 }
02271 
02272 //______________________________________________________________________________
02273 void TBufferSQL2::WriteUInt(UInt_t    i)
02274 {
02275    // Writes UInt_t value to buffer
02276 
02277    TBufferSQL2_operatorout(i);
02278 }
02279 
02280 //______________________________________________________________________________
02281 void TBufferSQL2::WriteLong(Long_t    l)
02282 {
02283    // Writes Long_t value to buffer
02284 
02285    TBufferSQL2_operatorout(l);
02286 }
02287 
02288 //______________________________________________________________________________
02289 void TBufferSQL2::WriteULong(ULong_t   l)
02290 {
02291    // Writes ULong_t value to buffer
02292 
02293    TBufferSQL2_operatorout(l);
02294 }
02295 
02296 //______________________________________________________________________________
02297 void TBufferSQL2::WriteLong64(Long64_t  l)
02298 {
02299    // Writes Long64_t value to buffer
02300 
02301    TBufferSQL2_operatorout(l);
02302 }
02303 
02304 //______________________________________________________________________________
02305 void TBufferSQL2::WriteULong64(ULong64_t l)
02306 {
02307    // Writes ULong64_t value to buffer
02308 
02309    TBufferSQL2_operatorout(l);
02310 }
02311 
02312 //______________________________________________________________________________
02313 void TBufferSQL2::WriteFloat(Float_t   f)
02314 {
02315    // Writes Float_t value to buffer
02316 
02317    TBufferSQL2_operatorout(f);
02318 }
02319 
02320 //______________________________________________________________________________
02321 void TBufferSQL2::WriteDouble(Double_t  d)
02322 {
02323    // Writes Double_t value to buffer
02324 
02325    TBufferSQL2_operatorout(d);
02326 }
02327 
02328 //______________________________________________________________________________
02329 void TBufferSQL2::WriteCharP(const Char_t *c)
02330 {
02331    // Writes array of characters to buffer
02332 
02333    SqlWriteValue(c, sqlio::CharStar);
02334 }
02335 
02336 //______________________________________________________________________________
02337 Bool_t TBufferSQL2::SqlWriteBasic(Char_t value)
02338 {
02339    // converts Char_t to string and creates correspondent sql structure
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    // converts Short_t to string and creates correspondent sql structure
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    // converts Int_t to string and creates correspondent sql structure
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    // converts Long_t to string and creates correspondent sql structure
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    // converts Long64_t to string and creates correspondent sql structure
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    // converts Float_t to string and creates correspondent sql structure
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    // converts Double_t to string and creates correspondent sql structure
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    // converts Bool_t to string and creates correspondent sql structure
02410 
02411    return SqlWriteValue(value ? sqlio::True : sqlio::False, sqlio::Bool);
02412 }
02413 
02414 //______________________________________________________________________________
02415 Bool_t TBufferSQL2::SqlWriteBasic(UChar_t value)
02416 {
02417    // converts UChar_t to string and creates correspondent sql structure
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    // converts UShort_t to string and creates correspondent sql structure
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    // converts UInt_t to string and creates correspondent sql structure
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    // converts ULong_t to string and creates correspondent sql structure
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    // converts ULong64_t to string and creates correspondent sql structure
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    // create structure in stack, which holds specified value
02469 
02470    Stack()->AddValue(value, tname);
02471 
02472    return kTRUE;
02473 }
02474 
02475 //______________________________________________________________________________
02476 void TBufferSQL2::SqlReadBasic(Char_t& value)
02477 {
02478    // read current value from table and convert it to Char_t value
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    // read current value from table and convert it to Short_t value
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    // read current value from table and convert it to Int_t value
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    // read current value from table and convert it to Long_t value
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    // read current value from table and convert it to Long64_t value
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    // read current value from table and convert it to Float_t value
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    // read current value from table and convert it to Double_t value
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    // read current value from table and convert it to Bool_t value
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    // read current value from table and convert it to UChar_t value
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    // read current value from table and convert it to UShort_t value
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    // read current value from table and convert it to UInt_t value
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    // read current value from table and convert it to ULong_t value
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    // read current value from table and convert it to ULong64_t value
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    // read string value from current stack node
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    // read CharStar value, if it has special code, request it from large table
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    // Push stack with structurual information about streamed object
02686 
02687    TSQLStructure* res = new TSQLStructure;
02688    if (fStk==0) {
02689       fStructure = res;
02690    } else {
02691       fStk->Add(res);
02692    }
02693 
02694    fStk = res;   // add in the stack
02695    return fStk;
02696 }
02697 
02698 //______________________________________________________________________________
02699 TSQLStructure* TBufferSQL2::PopStack()
02700 {
02701    // Pop stack
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    // returns head of stack
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    // set printf format for float/double members, default "%e"
02723    // changes global TSQLServer variable
02724 
02725    TSQLServer::SetFloatFormat(fmt);
02726 }
02727 
02728 //______________________________________________________________________________
02729 const char* TBufferSQL2::GetFloatFormat()
02730 {
02731    // return current printf format for float/double members, default "%e"
02732    // return format, hold by TSQLServer
02733 
02734    return TSQLServer::GetFloatFormat();
02735 }
02736 
02737 //______________________________________________________________________________
02738 Int_t TBufferSQL2::ReadSequence(const TStreamerInfoActions::TActionSequence &sequence, void *obj) 
02739 {
02740    // Read one collection of objects from the buffer using the StreamerInfoLoopAction.
02741    // The collection needs to be a split TClonesArray or a split vector of pointers.
02742    
02743    TVirtualStreamerInfo *info = sequence.fStreamerInfo;
02744    IncrementLevel(info);
02745    
02746    if (gDebug) {
02747       //loop on all active members
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          // Idea: Try to remove this function call as it is really needed only for XML streaming.
02753          SetStreamerElementNumber((*iter).fConfiguration->fElemId);
02754          (*iter).PrintDebug(*this,obj);
02755          (*iter)(*this,obj);
02756       }
02757       
02758    } else {
02759       //loop on all active members
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          // Idea: Try to remove this function call as it is really needed only for XML streaming.
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    // Read one collection of objects from the buffer using the StreamerInfoLoopAction.
02778    // The collection needs to be a split TClonesArray or a split vector of pointers.
02779    
02780    TVirtualStreamerInfo *info = sequence.fStreamerInfo;
02781    IncrementLevel(info);
02782    
02783    if (gDebug) {
02784       //loop on all active members
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          // Idea: Try to remove this function call as it is really needed only for XML streaming.
02790          SetStreamerElementNumber((*iter).fConfiguration->fElemId);
02791          (*iter).PrintDebug(*this,*(char**)start_collection);  // Warning: This limits us to TClonesArray and vector of pointers.
02792          (*iter)(*this,start_collection,end_collection);
02793       }
02794       
02795    } else {
02796       //loop on all active members
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          // Idea: Try to remove this function call as it is really needed only for XML streaming.
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    // Read one collection of objects from the buffer using the StreamerInfoLoopAction.
02815    
02816    TVirtualStreamerInfo *info = sequence.fStreamerInfo;
02817    IncrementLevel(info);
02818    
02819    TStreamerInfoActions::TLoopConfiguration *loopconfig = sequence.fLoopConfig;
02820    if (gDebug) {
02821       
02822       // Get the address of the first item for the PrintDebug.
02823       // (Performance is not essential here since we are going to print to
02824       // the screen anyway).
02825       void *arr0 = loopconfig->GetFirstAddress(start_collection,end_collection);
02826       // loop on all active members
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          // Idea: Try to remove this function call as it is really needed only for XML streaming.
02832          SetStreamerElementNumber((*iter).fConfiguration->fElemId);
02833          (*iter).PrintDebug(*this,arr0);
02834          (*iter)(*this,start_collection,end_collection,loopconfig);
02835       }
02836       
02837    } else {
02838       //loop on all active members
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          // Idea: Try to remove this function call as it is really needed only for XML streaming.
02844          SetStreamerElementNumber((*iter).fConfiguration->fElemId);
02845          (*iter)(*this,start_collection,end_collection,loopconfig);
02846       }
02847    }
02848    
02849    DecrementLevel(info);
02850    return 0;
02851 }
02852 

Generated on Tue Jul 5 14:30:32 2011 for ROOT_528-00b_version by  doxygen 1.5.1