62 _is(&is), _atEOL(
kFALSE), _atEOF(kFALSE), _prefix(""), _punct("()[]<>|/\\:?.,=+-&^%$
#@!`~") 72 _is(&is), _atEOL(kFALSE), _atEOF(kFALSE), _prefix(errorPrefix), _punct(
"()[]<>|/\\:?.,=+-&^%$#@!`~")
93 return (nc==
'\n'||nc==-1) ;
113 const char* punct = _punct.Data() ;
114 for (
int i=0 ; i<_punct.Length() ; i++)
135 char buffer[10240],
c(0), cnext=
'\0', cprev=
' ' ;
140 if (
_is->eof() ||
_is->fail()) {
146 if (
_is->peek()==
'\n') {
150 while (
_is->peek()==
'#') {
159 oocoutW((
TObject*)0,
InputArguments) <<
"RooStreamParser::readToken: token length exceeds buffer capacity, terminating token early" << endl ;
169 if (
_is->eof() ||
_is->fail() ||
c==
'\n')
break ;
182 if (
c ==
'.' ||
c==
'-' ||
c==
'+' ||
c==
'/' ||
c==
'\\') {
186 if (cnext==
'I' || cnext==
'i') {
192 haveINF = ((cnext==
'I' && tmp1 ==
'N' && tmp2 ==
'F') || (cnext==
'i' && tmp1 ==
'n' && tmp2 ==
'f')) ;
197 _is->putback(cnext) ;
202 if (
c==
'\\' && cnext==
'\\') {
211 if (
c==
'/' && cnext==
'/') {
220 }
else if (!quotedString) {
229 if (
isPunctChar(
c) && !(
c==
'.' && (isdigit(cnext)||isdigit(cprev)))
230 && (!
first || !((
c==
'-'||
c==
'+') && (isdigit(cnext)||cnext==
'.'||haveINF)))) {
259 if (
_is->eof() ||
_is->bad()) {
276 while ((isspace(
c) ||
c==
'/') &&
c !=
'\n') {
279 if (
_is->peek()==
'/') {
293 if (bufptr==0 && lineCont) {
299 return TString(buffer) ;
311 char c,buffer[10240] ;
314 if (
_is->peek()==
'\n')
_is->get(c) ;
317 _is->getline(buffer,nfree,
'\n') ;
320 char *pcontseq = strstr(buffer,
"\\\\") ;
321 if (pcontseq) nfree -= (pcontseq-buffer) ;
323 _is->getline(pcontseq,nfree,
'\n') ;
325 char* nextpcontseq = strstr(pcontseq,
"\\\\") ;
326 if (nextpcontseq) nfree -= (nextpcontseq-pcontseq) ;
327 pcontseq = nextpcontseq ;
331 char *pcomment = strstr(buffer,
"//") ;
332 if (pcomment) *pcomment=0 ;
335 char *pstart=buffer ;
336 while (isspace(*pstart)) {
339 char *pend=buffer+strlen(buffer)-1 ;
341 while (isspace(*pend)) { *pend--=0 ; }
343 if (
_is->eof() ||
_is->fail()) {
348 return TString(pstart) ;
361 if (
_is->peek()!=
'\n') {
367 _is->getline(buffer,nfree,
'\n') ;
371 char *pcontseq = strstr(buffer,
"\\\\") ;
372 if (pcontseq) nfree -= (pcontseq-buffer) ;
374 _is->getline(pcontseq,nfree,
'\n') ;
376 char* nextpcontseq = strstr(pcontseq,
"\\\\") ;
377 if (nextpcontseq) nfree -= (nextpcontseq-pcontseq) ;
378 pcontseq = nextpcontseq ;
396 Bool_t error=token.CompareTo(expected) ;
397 if (error && !_prefix.IsNull()) {
399 << expected <<
"'" <<
", got '" << token <<
"'" << endl ;
414 if (token.IsNull())
return kTRUE ;
427 const char*
data=token.Data() ;
430 if (!strcasecmp(data,
"inf") || !strcasecmp(data+1,
"inf")) {
435 value = strtod(data,&endptr) ;
436 Bool_t error = (endptr-data!=token.Length()) ;
438 if (error && !_prefix.IsNull()) {
440 << token <<
"'" <<
" to double precision" << endl ;
454 if (token.IsNull())
return kTRUE ;
467 const char*
data=token.Data() ;
468 value = strtol(data,&endptr,10) ;
469 Bool_t error = (endptr-data!=token.Length()) ;
471 if (error && !_prefix.IsNull()) {
473 << token <<
"'" <<
" to integer" << endl ;
488 if (token.IsNull())
return kTRUE ;
500 char buffer[10240],*ptr ;
501 strncpy(buffer,token.Data(),10239) ;
502 if (token.Length()>=10239) {
506 int len = strlen(buffer) ;
509 if ((len) && (buffer[len-1]==
'"'))
513 ptr=(buffer[0]==
'"') ? buffer+1 : buffer ;
Bool_t isPunctChar(char c) const
Check if given char is considered punctuation.
if on multiple lines(like in C++). **The " * configuration fragment. * * The "import myobject continue
Parses the configuration file.
Bool_t convertToDouble(const TString &token, Double_t &value)
Convert given string to a double. Return true if the conversion fails.
TString readToken()
Read one token separated by any of the know punctuation characters This function recognizes and handl...
Bool_t convertToInteger(const TString &token, Int_t &value)
Convert given string to an Int_t.
static Double_t infinity()
Return internal infinity representation.
void zapToEnd(Bool_t inclContLines=kFALSE)
Eat all characters up to and including then end of the current line.
RooStreamParser(std::istream &is)
Construct parser on given input stream.
Bool_t readDouble(Double_t &value, Bool_t zapOnError=kFALSE)
Read the next token and convert it to a Double_t.
TString readLine()
Read an entire line from the stream and return as TString This method recognizes the use of '\' in th...
Bool_t expectToken(const TString &expected, Bool_t zapOnError=kFALSE)
Read the next token and return kTRUE if it is identical to the given 'expected' token.
Bool_t readString(TString &value, Bool_t zapOnError=kFALSE)
Read a string token.
Bool_t convertToString(const TString &token, TString &string)
Convert given token to a string (i.e. remove eventual quotation marks)
void setPunctuation(const TString &punct)
Change list of characters interpreted as punctuation.
Mother of all ROOT objects.
virtual ~RooStreamParser()
Destructor.
Bool_t readInteger(Int_t &value, Bool_t zapOnError=kFALSE)
Read a token and convert it to an Int_t.
Bool_t atEOL()
If true, parser is at end of line in stream.