PDA

View Full Version : QTextStream help pls



munna
16th May 2006, 18:10
Hi,

I am trying to parse a text file. There are a few constraints.

1. If a line ends with "=", then the next line should also be read from the stream and should be added to the current line before sending it to the parse function.

2. If the next line starts with " "(space) then the line should be added to current line and then should be sent to the parse function.

Can someone please help me in this?
Thanks a lot.

wysota
16th May 2006, 18:22
So what problems do you experience?

munna
16th May 2006, 18:25
How can I use QTextStream to read the lines satisfying the above conditions ?

Thanks a lot

wysota
16th May 2006, 18:28
Read lines one by one and check those conditions using for example QString::endsWith(). You'll probably have to use QIODevice::peek() to check the first character of the next line.

munna
16th May 2006, 18:36
Another doubt:

Since I use QTextStream to read the file, how will QFile know about the current position, so that peek() can be used?

Thanks

jpn
16th May 2006, 18:45
Since I use QTextStream to read the file, how will QFile know about the current position, so that peek() can be used?
QTextStream::device() (http://doc.trolltech.com/4.1/qtextstream.html#device)