1    	// @(#)root/cont:$Id$
2    	// Author: Rene Brun   06/03/95
3    	
4    	/*************************************************************************
5    	 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
6    	 * All rights reserved.                                                  *
7    	 *                                                                       *
8    	 * For the licensing terms see $ROOTSYS/LICENSE.                         *
9    	 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
10   	 *************************************************************************/
11   	
12   	#ifndef ROOT_TArrayC
13   	#define ROOT_TArrayC
14   	
15   	
16   	//////////////////////////////////////////////////////////////////////////
17   	//                                                                      //
18   	// TArrayC                                                              //
19   	//                                                                      //
20   	// Array of chars or bytes (8 bits per element).                        //
21   	//                                                                      //
22   	//////////////////////////////////////////////////////////////////////////
23   	
24   	#ifndef ROOT_TArray
25   	#include "TArray.h"
26   	#endif
27   	
28   	
29   	class TArrayC : public TArray {
30   	
31   	public:
32   	   Char_t    *fArray;       //[fN] Array of fN chars
33   	
34   	   TArrayC();
35   	   TArrayC(Int_t n);
36   	   TArrayC(Int_t n, const Char_t *array);
37   	   TArrayC(const TArrayC &array);
38   	   TArrayC    &operator=(const TArrayC &rhs);
39   	   virtual    ~TArrayC();
40   	
41   	   void          Adopt(Int_t n, Char_t *array);
42   	   void          AddAt(Char_t c, Int_t i);
43   	   Char_t        At(Int_t i) const ;
44   	   void          Copy(TArrayC &array) const {array.Set(fN,fArray);}
45   	   const Char_t *GetArray() const { return fArray; }
46   	   Char_t       *GetArray() { return fArray; }
47   	   Double_t      GetAt(Int_t i) const { return At(i); }
48   	   Stat_t        GetSum() const {Stat_t sum=0; for (Int_t i=0;i<fN;i++) sum+=fArray[i]; return sum;}
49   	   void          Reset(Char_t val=0)  {memset(fArray,val,fN*sizeof(Char_t));}
50   	   void          Set(Int_t n);
51   	   void          Set(Int_t n, const Char_t *array);
52   	   void          SetAt(Double_t v, Int_t i) { AddAt((Char_t)v, i); }
53   	   Char_t       &operator[](Int_t i);
54   	   Char_t        operator[](Int_t i) const;
55   	
56   	   ClassDef(TArrayC,1)  //Array of chars
57   	};
58   	
59   	
60   	#if defined R__TEMPLATE_OVERLOAD_BUG
61   	template <>
62   	#endif
63   	inline TBuffer &operator>>(TBuffer &buf, TArrayC *&obj)
64   	{
65   	   // Read TArrayC object from buffer.
66   	
67   	   obj = (TArrayC *) TArray::ReadArray(buf, TArrayC::Class());
68   	   return buf;
69   	}
70   	
71   	#if defined R__TEMPLATE_OVERLOAD_BUG
72   	template <>
73   	#endif
74   	inline TBuffer &operator<<(TBuffer &buf, const TArrayC *obj)
75   	{
76   	   // Write a TArrayC object into buffer
77   	   return buf << (const TArray*)obj;
78   	}
79   	
80   	inline Char_t TArrayC::At(Int_t i) const
81   	{
82   	   if (!BoundsOk("TArrayC::At", i)) return 0;
83   	   return fArray[i];
84   	}
85   	
86   	inline Char_t &TArrayC::operator[](Int_t i)
87   	{
88   	   if (!BoundsOk("TArrayC::operator[]", i))
89   	      i = 0;
90   	   return fArray[i];
91   	}
92   	
93   	inline Char_t TArrayC::operator[](Int_t i) const
94   	{
95   	   if (!BoundsOk("TArrayC::operator[]", i)) return 0;
96   	   return fArray[i];
97   	}
98   	
99   	#endif
100