Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TArrayC.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/cont:$Id$
0002 // Author: Rene Brun   06/03/95
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TArrayC
0013 #define ROOT_TArrayC
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TArrayC                                                              //
0019 //                                                                      //
0020 // Array of chars or bytes (8 bits per element).                        //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "TArray.h"
0025 
0026 
0027 class TArrayC : public TArray {
0028 
0029 public:
0030    Char_t    *fArray;       //[fN] Array of fN chars
0031 
0032    TArrayC();
0033    TArrayC(Int_t n);
0034    TArrayC(Int_t n, const Char_t *array);
0035    TArrayC(const TArrayC &array);
0036    TArrayC    &operator=(const TArrayC &rhs);
0037    virtual    ~TArrayC();
0038 
0039    void          Adopt(Int_t n, Char_t *array);
0040    void          AddAt(Char_t c, Int_t i);
0041    Char_t        At(Int_t i) const ;
0042    void          Copy(TArrayC &array) const {array.Set(fN,fArray);}
0043    const Char_t *GetArray() const { return fArray; }
0044    Char_t       *GetArray() { return fArray; }
0045    Double_t      GetAt(Int_t i) const override { return At(i); }
0046    Stat_t        GetSum() const {Stat_t sum=0; for (Int_t i=0;i<fN;i++) sum+=fArray[i]; return sum;}
0047    void          Reset(Char_t val=0)  {memset(fArray,val,fN*sizeof(Char_t));}
0048    void          Set(Int_t n) override;
0049    void          Set(Int_t n, const Char_t *array);
0050    void          SetAt(Double_t v, Int_t i) override { AddAt((Char_t)v, i); }
0051    Char_t       &operator[](Int_t i);
0052    Char_t        operator[](Int_t i) const;
0053 
0054    ClassDefOverride(TArrayC,1)  //Array of chars
0055 };
0056 
0057 
0058 #if defined R__TEMPLATE_OVERLOAD_BUG
0059 template <>
0060 #endif
0061 inline TBuffer &operator>>(TBuffer &buf, TArrayC *&obj)
0062 {
0063    // Read TArrayC object from buffer.
0064 
0065    obj = (TArrayC *) TArray::ReadArray(buf, TArrayC::Class());
0066    return buf;
0067 }
0068 
0069 #if defined R__TEMPLATE_OVERLOAD_BUG
0070 template <>
0071 #endif
0072 inline TBuffer &operator<<(TBuffer &buf, const TArrayC *obj)
0073 {
0074    // Write a TArrayC object into buffer
0075    return buf << (const TArray*)obj;
0076 }
0077 
0078 inline Char_t TArrayC::At(Int_t i) const
0079 {
0080    if (!BoundsOk("TArrayC::At", i)) return 0;
0081    return fArray[i];
0082 }
0083 
0084 inline Char_t &TArrayC::operator[](Int_t i)
0085 {
0086    if (!BoundsOk("TArrayC::operator[]", i))
0087       i = 0;
0088    return fArray[i];
0089 }
0090 
0091 inline Char_t TArrayC::operator[](Int_t i) const
0092 {
0093    if (!BoundsOk("TArrayC::operator[]", i)) return 0;
0094    return fArray[i];
0095 }
0096 
0097 #endif