LineReader.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Retrieves a file linewise and reports the lines to a handler.
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 #ifndef LineReader_h
00020 #define LineReader_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include <string>
00033 #include <fstream>
00034 #include <utils/common/UtilExceptions.h>
00035 
00036 
00037 // ===========================================================================
00038 // class declarations
00039 // ===========================================================================
00040 class LineHandler;
00041 
00042 
00043 // ===========================================================================
00044 // class definitions
00045 // ===========================================================================
00056 class LineReader {
00057 public:
00059     LineReader() throw();
00060 
00061 
00069     LineReader(const std::string &file) throw();
00070 
00071 
00073     ~LineReader() throw();
00074 
00075 
00079     bool hasMore() const throw();
00080 
00081 
00088     void readAll(LineHandler &lh) throw(ProcessError);
00089 
00090 
00098     bool readLine(LineHandler &lh) throw(ProcessError);
00099 
00100 
00105     std::string readLine() throw();
00106 
00107 
00109     void close() throw();
00110 
00111 
00115     std::string getFileName() const throw();
00116 
00117 
00125     bool setFile(const std::string &file) throw();
00126 
00127 
00131     unsigned long getPosition() throw();
00132 
00133 
00135     void reinit() throw();
00136 
00137 
00142     void setPos(unsigned long pos) throw();
00143 
00144 
00148     bool good() const throw();
00149 
00150 
00151 private:
00153     std::string myFileName;
00154 
00156     std::ifstream myStrm;
00157 
00159     char myBuffer[1024];
00160 
00162     std::string myStrBuffer;
00163 
00165     unsigned int myRead;
00166 
00168     unsigned int myAvailable;
00169 
00171     unsigned int myRread;
00172 
00173 };
00174 
00175 
00176 #endif
00177 
00178 /****************************************************************************/
00179 

Generated on Wed May 5 00:06:30 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6