#include "TTreeRow.h"
#include "TObjArray.h"
ClassImp(TTreeRow)
TTreeRow::TTreeRow()
{
fColumnCount = 0;
fFields = 0;
fOriginal = 0;
fRow = 0;
}
TTreeRow::TTreeRow(Int_t nfields)
{
fColumnCount = nfields;
fFields = 0;
fOriginal = 0;
fRow = 0;
}
TTreeRow::TTreeRow(Int_t nfields, const Int_t *fields, const char *row)
{
fColumnCount = nfields;
fFields = 0;
fOriginal = 0;
SetRow(fields,row);
}
TTreeRow::TTreeRow(TSQLRow *original)
{
fFields = 0;
fOriginal = 0;
fColumnCount = 0;
fRow = 0;
if (!original) {
Error("TTreeRow", "original may not be 0");
return;
}
if (original->IsA() != TTreeRow::Class()) {
Error("TTreeRow", "original must be a TTreeRow");
return;
}
fOriginal = (TTreeRow*) original;
fColumnCount = fOriginal->fColumnCount;
}
TTreeRow::~TTreeRow()
{
if (fFields)
Close();
}
void TTreeRow::Close(Option_t *)
{
if (fRow) delete [] fRow;
if (fFields) delete [] fFields;
fColumnCount = 0;
fOriginal = 0;
}
Bool_t TTreeRow::IsValid(Int_t field)
{
if (!fFields && !fOriginal) {
Error("IsValid", "row closed");
return kFALSE;
}
if (field < 0 || field >= fColumnCount) {
Error("IsValid", "field index out of bounds");
return kFALSE;
}
return kTRUE;
}
ULong_t TTreeRow::GetFieldLength(Int_t field)
{
if (!IsValid(field))
return 0;
if (fOriginal)
return fOriginal->GetFieldLength(field);
if (field > 0) return fFields[field] - fFields[field-1] -1;
else return fFields[0] -1;
}
const char *TTreeRow::GetField(Int_t field)
{
if (!IsValid(field))
return 0;
if (fOriginal)
return fOriginal->GetField(field);
if (field > 0) return fRow +fFields[field-1];
else return fRow;
}
void TTreeRow::SetRow(const Int_t *fields, const char *row)
{
if (!fColumnCount) return;
if (fFields) delete [] fFields;
Int_t nch = fields[fColumnCount-1];
fFields = new Int_t[fColumnCount];
fOriginal = 0;
fRow = new char[nch];
for (Int_t i=0;i<fColumnCount;i++) fFields[i] = fields[i];
memcpy(fRow,row,nch);
}
void TTreeRow::Streamer(TBuffer &R__b)
{
UInt_t R__s, R__c;
if (R__b.IsReading()) {
R__b.ReadVersion(&R__s, &R__c);
TSQLRow::Streamer(R__b);
R__b >> fColumnCount;
fFields = new Int_t[fColumnCount];
R__b.ReadFastArray(fFields,fColumnCount);
Int_t nch;
R__b >> nch;
fRow = new char[nch];
R__b.ReadFastArray(fRow,nch);
R__b.CheckByteCount(R__s, R__c, TTreeRow::IsA());
} else {
R__c = R__b.WriteVersion(TTreeRow::Class(),kTRUE);
TSQLRow::Streamer(R__b);
R__b << fColumnCount;
R__b.WriteFastArray(fFields,fColumnCount);
Int_t nch = fFields[fColumnCount-1];
R__b << nch;
R__b.WriteFastArray(fRow,nch);
R__b.SetByteCount(R__c,kTRUE);
}
}
Last change: Wed Jun 25 08:54:26 2008
Last generated: 2008-06-25 08:54
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.