SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00008 // Retrieves a file linewise and reports the lines to a handler. 00009 /****************************************************************************/ 00010 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00011 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00012 /****************************************************************************/ 00013 // 00014 // This file is part of SUMO. 00015 // SUMO is free software: you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation, either version 3 of the License, or 00018 // (at your option) any later version. 00019 // 00020 /****************************************************************************/ 00021 #ifndef LineReader_h 00022 #define LineReader_h 00023 00024 00025 // =========================================================================== 00026 // included modules 00027 // =========================================================================== 00028 #ifdef _MSC_VER 00029 #include <windows_config.h> 00030 #else 00031 #include <config.h> 00032 #endif 00033 00034 #include <string> 00035 #include <fstream> 00036 #include <utils/common/UtilExceptions.h> 00037 00038 00039 // =========================================================================== 00040 // class declarations 00041 // =========================================================================== 00042 class LineHandler; 00043 00044 00045 // =========================================================================== 00046 // class definitions 00047 // =========================================================================== 00058 class LineReader { 00059 public: 00061 LineReader() ; 00062 00063 00071 LineReader(const std::string& file) ; 00072 00073 00075 ~LineReader() ; 00076 00077 00081 bool hasMore() const ; 00082 00083 00090 void readAll(LineHandler& lh) ; 00091 00092 00100 bool readLine(LineHandler& lh) ; 00101 00102 00107 std::string readLine() ; 00108 00109 00111 void close() ; 00112 00113 00117 std::string getFileName() const ; 00118 00119 00127 bool setFile(const std::string& file) ; 00128 00129 00133 unsigned long getPosition() ; 00134 00135 00137 void reinit() ; 00138 00139 00144 void setPos(unsigned long pos) ; 00145 00146 00150 bool good() const ; 00151 00152 00153 private: 00155 std::string myFileName; 00156 00158 std::ifstream myStrm; 00159 00161 char myBuffer[1024]; 00162 00164 std::string myStrBuffer; 00165 00167 unsigned int myRead; 00168 00170 unsigned int myAvailable; 00171 00173 unsigned int myRread; 00174 00175 }; 00176 00177 00178 #endif 00179 00180 /****************************************************************************/ 00181