70 bool moreAvailable =
true;
71 while (toReport.length() == 0) {
72 const std::string::size_type idx =
myStrBuffer.find(
'\n');
78 if (idx != std::string::npos) {
89 noBytes = noBytes > 1024 ? 1024 : noBytes;
94 moreAvailable =
false;
96 return lh.
report(toReport);
102 int idx = (int)toReport.length() - 1;
103 while (idx >= 0 && toReport[idx] < 32) {
107 toReport = toReport.substr(0, idx + 1);
112 if (!lh.
report(toReport)) {
115 return moreAvailable;
121 std::string toReport;
122 while (toReport.length() == 0 &&
myStrm.good()) {
123 const std::string::size_type idx =
myStrBuffer.find(
'\n');
130 if (idx != std::string::npos) {
141 noBytes = noBytes > 1024 ? 1024 : noBytes;
147 if (toReport ==
"") {
158 int idx = (int)toReport.length() - 1;
159 while (idx >= 0 && toReport[idx] < 32) {
163 toReport = toReport.substr(0, idx + 1);
200 myStrm.unsetf(std::ios::skipws);
201 myStrm.seekg(0, std::ios::end);
203 myStrm.seekg(0, std::ios::beg);
212 myStrm.seekg(0, 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.
int mySkipBOM
Number of skipped characters at the file begin (UTF-8 BOM)
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.