// @(#)root/cont:$Id$
// Author: Fons Rademakers   21/10/97

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TArray                                                               //
//                                                                      //
// Abstract array base class. Used by TArrayC, TArrayS, TArrayI,        //
// TArrayL, TArrayF and TArrayD.                                        //
// Data member is public for historical reasons.                        //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TArray.h"
#include "TError.h"
#include "TClass.h"
#include "TBuffer.h"


ClassImp(TArray)

//______________________________________________________________________________
Bool_t TArray::OutOfBoundsError(const char *where, Int_t i) const
{
   // Generate an out-of-bounds error. Always returns false.

   ::Error(where, "index %d out of bounds (size: %d, this: 0x%lx)", i, fN, (Long_t)this);
   return kFALSE;
}

//______________________________________________________________________________
TArray *TArray::ReadArray(TBuffer &b, const TClass *clReq)
{
   // Read TArray object from buffer. Simplified version of
   // TBuffer::ReadObject (does not keep track of multiple
   // references to same array).

   R__ASSERT(b.IsReading());

   // Make sure ReadArray is initialized
   b.InitMap();

   // Before reading object save start position
   UInt_t startpos = UInt_t(b.Length());

   UInt_t tag;
   TClass *clRef = b.ReadClass(clReq, &tag);

   TArray *a;
   if (!clRef) {

      a = 0;

   } else {

      a = (TArray *) clRef->New();
      if (!a) {
         ::Error("TArray::ReadArray", "could not create object of class %s",
                 clRef->GetName());
         // Exception
         return 0;
      }

      a->Streamer(b);

      b.CheckByteCount(startpos, tag, clRef);
   }

   return a;
}

//______________________________________________________________________________
void TArray::WriteArray(TBuffer &b, const TArray *a)
{
   // Write TArray object to buffer. Simplified version of
   // TBuffer::WriteObject (does not keep track of multiple
   // references to the same array).

   R__ASSERT(b.IsWriting());

   // Make sure WriteMap is initialized
   b.InitMap();

   if (!a) {

      b << (UInt_t) 0;

   } else {

      // Reserve space for leading byte count
      UInt_t cntpos = UInt_t(b.Length());
      b.SetBufferOffset(Int_t(cntpos+sizeof(UInt_t)));

      TClass *cl = a->IsA();
      b.WriteClass(cl);

      ((TArray *)a)->Streamer(b);

      // Write byte count
      b.SetByteCount(cntpos);
   }
}

//______________________________________________________________________________
TBuffer &operator<<(TBuffer &buf, const TArray *obj)
{
   // Write TArray or derived object to buffer.

   TArray::WriteArray(buf, obj);
   return buf;
}
 TArray.cxx:1
 TArray.cxx:2
 TArray.cxx:3
 TArray.cxx:4
 TArray.cxx:5
 TArray.cxx:6
 TArray.cxx:7
 TArray.cxx:8
 TArray.cxx:9
 TArray.cxx:10
 TArray.cxx:11
 TArray.cxx:12
 TArray.cxx:13
 TArray.cxx:14
 TArray.cxx:15
 TArray.cxx:16
 TArray.cxx:17
 TArray.cxx:18
 TArray.cxx:19
 TArray.cxx:20
 TArray.cxx:21
 TArray.cxx:22
 TArray.cxx:23
 TArray.cxx:24
 TArray.cxx:25
 TArray.cxx:26
 TArray.cxx:27
 TArray.cxx:28
 TArray.cxx:29
 TArray.cxx:30
 TArray.cxx:31
 TArray.cxx:32
 TArray.cxx:33
 TArray.cxx:34
 TArray.cxx:35
 TArray.cxx:36
 TArray.cxx:37
 TArray.cxx:38
 TArray.cxx:39
 TArray.cxx:40
 TArray.cxx:41
 TArray.cxx:42
 TArray.cxx:43
 TArray.cxx:44
 TArray.cxx:45
 TArray.cxx:46
 TArray.cxx:47
 TArray.cxx:48
 TArray.cxx:49
 TArray.cxx:50
 TArray.cxx:51
 TArray.cxx:52
 TArray.cxx:53
 TArray.cxx:54
 TArray.cxx:55
 TArray.cxx:56
 TArray.cxx:57
 TArray.cxx:58
 TArray.cxx:59
 TArray.cxx:60
 TArray.cxx:61
 TArray.cxx:62
 TArray.cxx:63
 TArray.cxx:64
 TArray.cxx:65
 TArray.cxx:66
 TArray.cxx:67
 TArray.cxx:68
 TArray.cxx:69
 TArray.cxx:70
 TArray.cxx:71
 TArray.cxx:72
 TArray.cxx:73
 TArray.cxx:74
 TArray.cxx:75
 TArray.cxx:76
 TArray.cxx:77
 TArray.cxx:78
 TArray.cxx:79
 TArray.cxx:80
 TArray.cxx:81
 TArray.cxx:82
 TArray.cxx:83
 TArray.cxx:84
 TArray.cxx:85
 TArray.cxx:86
 TArray.cxx:87
 TArray.cxx:88
 TArray.cxx:89
 TArray.cxx:90
 TArray.cxx:91
 TArray.cxx:92
 TArray.cxx:93
 TArray.cxx:94
 TArray.cxx:95
 TArray.cxx:96
 TArray.cxx:97
 TArray.cxx:98
 TArray.cxx:99
 TArray.cxx:100
 TArray.cxx:101
 TArray.cxx:102
 TArray.cxx:103
 TArray.cxx:104
 TArray.cxx:105
 TArray.cxx:106
 TArray.cxx:107
 TArray.cxx:108
 TArray.cxx:109
 TArray.cxx:110
 TArray.cxx:111
 TArray.cxx:112
 TArray.cxx:113
 TArray.cxx:114
 TArray.cxx:115
 TArray.cxx:116
 TArray.cxx:117
 TArray.cxx:118
 TArray.cxx:119