#include <rarStrParser.hh>
Public Member Functions | |
rarStrParser () | |
Trivial ctor. | |
rarStrParser (const char *str) | |
Ctor using char pointer. | |
rarStrParser (const TString str) | |
Ctor using TString object. | |
rarStrParser (const rarStrParser &) | |
Ctor for assignment using its own object. | |
virtual | ~rarStrParser () |
void | operator= (const char *str) |
Operator = with char pointer. | |
void | operator= (const TString str) |
Operator = with TString object. | |
void | operator= (const RooStringVar str) |
Operator = with RooStringVar object. | |
TString & | operator[] (const Int_t idx) |
Get the indexed token. | |
void | Remove (const Int_t idx=0) |
Remove the indexed token. | |
Int_t | Index (const TString token) |
Get the index for a token. | |
Bool_t | Have (const TString token) |
Check if have the token. | |
Int_t | nArgs () |
Return number of tokens. | |
Protected Member Functions | |
void | init () |
Initial function to parse a string. | |
TObjString * | nextToken () |
Get next token in the string from current position. | |
Protected Attributes | |
TString | _str |
String to parse. | |
TList | _strs |
List of parsed tokens. | |
Private Member Functions | |
ClassDef (rarStrParser, 0) | |
Private Attributes | |
Int_t | _idx |
Current char index used for string parsing. |
It is the string parser used widely by other RooRarFit classes to direct their actions through config items in config file. It breaks a string into tokens seperated by spaces. Characters inside quote(") are considered one token. Currently, quote (") can not be inside the parsed tokens.
Definition at line 27 of file rarStrParser.hh.
rarStrParser::rarStrParser | ( | ) |
rarStrParser::rarStrParser | ( | const char * | str | ) |
Ctor using char pointer.
str | String to parse |
Definition at line 44 of file rarStrParser.cc.
References init().
rarStrParser::rarStrParser | ( | const TString | str | ) |
Ctor using TString object.
str | String to parse |
Definition at line 54 of file rarStrParser.cc.
References init().
rarStrParser::rarStrParser | ( | const rarStrParser & | aParser | ) |
Ctor for assignment using its own object.
aParser | Source object |
Definition at line 63 of file rarStrParser.cc.
00064 : TObject(aParser) 00065 { 00066 _str=aParser._str; 00067 // go through tokens and copy them 00068 for (Int_t i=0; i<((rarStrParser&)aParser).nArgs(); i++) 00069 _strs.Add(new TObjString(((rarStrParser&)aParser)[i])); 00070 }
rarStrParser::~rarStrParser | ( | ) | [virtual] |
Definition at line 72 of file rarStrParser.cc.
References _strs.
00073 { 00074 _strs.Delete(); 00075 }
rarStrParser::ClassDef | ( | rarStrParser | , | |
0 | ||||
) | [private] |
Bool_t rarStrParser::Have | ( | const TString | token | ) |
Check if have the token.
token | Token to check |
Definition at line 130 of file rarStrParser.cc.
References Index().
Referenced by rarBasePdf::doPdfFit(), rarBasePdf::doPdfPlot(), rarMLFitter::doSPlot(), rarMLFitter::getSnB(), rarConfig::getVarTNTU(), rarDatasets::isBlind(), rarBasePdf::isFracName(), rarBasePdf::matchCatType(), and rarMLFitter::run().
00130 { 00131 return (Index(token)<0) ? kFALSE : kTRUE; 00132 }
Int_t rarStrParser::Index | ( | const TString | token | ) |
Get the index for a token.
token | Token to check |
Definition at line 139 of file rarStrParser.cc.
References nArgs().
Referenced by rarMLFitter::doContourPlot(), rarMLFitter::doSPlot(), rarConfig::getVarTNTU(), Have(), and rarMLPdf::init().
00139 { 00140 Int_t index(-1); 00141 for (Int_t i=0; i<nArgs(); i++) 00142 if (token==operator[](i)) return i; 00143 return index; 00144 }
void rarStrParser::init | ( | ) | [protected] |
Initial function to parse a string.
It initializes _idx and _strs and calls nextToken to parse the string
Definition at line 150 of file rarStrParser.cc.
References _idx, _strs, and nextToken().
Referenced by operator=(), and rarStrParser().
00151 { 00152 // reset index and parsed string objs 00153 _idx=0; 00154 _strs.Delete(); 00155 TObjString *objStr(0); 00156 while (objStr=nextToken()) { 00157 _strs.Add(objStr); 00158 } 00159 }
Int_t rarStrParser::nArgs | ( | ) | [inline] |
Return number of tokens.
Definition at line 45 of file rarStrParser.hh.
References _strs.
Referenced by rarMLFitter::avgSysErrors(), rarConfig::createAbsVar(), rarConfig::createAbsVars(), rarConfig::createDataSet(), rarConfig::createPdf(), rarBasePdf::createPdfs(), rarMLFitter::doCombinePlot(), rarMLFitter::doLLRPlot(), rarBasePdf::doPdfFit(), rarBasePdf::doPdfPlot(), rarMLFitter::doProjPlot(), rarMLFitter::doScanPlot(), rarMLFitter::doSignf(), rarMLFitter::doSPlot(), rarMLFitter::doSysStudy(), rarMLFitter::doToyStudy(), rarMLFitter::generate(), rarBasePdf::getArgSet(), rarBasePdf::getControlBit(), rarMLFitter::getCorrMatrix(), rarDatasets::getData(), rarDatasetDef::getFormulaArgs(), rarBasePdf::getFormulaArgs(), rarMLFitter::getParamFileName(), rarBasePdf::getRange(), rarMLFitter::getSnB(), rarMLFitter::getSplitCat(), rarMLFitter::getSplitCatSet(), rarConfig::getVarTNTU(), Index(), rarStep::init(), rarProd::init(), rarMLPdf::init(), rarMLFitter::init(), rarDecay::init(), rarDatasets::init(), rarBinned::init(), rarDatasets::isBlind(), rarBasePdf::matchCatType(), rarMLFitter::run(), and rarBasePdf::setControlBits().
00045 {return _strs.GetSize();}
TObjString * rarStrParser::nextToken | ( | ) | [protected] |
Get next token in the string from current position.
Definition at line 172 of file rarStrParser.cc.
Referenced by init().
00173 { 00174 Int_t nIdx(0); 00175 if (_idx>=_str.Length()) return 0; 00176 while (' '==_str[_idx] || '\t'==_str[_idx] || '\n'==_str[_idx]) { 00177 _idx++; 00178 if (_idx>=_str.Length()) return 0; 00179 } 00180 if ('"'==_str[_idx]) { 00181 _idx++; 00182 nIdx=_str.Index("\"", _idx); 00183 if(nIdx<0) return 0; 00184 } else { 00185 nIdx=_str.Index(" ", _idx); 00186 if(nIdx<0) nIdx=_str.Length(); 00187 } 00188 //cout<<"in Parser "<<nIdx<<" "<<_idx<<" "<<_str(_idx, nIdx-_idx)<<endl; 00189 TString substr=_str(_idx, nIdx-_idx); 00190 TObjString *subStr=new TObjString(substr); 00191 _idx=nIdx; 00192 if (_idx<_str.Length()) 00193 if ('"'==_str[_idx]) _idx++; 00194 00195 return subStr; 00196 }
void rarStrParser::operator= | ( | const RooStringVar | str | ) |
Operator = with RooStringVar object.
str | String to parse |
Definition at line 97 of file rarStrParser.cc.
References operator=().
00098 { 00099 rarStrParser::operator=(str.getVal()); 00100 }
void rarStrParser::operator= | ( | const TString | str | ) |
Operator = with TString object.
str | String to parse |
Definition at line 89 of file rarStrParser.cc.
References operator=().
00090 { 00091 rarStrParser::operator=(str.Data()); 00092 }
void rarStrParser::operator= | ( | const char * | str | ) |
Operator = with char pointer.
str | String to parse |
Definition at line 80 of file rarStrParser.cc.
Referenced by operator=().
TString & rarStrParser::operator[] | ( | const Int_t | idx | ) |
void rarStrParser::Remove | ( | const Int_t | idx = 0 |
) |
Remove the indexed token.
idx | The index of token to be removed |
Definition at line 116 of file rarStrParser.cc.
References _strs.
Referenced by rarConfig::createAbsVar(), rarConfig::createAbsVars(), rarConfig::createDataSet(), rarConfig::createPdf(), rarMLFitter::doContourPlot(), rarMLFitter::doLLRPlot(), rarBasePdf::doPdfFit(), rarBasePdf::doPdfPlot(), rarMLFitter::doProjPlot(), rarMLFitter::doScanPlot(), rarMLFitter::doSignf(), rarMLFitter::doSPlot(), rarMLFitter::doSysStudy(), rarMLFitter::doToyStudy(), rarMLFitter::generate(), rarBasePdf::getFormulaVal(), rarMLFitter::getParamFileName(), rarBasePdf::getRange(), rarMLFitter::getSplitCat(), rarConfig::getVarTNTU(), rarMLFitter::init(), rarGeneric::init(), rarBasePdf::init(), rarDatasets::isBlind(), and rarMLFitter::run().
00117 { 00118 TObject *val=_strs.At(idx); 00119 if (val) { 00120 _strs.Remove(val); 00121 delete val; 00122 } 00123 }
Int_t rarStrParser::_idx [private] |
Current char index used for string parsing.
Definition at line 55 of file rarStrParser.hh.
Referenced by init(), and nextToken().
TString rarStrParser::_str [protected] |
String to parse.
Definition at line 51 of file rarStrParser.hh.
Referenced by nextToken(), operator=(), operator[](), and rarStrParser().
TList rarStrParser::_strs [protected] |
List of parsed tokens.
Definition at line 52 of file rarStrParser.hh.
Referenced by init(), nArgs(), operator[](), rarStrParser(), Remove(), and ~rarStrParser().