|
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 () |
| Closes the reading. More... | |
| std::string | getFileName () const |
| Returns the name of the used file. More... | |
| unsigned long | getPosition () |
| Returns the current position within the file. More... | |
| bool | good () const |
| Returns the information whether the stream is readable. More... | |
| bool | hasMore () const |
| Returns whether another line may be read (the file was not read completely) More... | |
| LineReader () | |
| Constructor. More... | |
| LineReader (const std::string &file) | |
| Constructor. More... | |
| void | readAll (LineHandler &lh) |
| Reads the whole file linewise, reporting every line to the given LineHandler. More... | |
| bool | readLine (LineHandler &lh) |
| Reads a single (the next) line from the file and reports it to the given LineHandler. More... | |
| std::string | readLine () |
| Reads a single (the next) line from the file and returns it. More... | |
| void | reinit () |
| Reinitialises the reading (of the previous file) More... | |
| bool | setFile (const std::string &file) |
| Reinitialises the reader for reading from the given file. More... | |
| void | setPos (unsigned long pos) |
| Sets the current position within the file to the given value. More... | |
| ~LineReader () | |
| Destructor. More... | |
Private Attributes | |
| unsigned int | myAvailable |
| Information how many bytes are available within the used file. More... | |
| char | myBuffer [1024] |
| To override MSVC++-bugs, we use an own getline which uses this buffer. More... | |
| std::string | myFileName |
| the name of the file to read the contents from More... | |
| unsigned int | myRead |
| Information about how many characters were supplied to the LineHandler. More... | |
| unsigned int | myRread |
| Information how many bytes were read by the reader from the file. More... | |
| std::string | myStrBuffer |
| a string-buffer More... | |
| std::ifstream | myStrm |
| the stream used More... | |
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 58 of file LineReader.h.
| LineReader::LineReader | ( | ) |
Constructor.
Definition at line 50 of file LineReader.cpp.
| LineReader::LineReader | ( | const std::string & | file | ) |
Constructor.
Initialises reading from the file with the given name using setFile.
| [in] | file | The name of the file to open |
Definition at line 53 of file LineReader.cpp.
References reinit().
| LineReader::~LineReader | ( | ) |
Destructor.
Definition at line 60 of file LineReader.cpp.
| void LineReader::close | ( | ) |
Closes the reading.
| std::string LineReader::getFileName | ( | ) | const |
Returns the name of the used file.
Definition at line 183 of file LineReader.cpp.
References myFileName.
Referenced by RODFDetFlowLoader::read(), ODMatrix::readO(), and ODMatrix::readV().
| unsigned long LineReader::getPosition | ( | ) |
Returns the current position within the file.
Definition at line 197 of file LineReader.cpp.
References myRread.
Referenced by NIImporter_VISUM::load().
| bool LineReader::good | ( | ) | const |
Returns the information whether the stream is readable.
Definition at line 229 of file LineReader.cpp.
References myStrm.
Referenced by ODMatrix::getNextNonCommentLine(), and ODMatrix::loadMatrix().
| bool LineReader::hasMore | ( | ) | const |
Returns whether another line may be read (the file was not read completely)
Definition at line 64 of file LineReader.cpp.
References myAvailable, and myRread.
Referenced by ODMatrix::getNextNonCommentLine(), PCLoaderVisum::load(), NIImporter_VISUM::load(), PCLoaderDlrNavteq::loadPOIFile(), PCLoaderDlrNavteq::loadPolyFile(), RODFDetFlowLoader::read(), ODMatrix::readO(), and ODMatrix::readV().
| void LineReader::readAll | ( | LineHandler & | lh | ) |
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 70 of file LineReader.cpp.
References myAvailable, myRread, and readLine().
Referenced by NIImporter_DlrNavteq::loadNetwork().
| bool LineReader::readLine | ( | LineHandler & | lh | ) |
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 80 of file LineReader.cpp.
References myAvailable, myBuffer, myRead, myRread, myStrBuffer, myStrm, and LineHandler::report().
Referenced by ODMatrix::getNextNonCommentLine(), PCLoaderVisum::load(), NIImporter_VISUM::load(), ODMatrix::loadMatrix(), PCLoaderDlrNavteq::loadPOIFile(), PCLoaderDlrNavteq::loadPolyFile(), main(), and RODFDetFlowLoader::read().
| std::string LineReader::readLine | ( | ) |
Reads a single (the next) line from the file and returns it.
Definition at line 132 of file LineReader.cpp.
References myAvailable, myBuffer, myRead, myRread, myStrBuffer, and myStrm.
Referenced by readAll().
| void LineReader::reinit | ( | ) |
Reinitialises the reading (of the previous file)
Definition at line 203 of file LineReader.cpp.
References myAvailable, myFileName, myRead, myRread, myStrBuffer, and myStrm.
Referenced by LineReader(), PCLoaderVisum::load(), NIImporter_VISUM::load(), and setFile().
| bool LineReader::setFile | ( | const std::string & | file | ) |
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 189 of file LineReader.cpp.
References myFileName, myStrm, and reinit().
Referenced by NIImporter_VISUM::load(), and NIImporter_DlrNavteq::loadNetwork().
| void LineReader::setPos | ( | unsigned long | pos | ) |
Sets the current position within the file to the given value.
| [in] | pos | The new position within the file |
Definition at line 220 of file LineReader.cpp.
References myRead, myRread, myStrBuffer, and myStrm.
Referenced by NIImporter_VISUM::load().
|
private |
Information how many bytes are available within the used file.
Definition at line 170 of file LineReader.h.
Referenced by hasMore(), readAll(), readLine(), and reinit().
|
private |
To override MSVC++-bugs, we use an own getline which uses this buffer.
Definition at line 161 of file LineReader.h.
Referenced by readLine().
|
private |
the name of the file to read the contents from
Definition at line 155 of file LineReader.h.
Referenced by getFileName(), reinit(), and setFile().
|
private |
Information about how many characters were supplied to the LineHandler.
Definition at line 167 of file LineReader.h.
Referenced by readLine(), reinit(), and setPos().
|
private |
Information how many bytes were read by the reader from the file.
Definition at line 173 of file LineReader.h.
Referenced by getPosition(), hasMore(), readAll(), readLine(), reinit(), and setPos().
|
private |
a string-buffer
Definition at line 164 of file LineReader.h.
Referenced by readLine(), reinit(), and setPos().
|
private |
the stream used
Definition at line 158 of file LineReader.h.
Referenced by good(), readLine(), reinit(), setFile(), and setPos().