Logo ROOT   6.10/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 "TString.h"
20 
22 public:
23  // Constructors, assignment etc.
24  RooStreamParser(std::istream& is) ;
25  RooStreamParser(std::istream& is, const TString& errPrefix) ;
26  virtual ~RooStreamParser();
27 
28  TString readToken() ;
29  TString readLine() ;
30  Bool_t expectToken(const TString& expected, Bool_t zapOnError=kFALSE) ;
31  void setPunctuation(const TString& punct) ;
32  TString getPunctuation() const { return _punct ; }
33 
34  Bool_t readDouble(Double_t& value, Bool_t zapOnError=kFALSE) ;
35  Bool_t convertToDouble(const TString& token, Double_t& value) ;
36 
37  Bool_t readInteger(Int_t& value, Bool_t zapOnError=kFALSE) ;
38  Bool_t convertToInteger(const TString& token, Int_t& value) ;
39 
40  Bool_t readString(TString& value, Bool_t zapOnError=kFALSE) ;
41  Bool_t convertToString(const TString& token, TString& string) ;
42 
43  Bool_t atEOL() ;
44  inline Bool_t atEOF() { return _atEOF ; }
45  void zapToEnd(Bool_t inclContLines=kFALSE) ;
46 
47  Bool_t isPunctChar(char c) const ;
48 
49 protected:
50 
51  std::istream* _is ;
56 
57 
58  ClassDef(RooStreamParser,0) // Utility class that parses std::iostream data into tokens
59 };
60 
61 #endif
Bool_t isPunctChar(char c) const
Check if given char is considered punctuation.
Basic string class.
Definition: TString.h:129
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
#define ClassDef(name, id)
Definition: Rtypes.h:297
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.
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.
const Bool_t kFALSE
Definition: RtypesCore.h:92
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.
TString getPunctuation() const
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.