58 _is(&is), _atEOL(false), _atEOF(false), _prefix(
""), _punct(
"()[]<>|/\\:?.,=+-&^%$#@!`~")
68 _is(&is), _atEOL(false), _atEOF(false), _prefix(errorPrefix), _punct(
"()[]<>|/\\:?.,=+-&^%$#@!`~")
89 return (nc==
'\n'||nc==-1) ;
130 bool first(
true), quotedString(
false), lineCont(
false) ;
131 char buffer[64000],
c(0), cnext =
'\0', cprev =
' ';
132 bool haveINF(
false) ;
136 if (
_is->eof() ||
_is->fail()) {
142 if (
_is->peek()==
'\n') {
146 while (
_is->peek()==
'#') {
154 if (bufptr >= 63999) {
155 oocoutW(
nullptr, InputArguments)
156 <<
"RooStreamParser::readToken: token length exceeds buffer capacity, terminating token early" << endl;
166 if (
_is->eof() ||
_is->fail() ||
c==
'\n') break ;
179 if (
c ==
'.' ||
c==
'-' ||
c==
'+' ||
c==
'/' ||
c==
'\\') {
183 if (cnext==
'I' || cnext==
'i') {
189 haveINF = ((cnext==
'I' && tmp1 ==
'N' && tmp2 ==
'F') || (cnext==
'i' && tmp1 ==
'n' && tmp2 ==
'f')) ;
194 _is->putback(cnext) ;
199 if (
c==
'\\' && cnext==
'\\') {
208 if (
c==
'/' && cnext==
'/') {
217 }
else if (!quotedString) {
226 if (
isPunctChar(
c) && !(
c==
'.' && (isdigit(cnext)||isdigit(cprev)))
227 && !((
c==
'-'||
c==
'+') && isdigit(cnext) && (cprev ==
'e' || cprev ==
'E'))
228 && (!
first || !((
c==
'-'||
c==
'+') && (isdigit(cnext)||cnext==
'.'||haveINF)))) {
257 if (
_is->eof() ||
_is->bad()) {
263 oocoutW(
nullptr,InputArguments) <<
"RooStreamParser::readToken: closing quote (\") missing" << endl ;
274 while ((isspace(
c) ||
c==
'/') &&
c !=
'\n') {
277 if (
_is->peek()==
'/') {
291 if (bufptr==0 && lineCont) {
309 char c, buffer[64000];
312 if (
_is->peek() ==
'\n')
316 _is->getline(buffer, nfree,
'\n');
319 char *pcontseq = strstr(buffer,
"\\\\");
321 nfree -= (pcontseq - buffer);
323 _is->getline(pcontseq, nfree,
'\n');
325 char *nextpcontseq = strstr(pcontseq,
"\\\\");
327 nfree -= (nextpcontseq - pcontseq);
328 pcontseq = nextpcontseq;
332 char *pcomment = strstr(buffer,
"//") ;
333 if (pcomment) *pcomment=0 ;
336 char *pstart=buffer ;
337 while (isspace(*pstart)) {
340 char *pend=buffer+strlen(buffer)-1 ;
342 while (isspace(*pend)) { *pend--=0 ; }
344 if (
_is->eof() ||
_is->fail()) {
362 if (
_is->peek()!=
'\n') {
368 _is->getline(buffer, nfree,
'\n');
372 char *pcontseq = strstr(buffer,
"\\\\");
374 nfree -= (pcontseq - buffer);
376 _is->getline(pcontseq, nfree,
'\n');
378 char *nextpcontseq = strstr(pcontseq,
"\\\\");
380 nfree -= (nextpcontseq - pcontseq);
381 pcontseq = nextpcontseq;
401 oocoutW(
nullptr,InputArguments) <<
_prefix <<
": parse error, expected '"
402 << expected <<
"'" <<
", got '" << token <<
"'" << endl ;
417 if (token.
IsNull())
return true ;
433 if (!strcasecmp(
data,
"inf") || !strcasecmp(
data+1,
"inf")) {
442 oocoutE(
nullptr,InputArguments) <<
_prefix <<
": parse error, cannot convert '"
443 << token <<
"'" <<
" to double precision" << endl ;
457 if (token.
IsNull())
return true ;
475 oocoutE(
nullptr,InputArguments)<<
_prefix <<
": parse error, cannot convert '"
476 << token <<
"'" <<
" to integer" << endl ;
491 if (token.
IsNull())
return true ;
503 char buffer[64000], *ptr;
504 strncpy(buffer, token.
Data(), 63999);
505 if (token.
Length() >= 63999) {
506 oocoutW(
nullptr, InputArguments) <<
"RooStreamParser::convertToString: token length exceeds 63999, truncated"
510 int len = strlen(buffer) ;
513 if ((
len) && (buffer[
len-1]==
'"'))
517 ptr=(buffer[0]==
'"') ? buffer+1 : buffer ;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
static constexpr double infinity()
Return internal infinity representation.
bool convertToInteger(const TString &token, Int_t &value)
Convert given string to an Int_t.
bool readString(TString &value, bool zapOnError=false)
Read a string token.
void setPunctuation(const TString &punct)
Change list of characters interpreted as punctuation.
bool isPunctChar(char c) const
Check if given char is considered punctuation.
virtual ~RooStreamParser()
Destructor.
bool expectToken(const TString &expected, bool zapOnError=false)
Read the next token and return true if it is identical to the given 'expected' token.
bool convertToDouble(const TString &token, double &value)
Convert given string to a double. Return true if the conversion fails.
bool atEOL()
If true, parser is at end of line in stream.
TString readLine()
Read an entire line from the stream and return as TString This method recognizes the use of '\' in th...
bool readDouble(double &value, bool zapOnError=false)
Read the next token and convert it to a double.
TString readToken()
Read one token separated by any of the know punctuation characters This function recognizes and handl...
bool readInteger(Int_t &value, bool zapOnError=false)
Read a token and convert it to an Int_t.
void zapToEnd(bool inclContLines=false)
Eat all characters up to and including then end of the current line.
bool 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.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
const char * Data() const