ROOT logo
Podd » SRC » THaTextvars

class THaTextvars


THaTextvars

Generic string substitution facility
Contains a dictionary of text variable names and associated values.

Used for preprocessing of analyzer input files: Variable references
of the form ${name} in input files are replaced by their value.
For example, ${spectro}.s1.adc  ==>  R.s1.adc

The analyzer makes one instance of this class available via the
global gHaTextvars for easy access in scripts.

This code runs at initialization time and thus is not time-critical.


Function Members (Methods)

public:
THaTextvars()
THaTextvars(const THaTextvars&)
virtual~THaTextvars()
Int_tAdd(const string& name, const string& value)
Int_tAddVerbatim(const string& name, const string& value)
static TClass*Class()
voidClear()
const char*Get(const string& name, Int_t idx = 0) const
vector<std::string>GetArray(const string& name)
UInt_tGetArray(const string& name, vector<std::string>& array)
UInt_tGetNvalues(const string& name) const
virtual TClass*IsA() const
THaTextvars&operator=(const THaTextvars&)
voidPrint(Option_t* opt = "") const
voidRemove(const string& name)
Int_tSet(const string& name, const string& value)
virtual voidShowMembers(TMemberInspector&)
UInt_tSize() const
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
Int_tSubstitute(string& line) const
Int_tSubstitute(vector<std::string>& lines) const
private:
Int_tSubstitute(vector<std::string>& lines, bool do_multi) const

Data Members

private:
map<string,vector<string>,less<string>,allocator<pair<const string,vector<string> > > >fVars

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

Int_t Add(const string& name, const string& value)
 Add or Set/Replace text variable with given name and value.
 Parse value for multiple comma-separated tokens and store them as
 individual values.
Int_t AddVerbatim(const string& name, const string& value)
 Add or Set/Replace text variable with given name and value.
 Does not scan value for tokens; hence allows values that contain a ","
const char* Get(const string& name, Int_t idx = 0) const
 Get the i-th value of the text variable with the given name.
 Returns either the value or NULL if not found.
UInt_t GetArray(const string& name, vector<std::string>& array)
 Get the array of values for the text variable with the given name.
 Returns number of values found (size of array), or zero if not found.
vector<string> GetArray(const string& name)
 Get the values array for the text variable with the given name.
 If name is not found, the returned array has size zero.
 This function is inefficient and provided only for backward
 compatibility. Use GetArray( const string&, vector<string>& )
 instead.
UInt_t GetNvalues(const string& name) const
 Get the number of values for the text variable with the given name.
void Print(Option_t* opt = "") const
 Print all text variables
Int_t Substitute(string& line) const
 Substitute text variables in a single string.
 If any multi-valued variables are encountered, treat it as an error
Int_t Substitute(vector<std::string>& lines, bool do_multi) const
 Substitute text variables in the given array of strings.
 Supports multi-valued text variables, where each instance is
 separated by commas; e.g. arm = "L,R".

 Text Variables have the form ${name}

 Returns 0 if success, 1 on error (name not found)
THaTextvars()
{}
virtual ~THaTextvars()
{}
void Clear()
{ fVars.clear(); }
void Remove(const string& name)
{ fVars.erase(name); }
UInt_t Size() const
{ return fVars.size(); }
Int_t Set(const string& name, const string& value)
Int_t Substitute(string& line) const