00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "TArray.h"
00023 #include "TError.h"
00024 #include "TClass.h"
00025 #include "TBuffer.h"
00026
00027
00028 ClassImp(TArray)
00029
00030
00031 Bool_t TArray::OutOfBoundsError(const char *where, Int_t i) const
00032 {
00033
00034
00035 ::Error(where, "index %d out of bounds (size: %d, this: 0x%lx)", i, fN, (Long_t)this);
00036 return kFALSE;
00037 }
00038
00039
00040 TArray *TArray::ReadArray(TBuffer &b, const TClass *clReq)
00041 {
00042
00043
00044
00045
00046 R__ASSERT(b.IsReading());
00047
00048
00049 b.InitMap();
00050
00051
00052 UInt_t startpos = UInt_t(b.Length());
00053
00054 UInt_t tag;
00055 TClass *clRef = b.ReadClass(clReq, &tag);
00056
00057 TArray *a;
00058 if (!clRef) {
00059
00060 a = 0;
00061
00062 } else {
00063
00064 a = (TArray *) clRef->New();
00065 if (!a) {
00066 ::Error("TArray::ReadArray", "could not create object of class %s",
00067 clRef->GetName());
00068
00069 return 0;
00070 }
00071
00072 a->Streamer(b);
00073
00074 b.CheckByteCount(startpos, tag, clRef);
00075 }
00076
00077 return a;
00078 }
00079
00080
00081 void TArray::WriteArray(TBuffer &b, const TArray *a)
00082 {
00083
00084
00085
00086
00087 R__ASSERT(b.IsWriting());
00088
00089
00090 b.InitMap();
00091
00092 if (!a) {
00093
00094 b << (UInt_t) 0;
00095
00096 } else {
00097
00098
00099 UInt_t cntpos = UInt_t(b.Length());
00100 b.SetBufferOffset(Int_t(cntpos+sizeof(UInt_t)));
00101
00102 TClass *cl = a->IsA();
00103 b.WriteClass(cl);
00104
00105 ((TArray *)a)->Streamer(b);
00106
00107
00108 b.SetByteCount(cntpos);
00109 }
00110 }
00111
00112
00113 TBuffer &operator<<(TBuffer &buf, const TArray *obj)
00114 {
00115
00116
00117 TArray::WriteArray(buf, obj);
00118 return buf;
00119 }