Logo ROOT   6.07/09
Reference Guide
RooStreamParser.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooStreamParser.h,v 1.17 2007/05/11 09:11:30 verkerke Exp $
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 #ifndef ROO_STREAM_PARSER
17 #define ROO_STREAM_PARSER
18 
19 #include "Riosfwd.h"
20 #include "TString.h"
21 
23 public:
24  // Constructors, assignment etc.
25  RooStreamParser(std::istream& is) ;
26  RooStreamParser(std::istream& is, const TString& errPrefix) ;
27  virtual ~RooStreamParser();
28 
29  TString readToken() ;
30  TString readLine() ;
31  Bool_t expectToken(const TString& expected, Bool_t zapOnError=kFALSE) ;
32  void setPunctuation(const TString& punct) ;
33  TString getPunctuation() const { return _punct ; }
34 
35  Bool_t readDouble(Double_t& value, Bool_t zapOnError=kFALSE) ;
36  Bool_t convertToDouble(const TString& token, Double_t& value) ;
37 
38  Bool_t readInteger(Int_t& value, Bool_t zapOnError=kFALSE) ;
39  Bool_t convertToInteger(const TString& token, Int_t& value) ;
40 
41  Bool_t readString(TString& value, Bool_t zapOnError=kFALSE) ;
42  Bool_t convertToString(const TString& token, TString& string) ;
43 
44  Bool_t atEOL() ;
45  inline Bool_t atEOF() { return _atEOF ; }
46  void zapToEnd(Bool_t inclContLines=kFALSE) ;
47 
48  Bool_t isPunctChar(char c) const ;
49 
50 protected:
51 
52  std::istream* _is ;
57 
58 
59  ClassDef(RooStreamParser,0) // Utility class that parses std::iostream data into tokens
60 };
61 
62 #endif
TString getPunctuation() const
return c
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
#define ClassDef(name, id)
Definition: Rtypes.h:254
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.
void zapToEnd(Bool_t inclContLines=kFALSE)
Eat all characters up to and including then end of the current line.
Bool_t isPunctChar(char c) const
Check if given char is considered punctuation.
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.
double Double_t
Definition: RtypesCore.h:55
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.
std::istream * _is
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.