49using std::istream, std::endl;
77 return (nc==
'\n'||nc==-1) ;
97 const char* punct =
_punct.Data() ;
98 for (
int i = 0; i <
_punct.Length(); i++) {
120 bool quotedString(
false);
121 bool lineCont(
false);
126 bool haveINF(
false) ;
130 if (
_is->eof() ||
_is->fail()) {
136 if (
_is->peek()==
'\n') {
140 while (
_is->peek()==
'#') {
148 if (bufptr >= 63999) {
149 oocoutW(
nullptr, InputArguments)
150 <<
"RooStreamParser::readToken: token length exceeds buffer capacity, terminating token early" << std::endl;
166 }
else if (!quotedString) {
172 if (
c ==
'.' ||
c==
'-' ||
c==
'+' ||
c==
'/' ||
c==
'\\') {
176 if (cnext==
'I' || cnext==
'i') {
183 haveINF = ((cnext ==
'I' && tmp1 ==
'N' && tmp2 ==
'F') || (cnext ==
'i' && tmp1 ==
'n' && tmp2 ==
'f'));
188 _is->putback(cnext) ;
193 if (
c==
'\\' && cnext==
'\\') {
202 if (
c==
'/' && cnext==
'/') {
211 }
else if (!quotedString) {
220 if (
isPunctChar(
c) && !(
c==
'.' && (isdigit(cnext)||isdigit(cprev)))
221 && !((
c==
'-'||
c==
'+') && isdigit(cnext) && (cprev ==
'e' || cprev ==
'E'))
222 && (!first || !((
c==
'-'||
c==
'+') && (isdigit(cnext)||cnext==
'.'||haveINF)))) {
238 if (
c==
'"' && !first) {
251 if (
_is->eof() ||
_is->bad()) {
257 oocoutW(
nullptr,InputArguments) <<
"RooStreamParser::readToken: closing quote (\") missing" << std::endl ;
268 while ((isspace(
c) ||
c==
'/') &&
c !=
'\n') {
271 if (
_is->peek()==
'/') {
285 if (bufptr==0 && lineCont) {
307 if (
_is->peek() ==
'\n')
311 _is->getline(buffer, nfree,
'\n');
314 char *pcontseq = strstr(buffer,
"\\\\");
316 nfree -= (pcontseq - buffer);
318 _is->getline(pcontseq, nfree,
'\n');
320 char *nextpcontseq = strstr(pcontseq,
"\\\\");
322 nfree -= (nextpcontseq - pcontseq);
323 pcontseq = nextpcontseq;
327 char *pcomment = strstr(buffer,
"//");
332 char *pstart = buffer;
333 while (isspace(*pstart)) {
336 char *pend = buffer + strlen(buffer) - 1;
338 while (isspace(*pend)) {
343 if (
_is->eof() ||
_is->fail()) {
361 if (
_is->peek()!=
'\n') {
367 _is->getline(buffer, nfree,
'\n');
371 char *pcontseq = strstr(buffer,
"\\\\");
373 nfree -= (pcontseq - buffer);
375 _is->getline(pcontseq, nfree,
'\n');
377 char *nextpcontseq = strstr(pcontseq,
"\\\\");
379 nfree -= (nextpcontseq - pcontseq);
380 pcontseq = nextpcontseq;
399 if (error && !
_prefix.IsNull()) {
400 oocoutW(
nullptr,InputArguments) <<
_prefix <<
": parse error, expected '"
401 << expected <<
"'" <<
", got '" << token <<
"'" << std::endl ;
416 if (token.
IsNull())
return true ;
439 if (token.
IsNull())
return true ;
451 char* endptr =
nullptr;
456 if (error && !
_prefix.IsNull()) {
457 oocoutE(
nullptr,InputArguments)<<
_prefix <<
": parse error, cannot convert '"
458 << token <<
"'" <<
" to integer" << std::endl ;
473 if (token.
IsNull())
return true ;
487 strncpy(buffer, token.
Data(), 63999);
488 if (token.
Length() >= 63999) {
489 oocoutW(
nullptr, InputArguments) <<
"RooStreamParser::convertToString: token length exceeds 63999, truncated"
493 int len = strlen(buffer) ;
496 if ((
len) && (buffer[
len-1]==
'"'))
500 ptr=(buffer[0]==
'"') ? buffer+1 : buffer ;
double toDouble(const char *s)
int Int_t
Signed integer 4 bytes (int).
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
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.
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. Throws exceptions 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