TArrayC.h

Go to the documentation of this file.
00001 // @(#)root/cont:$Id: TArrayC.h 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Rene Brun   06/03/95
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TArrayC
00013 #define ROOT_TArrayC
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TArrayC                                                              //
00019 //                                                                      //
00020 // Array of chars or bytes (8 bits per element).                        //
00021 //                                                                      //
00022 //////////////////////////////////////////////////////////////////////////
00023 
00024 #ifndef ROOT_TArray
00025 #include "TArray.h"
00026 #endif
00027 
00028 
00029 class TArrayC : public TArray {
00030 
00031 public:
00032    Char_t    *fArray;       //[fN] Array of fN chars
00033 
00034    TArrayC();
00035    TArrayC(Int_t n);
00036    TArrayC(Int_t n, const Char_t *array);
00037    TArrayC(const TArrayC &array);
00038    TArrayC    &operator=(const TArrayC &rhs);
00039    virtual    ~TArrayC();
00040 
00041    void          Adopt(Int_t n, Char_t *array);
00042    void          AddAt(Char_t c, Int_t i);
00043    Char_t        At(Int_t i) const ;
00044    void          Copy(TArrayC &array) const {array.Set(fN,fArray);}
00045    const Char_t *GetArray() const { return fArray; }
00046    Char_t       *GetArray() { return fArray; }
00047    Double_t      GetAt(Int_t i) const { return At(i); }
00048    Stat_t        GetSum() const {Stat_t sum=0; for (Int_t i=0;i<fN;i++) sum+=fArray[i]; return sum;}
00049    void          Reset(Char_t val=0)  {memset(fArray,val,fN*sizeof(Char_t));}
00050    void          Set(Int_t n);
00051    void          Set(Int_t n, const Char_t *array);
00052    void          SetAt(Double_t v, Int_t i) { AddAt((Char_t)v, i); }
00053    Char_t       &operator[](Int_t i);
00054    Char_t        operator[](Int_t i) const;
00055 
00056    ClassDef(TArrayC,1)  //Array of chars
00057 };
00058 
00059 
00060 #if defined R__TEMPLATE_OVERLOAD_BUG
00061 template <>
00062 #endif
00063 inline TBuffer &operator>>(TBuffer &buf, TArrayC *&obj)
00064 {
00065    // Read TArrayC object from buffer.
00066 
00067    obj = (TArrayC *) TArray::ReadArray(buf, TArrayC::Class());
00068    return buf;
00069 }
00070 
00071 #if defined R__TEMPLATE_OVERLOAD_BUG
00072 template <>
00073 #endif
00074 inline TBuffer &operator<<(TBuffer &buf, const TArrayC *obj)
00075 {
00076    // Write a TArrayC object into buffer
00077    return buf << (TArray*)obj;
00078 }
00079 
00080 inline Char_t TArrayC::At(Int_t i) const
00081 {
00082    if (!BoundsOk("TArrayC::At", i)) return 0;
00083    return fArray[i];
00084 }
00085 
00086 inline Char_t &TArrayC::operator[](Int_t i)
00087 {
00088    if (!BoundsOk("TArrayC::operator[]", i))
00089       i = 0;
00090    return fArray[i];
00091 }
00092 
00093 inline Char_t TArrayC::operator[](Int_t i) const
00094 {
00095    if (!BoundsOk("TArrayC::operator[]", i)) return 0;
00096    return fArray[i];
00097 }
00098 
00099 #endif

Generated on Tue Jul 5 14:11:25 2011 for ROOT_528-00b_version by  doxygen 1.5.1