00001 /***************************************************************************** 00002 * Project: RooFit * 00003 * Package: RooFitCore * 00004 * File: $Id: RooStreamParser.h,v 1.17 2007/05/11 09:11:30 verkerke Exp $ 00005 * Authors: * 00006 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu * 00007 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu * 00008 * * 00009 * Copyright (c) 2000-2005, Regents of the University of California * 00010 * and Stanford University. All rights reserved. * 00011 * * 00012 * Redistribution and use in source and binary forms, * 00013 * with or without modification, are permitted according to the terms * 00014 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) * 00015 *****************************************************************************/ 00016 #ifndef ROO_STREAM_PARSER 00017 #define ROO_STREAM_PARSER 00018 00019 #include "Riosfwd.h" 00020 #include "TString.h" 00021 00022 class RooStreamParser { 00023 public: 00024 // Constructors, assignment etc. 00025 RooStreamParser(istream& is) ; 00026 RooStreamParser(istream& is, const TString& errPrefix) ; 00027 virtual ~RooStreamParser(); 00028 00029 TString readToken() ; 00030 TString readLine() ; 00031 Bool_t expectToken(const TString& expected, Bool_t zapOnError=kFALSE) ; 00032 void setPunctuation(const TString& punct) ; 00033 TString getPunctuation() const { return _punct ; } 00034 00035 Bool_t readDouble(Double_t& value, Bool_t zapOnError=kFALSE) ; 00036 Bool_t convertToDouble(const TString& token, Double_t& value) ; 00037 00038 Bool_t readInteger(Int_t& value, Bool_t zapOnError=kFALSE) ; 00039 Bool_t convertToInteger(const TString& token, Int_t& value) ; 00040 00041 Bool_t readString(TString& value, Bool_t zapOnError=kFALSE) ; 00042 Bool_t convertToString(const TString& token, TString& string) ; 00043 00044 Bool_t atEOL() ; 00045 inline Bool_t atEOF() { return _atEOF ; } 00046 void zapToEnd(Bool_t inclContLines=kFALSE) ; 00047 00048 Bool_t isPunctChar(char c) const ; 00049 00050 protected: 00051 00052 istream* _is ; 00053 Bool_t _atEOL ; 00054 Bool_t _atEOF ; 00055 TString _prefix ; 00056 TString _punct ; 00057 00058 00059 ClassDef(RooStreamParser,0) // Utility class that parses iostream data into tokens 00060 }; 00061 00062 #endif