[Qt-interest] Is there any hope for the pos() method when used with a QTextStream?
Atlant Schmidt
aschmidt at dekaresearch.com
Thu Sep 8 23:00:04 CEST 2011
Folks:
So I wrote this wonderful algorithm that ought to let my users page
their way forwards and backwards through this huge text file of
Open Source licensing information that we maintain. You know
the drill: "This device uses Open Source software licensed under
various licenses and we'll now bore you to tears listing them all..."
I wrote this algorithm using a QTextStream and readLine(), and as
I read forward through my file, I attempted to save the byte offset
that would represent the start of each page of licensing info; these
byte offsets ought to let me easily seek() back to a previous page.
I obtained those byte offsets by calling myTextStream_ptr->pos().
Unfortunately, after the first page or two, not only does that *NOT*
give me valid byte offsets, but it also screws up the reading process
so that 1) the readLine() operations don't give me the expected data
and 2) I never reach End-of-File.
And this is apparently a well-known problem: On Googling, I quickly
found:
o https://bugreports.qt.nokia.com/browse/QTBUG-9814<https://bugreports.qt.nokia.com/browse/QTBUG-9814?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel>
and
o https://bugreports.qt.nokia.com/browse/QTBUG-9989
both of which seem to directly relate to this problem and neither of
which are fixed nor have they seen any action in a long time.
So, is there any hope for me? I already keep a line count so when I need
to page backwards, I *COULD* close and re-open the file and then read
forward to the new position that I want, but that seems like using a punch
card solution in the smartphone age*. Has QTextStream::pos() been fixed?
If not, can it be fixed? And if it isn't/can't, has anyone got any better ideas
for alternatives? (I'd prefer not to keep several tens of thousands of lines
of text in an array of QStrings in memory, although that would work too.)
Atlant
*And unlike QTextStream, even magtapes implemented a rewind()
operation.
________________________________
This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.
Thank you.
Please consider the environment before printing this email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110908/c56f4a67/attachment.html
More information about the Qt-interest-old
mailing list