// $Id: FileParser.hh,v 1.1 2005/05/19 15:23:57 thea Exp $ // Author: Alessandro Thea 2005/05/17 /***************************************************************************** * ESAF: Euso Simulation and Analysis Framework * * * * Id: FileParser * * Package: * * Coordinator: * * * *****************************************************************************/ #ifndef __FILEPARSER_HH__ #define __FILEPARSER_HH__ #include "euso.hh" #include "EsafMsgSource.hh" #include #include #include //////////////////////////////////////////////////////////////////////////////// // // // FileParser // // // // // // // //////////////////////////////////////////////////////////////////////////////// class FileParser : public EsafMsgSource { public: FileParser( const string& path ); virtual ~FileParser(); virtual void AddComment( const char* ); virtual void AddDelimiter( const char ); virtual void ClearComments(); virtual void Dump() const; const char* GetDelimiters() const; void SetDelimiters( const char* ); //protected: virtual Bool_t ParseLine( string line ); string& SwallowSpaces(string &s); string& RSwallowSpaces(string &s); private: string fFileName; string fPath; // this config file name string fDelimiters; list fComments; list< list > fWords; // table of strings ClassDef(FileParser,0) }; inline string& FileParser::SwallowSpaces( string& s ) { return s.erase(0, s.find_first_not_of(" \t")); } inline string& FileParser::RSwallowSpaces( string& s ) { return s.erase(s.find_last_not_of("\t ")+1, string::npos); } inline void FileParser::AddComment( const char* s ) { fComments.push_back( s ); } inline void FileParser::AddDelimiter( const char c ) { fDelimiters += c; } inline void FileParser::ClearComments() { fComments.clear(); } inline const char* FileParser::GetDelimiters() const { return fDelimiters.c_str(); } inline void FileParser::SetDelimiters( const char* s ) { fDelimiters = s; } #endif /* __FILEPARSER_HH__ */