Logo ROOT  
Reference Guide
TArrayC.h
Go to the documentation of this file.
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 #include "TArray.h"
25 
26 
27 class TArrayC : public TArray {
28 
29 public:
30  Char_t *fArray; //[fN] Array of fN chars
31 
32  TArrayC();
33  TArrayC(Int_t n);
34  TArrayC(Int_t n, const Char_t *array);
35  TArrayC(const TArrayC &array);
36  TArrayC &operator=(const TArrayC &rhs);
37  virtual ~TArrayC();
38 
39  void Adopt(Int_t n, Char_t *array);
40  void AddAt(Char_t c, Int_t i);
41  Char_t At(Int_t i) const ;
42  void Copy(TArrayC &array) const {array.Set(fN,fArray);}
43  const Char_t *GetArray() const { return fArray; }
44  Char_t *GetArray() { return fArray; }
45  Double_t GetAt(Int_t i) const { return At(i); }
46  Stat_t GetSum() const {Stat_t sum=0; for (Int_t i=0;i<fN;i++) sum+=fArray[i]; return sum;}
47  void Reset(Char_t val=0) {memset(fArray,val,fN*sizeof(Char_t));}
48  void Set(Int_t n);
49  void Set(Int_t n, const Char_t *array);
50  void SetAt(Double_t v, Int_t i) { AddAt((Char_t)v, i); }
52  Char_t operator[](Int_t i) const;
53 
54  ClassDef(TArrayC,1) //Array of chars
55 };
56 
57 
58 #if defined R__TEMPLATE_OVERLOAD_BUG
59 template <>
60 #endif
61 inline TBuffer &operator>>(TBuffer &buf, TArrayC *&obj)
62 {
63  // Read TArrayC object from buffer.
64 
65  obj = (TArrayC *) TArray::ReadArray(buf, TArrayC::Class());
66  return buf;
67 }
68 
69 #if defined R__TEMPLATE_OVERLOAD_BUG
70 template <>
71 #endif
72 inline TBuffer &operator<<(TBuffer &buf, const TArrayC *obj)
73 {
74  // Write a TArrayC object into buffer
75  return buf << (const TArray*)obj;
76 }
77 
78 inline Char_t TArrayC::At(Int_t i) const
79 {
80  if (!BoundsOk("TArrayC::At", i)) return 0;
81  return fArray[i];
82 }
83 
85 {
86  if (!BoundsOk("TArrayC::operator[]", i))
87  i = 0;
88  return fArray[i];
89 }
90 
92 {
93  if (!BoundsOk("TArrayC::operator[]", i)) return 0;
94  return fArray[i];
95 }
96 
97 #endif
c
#define c(i)
Definition: RSha256.hxx:101
n
const Int_t n
Definition: legend1.C:16
TArrayC::Adopt
void Adopt(Int_t n, Char_t *array)
Adopt array arr into TArrayC, i.e.
Definition: TArrayC.cxx:81
operator<<
TBuffer & operator<<(TBuffer &buf, const TArrayC *obj)
Definition: TArrayC.h:72
TArrayC::GetArray
Char_t * GetArray()
Definition: TArrayC.h:44
operator>>
TBuffer & operator>>(TBuffer &buf, TArrayC *&obj)
Definition: TArrayC.h:61
sum
static uint64_t sum(uint64_t i)
Definition: Factory.cxx:2345
TArrayC::Set
void Set(Int_t n)
Set size of this array to n chars.
Definition: TArrayC.cxx:105
Int_t
int Int_t
Definition: RtypesCore.h:45
TArrayC::AddAt
void AddAt(Char_t c, Int_t i)
Add char c at position i. Check for out of bounds.
Definition: TArrayC.cxx:93
TArrayC::fArray
Char_t * fArray
Definition: TArrayC.h:30
TBuffer
Buffer base class used for serializing objects.
Definition: TBuffer.h:43
TArray::fN
Int_t fN
Definition: TArray.h:38
v
@ v
Definition: rootcling_impl.cxx:3635
TArrayC::GetSum
Stat_t GetSum() const
Definition: TArrayC.h:46
TArrayC::operator=
TArrayC & operator=(const TArrayC &rhs)
TArrayC assignment operator.
Definition: TArrayC.cxx:61
TArrayC::Reset
void Reset(Char_t val=0)
Definition: TArrayC.h:47
TArrayC::Copy
void Copy(TArrayC &array) const
Definition: TArrayC.h:42
TArrayC::TArrayC
TArrayC()
Default TArrayC ctor.
Definition: TArrayC.cxx:26
TArrayC::GetAt
Double_t GetAt(Int_t i) const
Definition: TArrayC.h:45
TArrayC::operator[]
Char_t & operator[](Int_t i)
Definition: TArrayC.h:84
TArrayC
Array of chars or bytes (8 bits per element).
Definition: TArrayC.h:27
TArrayC::SetAt
void SetAt(Double_t v, Int_t i)
Definition: TArrayC.h:50
TArray::ReadArray
static TArray * ReadArray(TBuffer &b, const TClass *clReq)
Read TArray object from buffer.
Definition: TArray.cxx:41
Double_t
double Double_t
Definition: RtypesCore.h:59
TArray
Abstract array base class.
Definition: TArray.h:31
TArray::BoundsOk
Bool_t BoundsOk(const char *where, Int_t at) const
Definition: TArray.h:77
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TArrayC::At
Char_t At(Int_t i) const
Definition: TArrayC.h:78
TArrayC::~TArrayC
virtual ~TArrayC()
Delete TArrayC object.
Definition: TArrayC.cxx:71
TArray.h
Stat_t
double Stat_t
Definition: RtypesCore.h:77
TArrayC::GetArray
const Char_t * GetArray() const
Definition: TArrayC.h:43
Class
void Class()
Definition: Class.C:29
Char_t
char Char_t
Definition: RtypesCore.h:33
int