ROOT logo
Podd » SRC » THaArrayString

class THaArrayString


 THaArrayString

 This class parses the array subscript(s) of variable.
 In the trivial case of a scalar, it simply stores the variable name.
 Otherwise, it extracts the individual subscript(s) and number of
 dimensions.

 Example:

   THaArrayString txt("x[7,4]");

 gives
    fName   = "x"
    fNdim   = 2
    fDim    = [ 7, 4 ]
    fLen    = 7*4 = 28
    fStatus = 0

 THaArrayStrings are used in particular by THaFormula and THaVar.


Function Members (Methods)

public:
THaArrayString()
THaArrayString(const char* string)
THaArrayString(const THaArrayString&)
virtual~THaArrayString()
static TClass*Class()
const Int_t*GetDim() const
Int_tGetLen() const
const char*GetName() const
Int_tGetNdim() const
ULong_tHash() const
virtual TClass*IsA() const
Bool_tIsArray() const
Bool_tIsError() const
const char*operator const char*() const
const TString&operator const TString&() const
booloperator!() const
THaArrayString&operator=(const THaArrayString&)
THaArrayString&operator=(const char* rhs)
Int_toperator[](Int_t i) const
virtual Int_tParse(const char* string = "")
virtual voidPrint(Option_t* opt = "") const
virtual voidShowMembers(TMemberInspector&)
THaArrayString::EStatusStatus() const
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)

Data Members

public:
enum EStatus { kOK
kBadsyntax
kIllegalchars
kToolarge
kToolong
kNotinit
};
protected:
Int_t*fDimDimensions, if any (NULL for scalar)
Int_tfLenLength of array (product of all dimensions)
TStringfNameVariable name
Int_tfNdimNumber of array dimensions (0=scalar)
THaArrayString::EStatusfStatusStatus of Parse()

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

THaArrayString(const THaArrayString& )
 Copy constructor
THaArrayString& operator=(const THaArrayString& )
 Assignment operator
Int_t Parse(const char* string = "")
 Parse the given string for array syntax.
 For multidimensional arrays, both C-style and comma-separated subscripts
 are supported.

 Examples of legal expressions:

    "x"           scalar "x"
    "x[2]"        1-d array "x" of size 2
    "x[2][3]"     2-d array "x" of size 2x3=6
    "x[2,3]"      same 2-d array
    "x[2][3][4]"  3-d array "x" of size 2x3x4=24

 Results are stored in this object and can be retrieved using
 GetName(), GetNdim(), GetDim(), and GetLen().

 The maximum length of the input string is 255 characters.

 Returns 0 if ok, or EStatus error code otherwise (see header).
void Print(Option_t* opt = "") const
 Print the name and array dimension(s), if any.
 If option == "dimonly", only print the dimensions, without square brackets.
Int_t operator[](Int_t i) const
 Return i-th array dimension
THaArrayString()
{}
THaArrayString(const char* string)
{ Parse(); }
THaArrayString& operator=(const THaArrayString& )
virtual ~THaArrayString()
{ delete [] fDim; }
operator const char*() const
{ return fName.Data(); }
operator const TString&() const
{ return fName; }
bool operator!() const
{ return IsError(); }
const Int_t* GetDim() const
{ return fDim; }
Int_t GetLen() const
{ return fLen; }
const char* GetName() const
{ return fName.Data(); }
Int_t GetNdim() const
{ return fNdim; }
ULong_t Hash() const
{ return fName.Hash(); }
Bool_t IsArray() const
{ return (fNdim > 0); }
Bool_t IsError() const
{ return (fStatus != kOK); }