#include "TROOT.h"
#include "TStreamerElement.h"
#include "TStreamerInfo.h"
#include "TClass.h"
#include "TClassEdit.h"
#include "TBaseClass.h"
#include "TDataMember.h"
#include "TDataType.h"
#include "TMethodCall.h"
#include "TRealData.h"
#include "TFolder.h"
#include "TRef.h"
#include "Api.h"
#include "TInterpreter.h"
#include "TError.h"
#include <string>
namespace std {} using namespace std;
const Int_t kMaxLen = 1024;
static char gIncludeName[kMaxLen];
static TStreamerBasicType *InitCounter(const char *countClass, const char *countName)
{
TClass *cl = gROOT->GetClass(countClass);
if (cl==0) return 0;
TStreamerBasicType *counter = TStreamerInfo::GetElementCounter(countName,cl);
if (counter) {
if (counter->GetType() < TStreamerInfo::kCounter) counter->SetType(TStreamerInfo::kCounter);
}
return counter;
}
static void GetRange(const char *comments, Double_t &xmin, Double_t &xmax, Double_t &factor)
{
factor = xmin = xmax = 0;
if (!comments) return;
const char *left = strstr(comments,"[");
if (!left) return;
const char *right = strstr(left,"]");
if (!right) return;
const char *comma = strstr(left,",");
if (!comma || comma > right) {
left = strstr(right,"[");
if (!left) return;
right = strstr(left,"]");
if (!right) return;
comma = strstr(left,",");
if (!comma || comma >right) return;
}
const char *comma2 = 0;
if (comma) comma2 = strstr(comma+1,",");
if (comma2 > right) comma2 = 0;
Int_t nbits = 32;
if (comma2) {
TString sbits(comma2+1,right-comma2-1);
sscanf(sbits.Data(),"%d",&nbits);
if (nbits < 2 || nbits > 32) {
::Error("GetRange","Illegal specification for the number of bits; %d. reset to 32.",nbits);
nbits = 32;
}
right = comma2;
}
TString range(left+1,right-left-1);
TString sxmin(left+1,comma-left-1);
sxmin.ToLower();
sxmin.ReplaceAll(" ","");
if (sxmin.Contains("pi")) {
if (sxmin.Contains("2pi")) xmin = TMath::TwoPi();
else if (sxmin.Contains("2*pi")) xmin = TMath::TwoPi();
else if (sxmin.Contains("twopi")) xmin = TMath::TwoPi();
else if (sxmin.Contains("pi/2")) xmin = TMath::PiOver2();
else if (sxmin.Contains("pi/4")) xmin = TMath::PiOver4();
else if (sxmin.Contains("pi")) xmin = TMath::Pi();
if (sxmin.Contains("-")) xmin = -xmin;
} else {
sscanf(sxmin.Data(),"%lg",&xmin);
}
TString sxmax(comma+1,right-comma-1);
sxmax.ToLower();
sxmax.ReplaceAll(" ","");
if (sxmax.Contains("pi")) {
if (sxmax.Contains("2pi")) xmax = TMath::TwoPi();
else if (sxmax.Contains("2*pi")) xmax = TMath::TwoPi();
else if (sxmax.Contains("twopi")) xmax = TMath::TwoPi();
else if (sxmax.Contains("pi/2")) xmax = TMath::PiOver2();
else if (sxmax.Contains("pi/4")) xmax = TMath::PiOver4();
else if (sxmax.Contains("pi")) xmax = TMath::Pi();
if (sxmax.Contains("-")) xmax = -xmax;
} else {
sscanf(sxmax.Data(),"%lg",&xmax);
}
UInt_t bigint;
if (nbits < 32) bigint = 1<<nbits;
else bigint = 0xffffffff;
if (xmin < xmax) factor = bigint/(xmax-xmin);
}
ClassImp(TStreamerElement)
TStreamerElement::TStreamerElement()
{
fType = 0;
fSize = 0;
fNewType = 0;
fArrayDim = 0;
fArrayLength = 0;
fStreamer = 0;
fMethod = 0;
fOffset = 0;
fClassObject = (TClass*)(-1);
fTObjectOffset = 0;
fFactor = 0;
fXmin = 0;
fXmax = 0;
for (Int_t i=0;i<5;i++) fMaxIndex[i] = 0;
}
TStreamerElement::TStreamerElement(const char *name, const char *title, Int_t offset, Int_t dtype, const char *typeName)
: TNamed(name,title)
{
fOffset = offset;
fType = dtype;
fSize = 0;
fNewType = fType;
fArrayDim = 0;
fArrayLength = 0;
fTypeName = TClassEdit::ResolveTypedef(typeName);
fStreamer = 0;
fMethod = 0;
fClassObject = (TClass*)(-1);
fTObjectOffset = 0;
fFactor = 0;
fXmin = 0;
fXmax = 0;
for (Int_t i=0;i<5;i++) fMaxIndex[i] = 0;
if (fTypeName == "Double32_t") {
GetRange(title,fXmin,fXmax,fFactor);
if (fFactor > 0) SetBit(kHasRange);
}
}
TStreamerElement::~TStreamerElement()
{
delete fMethod;
}
Bool_t TStreamerElement::CannotSplit() const
{
if (strspn(GetTitle(),"||") == 2) return kTRUE;
TClass *cl = GetClassPointer();
if (!cl) return kFALSE;
switch(fType) {
case TStreamerInfo::kAny +TStreamerInfo::kOffsetL:
case TStreamerInfo::kObject +TStreamerInfo::kOffsetL:
case TStreamerInfo::kTObject+TStreamerInfo::kOffsetL:
case TStreamerInfo::kTString+TStreamerInfo::kOffsetL:
case TStreamerInfo::kTNamed +TStreamerInfo::kOffsetL:
return kTRUE;
}
if ( !cl->CanSplit() ) return kTRUE;
return kFALSE;
}
TClass *TStreamerElement::GetClassPointer() const
{
if (fClassObject!=(TClass*)(-1)) return fClassObject;
TString className = fTypeName.Strip(TString::kTrailing, '*');
if (className.Index("const ")==0) className.Remove(0,6);
((TStreamerElement*)this)->fClassObject = gROOT->GetClass(className);
return fClassObject;
}
Int_t TStreamerElement::GetExecID() const
{
if (strncmp(fTypeName.Data(),"TRef",4) != 0) return 0;
if (GetUniqueID()) return GetUniqueID();
char *action = (char*)strstr(GetTitle(),"EXEC:");
if (!action) return 0;
char caction[512];
strcpy(caction,action+5);
char *blank = (char*)strchr(caction,' ');
if (blank) *blank = 0;
Int_t index = TRef::AddExec(caction);
((TStreamerElement*)this)->SetUniqueID(index+1);
return index+1;
}
const char *TStreamerElement::GetFullName() const
{
static char name[kMaxLen];
char cdim[20];
sprintf(name,GetName());
for (Int_t i=0;i<fArrayDim;i++) {
sprintf(cdim,"[%d]",fMaxIndex[i]);
strcat(name,cdim);
}
return name;
}
Int_t TStreamerElement::GetSize() const
{
return fSize;
}
TMemberStreamer *TStreamerElement::GetStreamer() const
{
return fStreamer;
}
const char *TStreamerElement::GetTypeNameBasic() const
{
TDataType *dt = gROOT->GetType(fTypeName.Data());
if (fType < 1 || fType > 55) return fTypeName.Data();
if (dt && dt->GetType() > 0) return fTypeName.Data();
Int_t dtype = fType%20;
return TDataType::GetTypeName((EDataType)dtype);
}
void TStreamerElement::Init(TObject *)
{
fClassObject = GetClassPointer();
if (fClassObject && fClassObject->InheritsFrom(TObject::Class())) {
fTObjectOffset = fClassObject->GetBaseClassOffset(TObject::Class());
}
}
Bool_t TStreamerElement::IsOldFormat(const char *newTypeName)
{
if (!strstr(newTypeName,fTypeName.Data())) return kFALSE;
fTypeName = newTypeName;
return kTRUE;
}
Bool_t TStreamerElement::IsBase() const
{
return kFALSE;
}
void TStreamerElement::ls(Option_t *) const
{
sprintf(gIncludeName,GetTypeName());
if (IsaPointer() && !fTypeName.Contains("*")) strcat(gIncludeName,"*");
printf(" %-14s %-15s offset=%3d type=%2d %-20s\n",gIncludeName,GetFullName(),fOffset,fType,GetTitle());
}
void TStreamerElement::SetArrayDim(Int_t dim)
{
fArrayDim = dim;
if (dim) fType += TStreamerInfo::kOffsetL;
fNewType = fType;
}
void TStreamerElement::SetMaxIndex(Int_t dim, Int_t max)
{
if (dim < 0 || dim > 4) return;
fMaxIndex[dim] = max;
if (fArrayLength == 0) fArrayLength = max;
else fArrayLength *= max;
}
void TStreamerElement::SetStreamer(TMemberStreamer *streamer)
{
fStreamer = streamer;
}
void TStreamerElement::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
R__b.ClassBegin(TStreamerElement::Class(), R__v);
R__b.ClassMember("TNamed");
TNamed::Streamer(R__b);
R__b.ClassMember("fType","Int_t");
R__b >> fType;
R__b.ClassMember("fSize","Int_t");
R__b >> fSize;
R__b.ClassMember("fArrayLength","Int_t");
R__b >> fArrayLength;
R__b.ClassMember("fArrayDim","Int_t");
R__b >> fArrayDim;
R__b.ClassMember("fMaxIndex","Int_t", 5);
if (R__v == 1) R__b.ReadStaticArray(fMaxIndex);
else R__b.ReadFastArray(fMaxIndex,5);
R__b.ClassMember("fTypeName","TString");
fTypeName.Streamer(R__b);
if (fType==11&&(fTypeName=="Bool_t"||fTypeName=="bool")) fType = 18;
if (R__v > 1) {
SetUniqueID(0);
GetExecID();
}
if (R__v <= 2 && this->IsA()==TStreamerBasicType::Class()) {
TDataType *type = gROOT->GetType(GetTypeName());
if (type && fArrayLength) fSize = fArrayLength * type->Size();
}
if (R__v == 3) {
R__b >> fXmin;
R__b >> fXmax;
R__b >> fFactor;
if (fFactor > 0) SetBit(kHasRange);
}
if (R__v > 3) {
if (TestBit(kHasRange)) GetRange(GetTitle(),fXmin,fXmax,fFactor);
}
R__b.ClassEnd(TStreamerElement::Class());
R__b.SetBufferOffset(R__s+R__c+sizeof(UInt_t));
} else {
TStreamerElement::Class()->WriteBuffer(R__b,this);
}
}
void TStreamerElement::Update(const TClass *oldClass, TClass *newClass)
{
if (fClassObject == oldClass) {
fClassObject = newClass;
if (fClassObject && fClassObject->InheritsFrom(TObject::Class())) {
fTObjectOffset = fClassObject->GetBaseClassOffset(TObject::Class());
}
} else if (fClassObject==0) {
fClassObject = (TClass*)-1;
GetClassPointer();
if (fClassObject && fClassObject->InheritsFrom(TObject::Class())) {
fTObjectOffset = fClassObject->GetBaseClassOffset(TObject::Class());
}
}
}
ClassImp(TStreamerBase)
TStreamerBase::TStreamerBase()
{
fBaseClass = (TClass*)(-1);
fBaseVersion = 0;
}
TStreamerBase::TStreamerBase(const char *name, const char *title, Int_t offset)
: TStreamerElement(name,title,offset,TStreamerInfo::kBase,"BASE")
{
if (strcmp(name,"TObject") == 0) fType = TStreamerInfo::kTObject;
if (strcmp(name,"TNamed") == 0) fType = TStreamerInfo::kTNamed;
fNewType = fType;
fBaseClass = gROOT->GetClass(GetName());
fBaseVersion = fBaseClass->GetClassVersion();
Init();
}
TStreamerBase::~TStreamerBase()
{
}
TClass *TStreamerBase::GetClassPointer() const
{
if (fBaseClass!=(TClass*)(-1)) return fBaseClass;
((TStreamerBase*)this)->fBaseClass = gROOT->GetClass(GetName());
return fBaseClass;
}
Int_t TStreamerBase::GetSize() const
{
TClass *cl = GetClassPointer();
if (cl) return cl->Size();
return 0;
}
void TStreamerBase::Init(TObject *)
{
if (fType == TStreamerInfo::kTObject || fType == TStreamerInfo::kTNamed) return;
fBaseClass = gROOT->GetClass(GetName());
if (!fBaseClass) return;
if (!fBaseClass->GetMethodAny("StreamerNVirtual")) return;
fMethod = new TMethodCall();
fMethod->InitWithPrototype(fBaseClass,"StreamerNVirtual","TBuffer &");
}
Bool_t TStreamerBase::IsBase() const
{
return kTRUE;
}
const char *TStreamerBase::GetInclude() const
{
if (GetClassPointer() && fBaseClass->GetClassInfo()) sprintf(gIncludeName,"\"%s\"",fBaseClass->GetDeclFileName());
else sprintf(gIncludeName,"\"%s.h\"",GetName());
return gIncludeName;
}
void TStreamerBase::ls(Option_t *) const
{
printf(" %-14s %-15s offset=%3d type=%2d %-20s\n",GetFullName(),GetTypeName(),fOffset,fType,GetTitle());
}
Int_t TStreamerBase::ReadBuffer (TBuffer &b, char *pointer)
{
if (fMethod) {
ULong_t args[1];
args[0] = (ULong_t)&b;
fMethod->SetParamPtrs(args);
fMethod->Execute((void*)(pointer+fOffset));
} else {
fBaseClass->ReadBuffer(b,pointer+fOffset);
}
return 0;
}
void TStreamerBase::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
R__b.ClassBegin(TStreamerBase::Class(), R__v);
R__b.ClassMember("TStreamerElement");
TStreamerElement::Streamer(R__b);
fBaseClass = (TClass*)-1;
if (R__v > 2) {
R__b.ClassMember("fBaseVersion","Int_t");
R__b >> fBaseVersion;
} else {
fBaseClass = gROOT->GetClass(GetName());
fBaseVersion = fBaseClass->GetClassVersion();
}
R__b.ClassEnd(TStreamerBase::Class());
R__b.SetBufferOffset(R__s+R__c+sizeof(UInt_t));
} else {
TStreamerBase::Class()->WriteBuffer(R__b,this);
}
}
void TStreamerBase::Update(const TClass *oldClass, TClass *newClass)
{
if (fClassObject == oldClass) fClassObject = newClass;
else if (fClassObject == 0) {
fClassObject = (TClass*)-1;
GetClassPointer();
}
if (fBaseClass == oldClass) fBaseClass = newClass;
else if (fBaseClass == 0 ) {
fBaseClass = (TClass*)-1;
GetClassPointer();
}
if (fClassObject != (TClass*)-1 &&
fClassObject && fClassObject->InheritsFrom(TObject::Class())) {
fTObjectOffset = fClassObject->GetBaseClassOffset(TObject::Class());
}
}
Int_t TStreamerBase::WriteBuffer (TBuffer &b, char *pointer)
{
if (!fMethod) {
fBaseClass->WriteBuffer(b,pointer+fOffset);
return 0;
}
ULong_t args[1];
args[0] = (ULong_t)&b;
fMethod->SetParamPtrs(args);
fMethod->Execute((void*)(pointer+fOffset));
fBaseClass->GetStreamerInfo()->ForceWriteInfo((TFile *)b.GetParent());
return 0;
}
ClassImp(TStreamerBasicPointer)
TStreamerBasicPointer::TStreamerBasicPointer() : fCounter(0)
{
fCounter = 0;
}
TStreamerBasicPointer::TStreamerBasicPointer(const char *name, const char *title, Int_t offset, Int_t dtype, const char *countName, const char *countClass, Int_t countVersion, const char *typeName)
: TStreamerElement(name,title,offset,dtype,typeName)
{
fType += TStreamerInfo::kOffsetP;
fCountName = countName;
fCountClass = countClass;
fCountVersion = countVersion;
Init();
}
TStreamerBasicPointer::~TStreamerBasicPointer()
{
}
ULong_t TStreamerBasicPointer::GetMethod() const
{
if (!fCounter) ((TStreamerBasicPointer*)this)->Init();
if (!fCounter) return 0;
return (ULong_t)fCounter->GetOffset();
}
Int_t TStreamerBasicPointer::GetSize() const
{
if (fArrayLength) return fArrayLength*sizeof(void *);
return sizeof(void *);
}
void TStreamerBasicPointer::Init(TObject *)
{
fCounter = InitCounter( fCountClass, fCountName );
}
void TStreamerBasicPointer::SetArrayDim(Int_t dim)
{
fArrayDim = dim;
fNewType = fType;
}
void TStreamerBasicPointer::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 1) {
TStreamerBasicPointer::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
return;
}
TStreamerElement::Streamer(R__b);
R__b >> fCountVersion;
fCountName.Streamer(R__b);
fCountClass.Streamer(R__b);
R__b.SetBufferOffset(R__s+R__c+sizeof(UInt_t));
} else {
TStreamerBasicPointer::Class()->WriteBuffer(R__b,this);
}
}
ClassImp(TStreamerLoop)
TStreamerLoop::TStreamerLoop() : fCounter(0)
{
fCounter = 0;
}
TStreamerLoop::TStreamerLoop(const char *name, const char *title, Int_t offset, const char *countName, const char *countClass, Int_t countVersion, const char *typeName)
: TStreamerElement(name,title,offset,TStreamerInfo::kStreamLoop,typeName)
{
fCountName = countName;
fCountClass = countClass;
fCountVersion = countVersion;
Init();
}
TStreamerLoop::~TStreamerLoop()
{
}
ULong_t TStreamerLoop::GetMethod() const
{
if (!fCounter) return 0;
return (ULong_t)fCounter->GetOffset();
}
Int_t TStreamerLoop::GetSize() const
{
if (fArrayLength) return fArrayLength*sizeof(Int_t);
return sizeof(Int_t);
}
void TStreamerLoop::Init(TObject *)
{
fCounter = InitCounter( fCountClass, fCountName );
}
const char *TStreamerLoop::GetInclude() const
{
sprintf(gIncludeName,"<%s>","TString.h");
return gIncludeName;
}
void TStreamerLoop::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 1) {
TStreamerLoop::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
return;
}
TStreamerElement::Streamer(R__b);
R__b >> fCountVersion;
fCountName.Streamer(R__b);
fCountClass.Streamer(R__b);
R__b.SetBufferOffset(R__s+R__c+sizeof(UInt_t));
} else {
TStreamerLoop::Class()->WriteBuffer(R__b,this);
}
}
ClassImp(TStreamerBasicType)
TStreamerBasicType::TStreamerBasicType()
{
}
TStreamerBasicType::TStreamerBasicType(const char *name, const char *title, Int_t offset, Int_t dtype, const char *typeName)
: TStreamerElement(name,title,offset,dtype,typeName)
{
}
TStreamerBasicType::~TStreamerBasicType()
{
}
ULong_t TStreamerBasicType::GetMethod() const
{
if (fType == TStreamerInfo::kCounter ||
fType == (TStreamerInfo::kCounter+TStreamerInfo::kSkip)) return (ULong_t)&fCounter;
return 0;
}
Int_t TStreamerBasicType::GetSize() const
{
return fSize;
}
void TStreamerBasicType::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 1) {
TStreamerBasicType::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
return;
}
TStreamerElement::Streamer(R__b);
R__b.CheckByteCount(R__s, R__c, TStreamerBasicType::IsA());
} else {
TStreamerBasicType::Class()->WriteBuffer(R__b,this);
}
}
ClassImp(TStreamerObject)
TStreamerObject::TStreamerObject()
{
}
TStreamerObject::TStreamerObject(const char *name, const char *title, Int_t offset, const char *typeName)
: TStreamerElement(name,title,offset,0,typeName)
{
fType = TStreamerInfo::kObject;
if (strcmp(typeName,"TObject") == 0) fType = TStreamerInfo::kTObject;
if (strcmp(typeName,"TNamed") == 0) fType = TStreamerInfo::kTNamed;
fNewType = fType;
Init();
}
TStreamerObject::~TStreamerObject()
{
}
void TStreamerObject::Init(TObject *)
{
fClassObject = GetClassPointer();
if (fClassObject && fClassObject->InheritsFrom(TObject::Class())) {
fTObjectOffset = fClassObject->GetBaseClassOffset(TObject::Class());
}
}
const char *TStreamerObject::GetInclude() const
{
TClass *cl = GetClassPointer();
if (cl && cl->GetClassInfo()) sprintf(gIncludeName,"\"%s\"",cl->GetDeclFileName());
else sprintf(gIncludeName,"\"%s.h\"",GetTypeName());
return gIncludeName;
}
Int_t TStreamerObject::GetSize() const
{
TClass *cl = GetClassPointer();
Int_t classSize = 8;
if (cl) classSize = cl->Size();
if (fArrayLength) return fArrayLength*classSize;
return classSize;
}
void TStreamerObject::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 1) {
TStreamerObject::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
return;
}
TStreamerElement::Streamer(R__b);
R__b.CheckByteCount(R__s, R__c, TStreamerObject::IsA());
} else {
TStreamerObject::Class()->WriteBuffer(R__b,this);
}
}
ClassImp(TStreamerObjectAny)
TStreamerObjectAny::TStreamerObjectAny()
{
}
TStreamerObjectAny::TStreamerObjectAny(const char *name, const char *title, Int_t offset, const char *typeName)
: TStreamerElement(name,title,offset,TStreamerInfo::kAny,typeName)
{
Init();
}
TStreamerObjectAny::~TStreamerObjectAny()
{
}
void TStreamerObjectAny::Init(TObject *)
{
fClassObject = GetClassPointer();
if (fClassObject && fClassObject->InheritsFrom(TObject::Class())) {
fTObjectOffset = fClassObject->GetBaseClassOffset(TObject::Class());
}
}
const char *TStreamerObjectAny::GetInclude() const
{
TClass *cl = GetClassPointer();
if (cl && cl->GetClassInfo()) sprintf(gIncludeName,"\"%s\"",cl->GetDeclFileName());
else sprintf(gIncludeName,"\"%s.h\"",GetTypeName());
return gIncludeName;
}
Int_t TStreamerObjectAny::GetSize() const
{
TClass *cl = GetClassPointer();
Int_t classSize = 8;
if (cl) classSize = cl->Size();
if (fArrayLength) return fArrayLength*classSize;
return classSize;
}
void TStreamerObjectAny::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 1) {
TStreamerObjectAny::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
return;
}
TStreamerElement::Streamer(R__b);
R__b.CheckByteCount(R__s, R__c, TStreamerObjectAny::IsA());
} else {
TStreamerObjectAny::Class()->WriteBuffer(R__b,this);
}
}
ClassImp(TStreamerObjectPointer)
TStreamerObjectPointer::TStreamerObjectPointer()
{
}
TStreamerObjectPointer::TStreamerObjectPointer(const char *name, const char *title,
Int_t offset, const char *typeName)
: TStreamerElement(name,title,offset,TStreamerInfo::kObjectP,typeName)
{
if (strncmp(title,"->",2) == 0) fType = TStreamerInfo::kObjectp;
fNewType = fType;
Init();
}
TStreamerObjectPointer::~TStreamerObjectPointer()
{
}
void TStreamerObjectPointer::Init(TObject *)
{
fClassObject = GetClassPointer();
if (fClassObject && fClassObject->InheritsFrom(TObject::Class())) {
fTObjectOffset = fClassObject->GetBaseClassOffset(TObject::Class());
}
}
const char *TStreamerObjectPointer::GetInclude() const
{
TClass *cl = GetClassPointer();
if (cl && cl->GetClassInfo()) sprintf(gIncludeName,"\"%s\"",cl->GetDeclFileName());
else sprintf(gIncludeName,"\"%s.h\"",GetTypeName());
char *star = strchr(gIncludeName,'*');
if (star) strcpy(star,star+1);
return gIncludeName;
}
Int_t TStreamerObjectPointer::GetSize() const
{
if (fArrayLength) return fArrayLength*sizeof(void *);
return sizeof(void *);
}
void TStreamerObjectPointer::SetArrayDim(Int_t dim)
{
fArrayDim = dim;
fNewType = fType;
}
void TStreamerObjectPointer::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 1) {
TStreamerObjectPointer::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
return;
}
TStreamerElement::Streamer(R__b);
R__b.CheckByteCount(R__s, R__c, TStreamerObjectPointer::IsA());
} else {
TStreamerObjectPointer::Class()->WriteBuffer(R__b,this);
}
}
ClassImp(TStreamerObjectAnyPointer)
TStreamerObjectAnyPointer::TStreamerObjectAnyPointer()
{
}
TStreamerObjectAnyPointer::TStreamerObjectAnyPointer(const char *name, const char *title,
Int_t offset, const char *typeName)
: TStreamerElement(name,title,offset,TStreamerInfo::kAnyP,typeName)
{
if (strncmp(title,"->",2) == 0) fType = TStreamerInfo::kAnyp;
fNewType = fType;
Init();
}
TStreamerObjectAnyPointer::~TStreamerObjectAnyPointer()
{
}
void TStreamerObjectAnyPointer::Init(TObject *)
{
fClassObject = GetClassPointer();
if (fClassObject && fClassObject->InheritsFrom(TObject::Class())) {
fTObjectOffset = fClassObject->GetBaseClassOffset(TObject::Class());
}
}
const char *TStreamerObjectAnyPointer::GetInclude() const
{
TClass *cl = GetClassPointer();
if (cl && cl->GetClassInfo()) sprintf(gIncludeName,"\"%s\"",cl->GetDeclFileName());
else sprintf(gIncludeName,"\"%s.h\"",GetTypeName());
char *star = strchr(gIncludeName,'*');
if (star) strcpy(star,star+1);
return gIncludeName;
}
Int_t TStreamerObjectAnyPointer::GetSize() const
{
if (fArrayLength) return fArrayLength*sizeof(void *);
return sizeof(void *);
}
void TStreamerObjectAnyPointer::SetArrayDim(Int_t dim)
{
fArrayDim = dim;
fNewType = fType;
}
void TStreamerObjectAnyPointer::Streamer(TBuffer &R__b)
{
if (R__b.IsReading()) {
TStreamerObjectAnyPointer::Class()->ReadBuffer(R__b, this);
} else {
TStreamerObjectAnyPointer::Class()->WriteBuffer(R__b,this);
}
}
ClassImp(TStreamerString)
TStreamerString::TStreamerString()
{
}
TStreamerString::TStreamerString(const char *name, const char *title, Int_t offset)
: TStreamerElement(name,title,offset,TStreamerInfo::kTString,"TString")
{
}
TStreamerString::~TStreamerString()
{
}
Int_t TStreamerString::GetSize() const
{
if (fArrayLength) return fArrayLength*sizeof(TString);
return sizeof(TString);
}
void TStreamerString::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 1) {
TStreamerString::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
return;
}
TStreamerElement::Streamer(R__b);
R__b.CheckByteCount(R__s, R__c, TStreamerString::IsA());
} else {
TStreamerString::Class()->WriteBuffer(R__b,this);
}
}
ClassImp(TStreamerSTL)
TStreamerSTL::TStreamerSTL()
{
}
#include "Api.h"
TStreamerSTL::TStreamerSTL(const char *name, const char *title, Int_t offset,
const char *typeName, const char *trueType, Bool_t dmPointer)
: TStreamerElement(name,title,offset,kSTL,typeName)
{
const char *t = trueType;
if (!t || !*t) t = typeName;
fTypeName = TClassEdit::ShortType(fTypeName,TClassEdit::kDropStlDefault).c_str();
if (name==typeName
|| strcmp(name,typeName)==0) {
fName = fTypeName;
}
Int_t nch = strlen(t);
char *s = new char[nch+1];
strcpy(s,t);
char *sopen = strchr(s,'<'); *sopen = 0; sopen++;
char* current=sopen;
for(int count = 0; *current!='\0'; current++) {
if (*current=='<') count++;
if (*current=='>') {
if (count==0) break;
count--;
}
if (*current==',' && count==0) break;
}
char *sclose = current; *sclose = 0; sclose--;
char *sconst = strstr(sopen,"const ");
if (sconst) {
char *pconst = sconst-1;
if (*pconst == ' ' || *pconst == '<' || *pconst == '*' || *pconst == '\0') sopen = sconst + 5;
}
fSTLtype = 0;
fCtype = 0;
if (strstr(s,"vector")) fSTLtype = kSTLvector;
else if (strstr(s,"list")) fSTLtype = kSTLlist;
else if (strstr(s,"deque")) fSTLtype = kSTLdeque;
else if (strstr(s,"map")) fSTLtype = kSTLmap;
else if (strstr(s,"set")) fSTLtype = kSTLset;
else if (strstr(s,"multimap")) fSTLtype = kSTLmultimap;
else if (strstr(s,"multiset")) fSTLtype = kSTLmultiset;
if (fSTLtype == 0) { delete [] s; return;}
if (dmPointer) fSTLtype += TStreamerInfo::kOffsetP;
while (*sopen==' ') sopen++;
Bool_t isPointer = kFALSE;
char *star = strrchr(sopen,'>');
if (star) star = strchr(star,'*');
else star = strchr(sopen,'*');
if (star) {
isPointer = kTRUE;
*star = 0;
sclose = star - 1;
}
while (*sclose == ' ') {*sclose = 0; sclose--;}
TDataType *dt = (TDataType*)gROOT->GetListOfTypes()->FindObject(sopen);
if (dt) {
fCtype = dt->GetType();
if (isPointer) fCtype += TStreamerInfo::kOffsetP;
} else {
TClass *cl = gROOT->GetClass(sopen);
if (cl) {
if (isPointer) fCtype = TStreamerInfo::kObjectp;
else fCtype = TStreamerInfo::kObject;
} else {
G__ClassInfo info(sopen);
if (info.IsValid() && info.Property()&G__BIT_ISENUM) {
if (isPointer) fCtype += TStreamerInfo::kOffsetP;
} else {
if(strcmp(sopen,"string")) {
if (GetClassPointer() && GetClassPointer()->IsLoaded()) {
Warning("TStreamerSTL","For %s we could not find any information about the type %s",fTypeName.Data(),sopen);
}
}
}
}
}
delete [] s;
if (TStreamerSTL::IsaPointer()) fType = TStreamerInfo::kSTLp;
}
TStreamerSTL::~TStreamerSTL()
{
}
Bool_t TStreamerSTL::CannotSplit() const
{
if (IsaPointer()) {
if (GetTitle()[0]=='[') return kTRUE;
return kTRUE;
}
if (GetArrayDim()>=1 && GetArrayLength()>1) return kTRUE;
if (TStreamerElement::CannotSplit()) return kTRUE;
return kFALSE;
}
Bool_t TStreamerSTL::IsaPointer() const
{
const char *type_name = GetTypeName();
if ( type_name[strlen(type_name)-1]=='*' ) return kTRUE;
else return kFALSE;
}
Bool_t TStreamerSTL::IsBase() const
{
TString ts(GetName());
if (strcmp(ts.Data(),GetTypeName())==0) return kTRUE;
if (strcmp(ts.Data(),GetTypeNameBasic())==0) return kTRUE;
return kFALSE;
}
Int_t TStreamerSTL::GetSize() const
{
UInt_t size = GetClassPointer()->Size();
if (fArrayLength) return fArrayLength*size;
return size;
}
void TStreamerSTL::ls(Option_t *) const
{
char name[kMaxLen];
char cdim[20];
sprintf(name,GetName());
for (Int_t i=0;i<fArrayDim;i++) {
sprintf(cdim,"[%d]",fMaxIndex[i]);
strcat(name,cdim);
}
printf(" %-14s %-15s offset=%3d type=%2d ,stl=%d, ctype=%d, %-20s",GetTypeName(),name,fOffset,fType,fSTLtype,fCtype,GetTitle());
printf("\n");
}
const char *TStreamerSTL::GetInclude() const
{
if (fSTLtype == kSTLvector) sprintf(gIncludeName,"<%s>","vector");
else if (fSTLtype == kSTLlist) sprintf(gIncludeName,"<%s>","list");
else if (fSTLtype == kSTLdeque) sprintf(gIncludeName,"<%s>","deque");
else if (fSTLtype == kSTLmap) sprintf(gIncludeName,"<%s>","map");
else if (fSTLtype == kSTLset) sprintf(gIncludeName,"<%s>","set");
else if (fSTLtype == kSTLmultimap) sprintf(gIncludeName,"<%s>","multimap");
else if (fSTLtype == kSTLmultiset) sprintf(gIncludeName,"<%s>","multiset");
return gIncludeName;
}
void TStreamerSTL::SetStreamer(TMemberStreamer *streamer)
{
if (fType==TStreamerInfo::kSTLp || 1) return;
fStreamer = streamer;
if (streamer && !IsaPointer() ) {
fType = TStreamerInfo::kStreamer;
fNewType = fType;
}
}
void TStreamerSTL::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 2) {
TStreamerSTL::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
} else {
TStreamerElement::Streamer(R__b);
R__b >> fSTLtype;
R__b >> fCtype;
R__b.CheckByteCount(R__s, R__c, TStreamerSTL::IsA());
}
if (IsaPointer()) fType = TStreamerInfo::kSTLp;
else fType = TStreamerInfo::kSTL;
return;
} else {
Int_t tmp = fType;
fType = TStreamerInfo::kStreamer;
TStreamerSTL::Class()->WriteBuffer(R__b,this);
fType = tmp;
}
}
ClassImp(TStreamerSTLstring)
TStreamerSTLstring::TStreamerSTLstring()
{
}
TStreamerSTLstring::TStreamerSTLstring(const char *name, const char *title, Int_t offset,
const char *typeName, Bool_t dmPointer)
: TStreamerSTL()
{
SetName(name);
SetTitle(title);
if (dmPointer) {
fType = TStreamerInfo::kSTLp;
} else {
fType = TStreamerInfo::kSTL;
}
fNewType = fType;
fOffset = offset;
fSTLtype = kSTLstring;
fCtype = kSTLstring;
fTypeName= typeName;
}
TStreamerSTLstring::~TStreamerSTLstring()
{
}
const char *TStreamerSTLstring::GetInclude() const
{
sprintf(gIncludeName,"<string>");
return gIncludeName;
}
Int_t TStreamerSTLstring::GetSize() const
{
if (fArrayLength) return fArrayLength*sizeof(string);
return sizeof(string);
}
void TStreamerSTLstring::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 1) {
TStreamerSTLstring::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
return;
}
TStreamerSTL::Streamer(R__b);
R__b.CheckByteCount(R__s, R__c, TStreamerSTLstring::IsA());
} else {
TStreamerSTLstring::Class()->WriteBuffer(R__b,this);
}
}
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.