[Positioning] TextFileReader: handle comments

TextFileReader::read_nonblank_line() now skips lines beginning with a #,
or with blank characters and then #.
This commit is contained in:
Matteo Cypriani 2010-04-01 19:43:46 +02:00
parent 675d2d7213
commit 2d4c90e4cd
1 changed files with 6 additions and 4 deletions

View File

@ -32,9 +32,11 @@ TextFileReader::~TextFileReader()
/** /**
* Tabs and spaces at the begining of a * Blank lines or lines containing only blank characters are skipped.
* line are deleted. * Tabs and spaces at the begining of a line are deleted.
* \em text is unchanged in case of error. * If the first non-blank character of a line is a #, then the line is
* skipped (note that comments at the end of a line are *not* handled).
* @param text Output argument; unchanged in case of error.
* @return false in case of error, true else. * @return false in case of error, true else.
*/ */
bool TextFileReader::read_nonblank_line(string &text) bool TextFileReader::read_nonblank_line(string &text)
@ -46,7 +48,7 @@ bool TextFileReader::read_nonblank_line(string &text)
if (! read_line(line)) if (! read_line(line))
return false ; return false ;
while ((first_non_blank = line.find_first_not_of(" \t")) while ((first_non_blank = line.find_first_not_of(" \t"))
== string::npos) ; == string::npos || line.at(first_non_blank) == '#') ;
line.erase(0, first_non_blank) ; line.erase(0, first_non_blank) ;
text = line ; text = line ;