69 bool moreAvailable =
true;
70 while (toReport.length() == 0) {
71 const std::string::size_type idx =
myStrBuffer.find(
'\n');
77 if (idx != std::string::npos) {
88 noBytes = noBytes > 1024 ? 1024 : noBytes;
93 moreAvailable =
false;
95 return lh.
report(toReport);
101 int idx = (int)toReport.length() - 1;
102 while (idx >= 0 && toReport[idx] < 32) {
106 toReport = toReport.substr(0, idx + 1);
111 if (!lh.
report(toReport)) {
114 return moreAvailable;
120 std::string toReport;
121 while (toReport.length() == 0 &&
myStrm.good()) {
122 const std::string::size_type idx =
myStrBuffer.find(
'\n');
129 if (idx != std::string::npos) {
140 noBytes = noBytes > 1024 ? 1024 : noBytes;
146 if (toReport ==
"") {
157 int idx = (int)toReport.length() - 1;
158 while (idx >= 0 && toReport[idx] < 32) {
162 toReport = toReport.substr(0, idx + 1);
199 myStrm.unsetf(std::ios::skipws);
200 myStrm.seekg(0, std::ios::end);
202 myStrm.seekg(0, std::ios::beg);
209 myStrm.seekg(0, std::ios::beg);
221 myStrm.seekg(pos, std::ios::beg);
Interface definition for a class which retrieves lines from a LineHandler.
virtual bool report(const std::string &result)=0
Method that obatins a line read by the LineReader.
void setPos(unsigned long pos)
Sets the current position within the file to the given value.
unsigned long getPosition()
Returns the current position within the file.
bool good() const
Returns the information whether the stream is readable.
int myRead
Information about how many characters were supplied to the LineHandler.
int myRread
Information how many bytes were read by the reader from the file.
int myAvailable
Information how many bytes are available within the used file.
std::string readLine()
Reads a single (the next) line from the file and returns it.
bool setFile(const std::string &file)
Reinitialises the reader for reading from the given file.
void reinit()
Reinitialises the reading (of the previous file)
int myLinesRead
Information how many lines were read for meaningful error messages.
bool hasMore() const
Returns whether another line may be read (the file was not read completely)
std::string getFileName() const
Returns the name of the used file.
std::ifstream myStrm
the stream used
std::string myFileName
the name of the file to read the contents from
char myBuffer[1024]
To override MSVC++-bugs, we use an own getline which uses this buffer.
std::string myStrBuffer
a string-buffer
void readAll(LineHandler &lh)
Reads the whole file linewise, reporting every line to the given LineHandler.