|
SUMO - Simulation of Urban MObility
|
Retrieves a file linewise and reports the lines to a handler. More...
#include <LineReader.h>
Public Member Functions | |
| void | close () throw () |
| Closes the reading. | |
| std::string | getFileName () const throw () |
| Returns the name of the used file. | |
| unsigned long | getPosition () throw () |
| Returns the current position within the file. | |
| bool | good () const throw () |
| Returns the information whether the stream is readable. | |
| bool | hasMore () const throw () |
| Returns whether another line may be read (the file was not read completely) | |
| LineReader (const std::string &file) throw () | |
| Constructor. | |
| LineReader () throw () | |
| Constructor. | |
| void | readAll (LineHandler &lh) throw (ProcessError) |
| Reads the whole file linewise, reporting every line to the given LineHandler. | |
| std::string | readLine () throw () |
| Reads a single (the next) line from the file and returns it. | |
| bool | readLine (LineHandler &lh) throw (ProcessError) |
| Reads a single (the next) line from the file and reports it to the given LineHandler. | |
| void | reinit () throw () |
| Reinitialises the reading (of the previous file) | |
| bool | setFile (const std::string &file) throw () |
| Reinitialises the reader for reading from the given file. | |
| void | setPos (unsigned long pos) throw () |
| Sets the current position within the file to the given value. | |
| ~LineReader () throw () | |
| Destructor. | |
Private Attributes | |
| unsigned int | myAvailable |
| Information how many bytes are available within the used file. | |
| char | myBuffer [1024] |
| To override MSVC++-bugs, we use an own getline which uses this buffer. | |
| std::string | myFileName |
| the name of the file to read the contents from | |
| unsigned int | myRead |
| Information about how many characters were supplied to the LineHandler. | |
| unsigned int | myRread |
| Information how many bytes were read by the reader from the file. | |
| std::string | myStrBuffer |
| a string-buffer | |
| std::ifstream | myStrm |
| the stream used | |
Retrieves a file linewise and reports the lines to a handler.
This class reads the contents from a file line by line and report them to a LineHandler-derivate.
No checks are done so far during reading/setting position etc.
Should not IOError be thrown if something fails?
Definition at line 56 of file LineReader.h.
| LineReader::LineReader | ( | ) | throw () |
Constructor.
Definition at line 47 of file LineReader.cpp.
| LineReader::LineReader | ( | const std::string & | file | ) | throw () |
Constructor.
Initialises reading from the file with the given name using setFile.
| [in] | file | The name of the file to open |
Definition at line 50 of file LineReader.cpp.
| LineReader::~LineReader | ( | ) | throw () |
Destructor.
Definition at line 57 of file LineReader.cpp.
| void LineReader::close | ( | ) | throw () |
Closes the reading.
| std::string LineReader::getFileName | ( | ) | const throw () |
Returns the name of the used file.
Definition at line 182 of file LineReader.cpp.
References myFileName.
Referenced by RODFDetFlowLoader::read(), readO(), and readV().
| unsigned long LineReader::getPosition | ( | ) | throw () |
Returns the current position within the file.
Definition at line 196 of file LineReader.cpp.
References myRread.
Referenced by NIImporter_VISUM::load().
| bool LineReader::good | ( | ) | const throw () |
Returns the information whether the stream is readable.
Definition at line 228 of file LineReader.cpp.
References myStrm.
Referenced by getNextNonCommentLine(), and loadMatrix().
| bool LineReader::hasMore | ( | ) | const throw () |
Returns whether another line may be read (the file was not read completely)
Definition at line 61 of file LineReader.cpp.
References myAvailable, and myRread.
Referenced by getNextNonCommentLine(), PCLoaderVisum::load(), NIImporter_VISUM::load(), PCLoaderDlrNavteq::loadPOIFile(), PCLoaderDlrNavteq::loadPolyFile(), RODFDetFlowLoader::read(), readO(), and readV().
| void LineReader::readAll | ( | LineHandler & | lh | ) | throw (ProcessError) |
Reads the whole file linewise, reporting every line to the given LineHandler.
When the LineHandler returns false, the reading will be aborted
| [in] | lh | The LineHandler to report read lines to |
Definition at line 67 of file LineReader.cpp.
Referenced by NIImporter_DlrNavteq::loadNetwork().
| std::string LineReader::readLine | ( | ) | throw () |
Reads a single (the next) line from the file and returns it.
Definition at line 129 of file LineReader.cpp.
References myAvailable, myBuffer, myRead, myRread, myStrBuffer, and myStrm.
| bool LineReader::readLine | ( | LineHandler & | lh | ) | throw (ProcessError) |
Reads a single (the next) line from the file and reports it to the given LineHandler.
When the LineHandler returns false, the reading will be aborted
| [in] | lh | The LineHandler to report read lines to |
Definition at line 77 of file LineReader.cpp.
Referenced by getNextNonCommentLine(), PCLoaderVisum::load(), NIImporter_VISUM::load(), loadMatrix(), PCLoaderDlrNavteq::loadPOIFile(), PCLoaderDlrNavteq::loadPolyFile(), and RODFDetFlowLoader::read().
| void LineReader::reinit | ( | ) | throw () |
Reinitialises the reading (of the previous file)
Definition at line 202 of file LineReader.cpp.
References myAvailable, myFileName, myRead, myRread, myStrBuffer, and myStrm.
Referenced by PCLoaderVisum::load(), and NIImporter_VISUM::load().
| bool LineReader::setFile | ( | const std::string & | file | ) | throw () |
Reinitialises the reader for reading from the given file.
Returns false when the file is not readable
| [in] | file | The name of the file to open |
Definition at line 188 of file LineReader.cpp.
Referenced by NIImporter_VISUM::load(), and NIImporter_DlrNavteq::loadNetwork().
| void LineReader::setPos | ( | unsigned long | pos | ) | throw () |
Sets the current position within the file to the given value.
| [in] | pos | The new position within the file |
Definition at line 219 of file LineReader.cpp.
Referenced by NIImporter_VISUM::load().
unsigned int LineReader::myAvailable [private] |
Information how many bytes are available within the used file.
Definition at line 168 of file LineReader.h.
Referenced by hasMore(), readLine(), and reinit().
char LineReader::myBuffer[1024] [private] |
To override MSVC++-bugs, we use an own getline which uses this buffer.
Definition at line 159 of file LineReader.h.
Referenced by readLine().
std::string LineReader::myFileName [private] |
the name of the file to read the contents from
Definition at line 153 of file LineReader.h.
Referenced by getFileName(), and reinit().
unsigned int LineReader::myRead [private] |
Information about how many characters were supplied to the LineHandler.
Definition at line 165 of file LineReader.h.
Referenced by readLine(), and reinit().
unsigned int LineReader::myRread [private] |
Information how many bytes were read by the reader from the file.
Definition at line 171 of file LineReader.h.
Referenced by getPosition(), hasMore(), readLine(), and reinit().
std::string LineReader::myStrBuffer [private] |
a string-buffer
Definition at line 162 of file LineReader.h.
Referenced by readLine(), and reinit().
std::ifstream LineReader::myStrm [private] |
the stream used
Definition at line 156 of file LineReader.h.
Referenced by good(), readLine(), and reinit().