60 _is(&is), _atEOL(
kFALSE), _atEOF(
kFALSE), _prefix(
""), _punct(
"()[]<>|/\\:?.,=+-&^%$#@!`~")
70 _is(&is), _atEOL(
kFALSE), _atEOF(
kFALSE), _prefix(errorPrefix), _punct(
"()[]<>|/\\:?.,=+-&^%$#@!`~")
91 return (nc==
'\n'||nc==-1) ;
133 char buffer[64000],
c(0), cnext =
'\0', cprev =
' ';
138 if (
_is->eof() ||
_is->fail()) {
144 if (
_is->peek()==
'\n') {
148 while (
_is->peek()==
'#') {
156 if (bufptr >= 63999) {
158 <<
"RooStreamParser::readToken: token length exceeds buffer capacity, terminating token early" << endl;
168 if (
_is->eof() ||
_is->fail() ||
c==
'\n') break ;
181 if (
c ==
'.' ||
c==
'-' ||
c==
'+' ||
c==
'/' ||
c==
'\\') {
185 if (cnext==
'I' || cnext==
'i') {
191 haveINF = ((cnext==
'I' && tmp1 ==
'N' && tmp2 ==
'F') || (cnext==
'i' && tmp1 ==
'n' && tmp2 ==
'f')) ;
196 _is->putback(cnext) ;
201 if (
c==
'\\' && cnext==
'\\') {
210 if (
c==
'/' && cnext==
'/') {
219 }
else if (!quotedString) {
228 if (
isPunctChar(
c) && !(
c==
'.' && (isdigit(cnext)||isdigit(cprev)))
229 && !((
c==
'-'||
c==
'+') && isdigit(cnext) && (cprev ==
'e' || cprev ==
'E'))
230 && (!
first || !((
c==
'-'||
c==
'+') && (isdigit(cnext)||cnext==
'.'||haveINF)))) {
259 if (
_is->eof() ||
_is->bad()) {
265 oocoutW((
TObject*)0,InputArguments) <<
"RooStreamParser::readToken: closing quote (\") missing" << endl ;
276 while ((isspace(
c) ||
c==
'/') &&
c !=
'\n') {
279 if (
_is->peek()==
'/') {
293 if (bufptr==0 && lineCont) {
311 char c, buffer[64000];
314 if (
_is->peek() ==
'\n')
318 _is->getline(buffer, nfree,
'\n');
321 char *pcontseq = strstr(buffer,
"\\\\");
323 nfree -= (pcontseq - buffer);
325 _is->getline(pcontseq, nfree,
'\n');
327 char *nextpcontseq = strstr(pcontseq,
"\\\\");
329 nfree -= (nextpcontseq - pcontseq);
330 pcontseq = nextpcontseq;
334 char *pcomment = strstr(buffer,
"//") ;
335 if (pcomment) *pcomment=0 ;
338 char *pstart=buffer ;
339 while (isspace(*pstart)) {
342 char *pend=buffer+strlen(buffer)-1 ;
344 while (isspace(*pend)) { *pend--=0 ; }
346 if (
_is->eof() ||
_is->fail()) {
364 if (
_is->peek()!=
'\n') {
370 _is->getline(buffer, nfree,
'\n');
374 char *pcontseq = strstr(buffer,
"\\\\");
376 nfree -= (pcontseq - buffer);
378 _is->getline(pcontseq, nfree,
'\n');
380 char *nextpcontseq = strstr(pcontseq,
"\\\\");
382 nfree -= (nextpcontseq - pcontseq);
383 pcontseq = nextpcontseq;
404 << expected <<
"'" <<
", got '" << token <<
"'" << endl ;
432 const char* data=token.
Data() ;
435 if (!strcasecmp(data,
"inf") || !strcasecmp(data+1,
"inf")) {
440 value = strtod(data,&endptr) ;
445 << token <<
"'" <<
" to double precision" << endl ;
472 const char* data=token.
Data() ;
473 value = strtol(data,&endptr,10) ;
478 << token <<
"'" <<
" to integer" << endl ;
505 char buffer[64000], *ptr;
506 strncpy(buffer, token.
Data(), 63999);
507 if (token.
Length() >= 63999) {
508 oocoutW((
TObject *)0, InputArguments) <<
"RooStreamParser::convertToString: token length exceeds 63999, truncated"
512 int len = strlen(buffer) ;
515 if ((len) && (buffer[len-1]==
'"'))
519 ptr=(buffer[0]==
'"') ? buffer+1 : buffer ;
static Double_t infinity()
Return internal infinity representation.
Bool_t isPunctChar(char c) const
Check if given char is considered punctuation.
Bool_t atEOL()
If true, parser is at end of line in stream.
Bool_t readInteger(Int_t &value, Bool_t zapOnError=kFALSE)
Read a token and convert it to an Int_t.
Bool_t readDouble(Double_t &value, Bool_t zapOnError=kFALSE)
Read the next token and convert it to a Double_t.
Bool_t convertToDouble(const TString &token, Double_t &value)
Convert given string to a double. Return true if the conversion fails.
Bool_t readString(TString &value, Bool_t zapOnError=kFALSE)
Read a string token.
void setPunctuation(const TString &punct)
Change list of characters interpreted as punctuation.
void zapToEnd(Bool_t inclContLines=kFALSE)
Eat all characters up to and including then end of the current line.
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.
virtual ~RooStreamParser()
Destructor.
Bool_t convertToInteger(const TString &token, Int_t &value)
Convert given string to an Int_t.
TString readLine()
Read an entire line from the stream and return as TString This method recognizes the use of '\' in th...
TString readToken()
Read one token separated by any of the know punctuation characters This function recognizes and handl...
Bool_t convertToString(const TString &token, TString &string)
Convert given token to a string (i.e. remove eventual quotation marks)
RooStreamParser(std::istream &is)
Construct parser on given input stream.
Mother of all ROOT objects.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
const char * Data() const