[Qt-interest] Is there any hope for the pos() method when used with a QTextStream?
Atlant Schmidt
aschmidt at dekaresearch.com
Fri Sep 9 13:03:37 CEST 2011
Thiago:
Thanks for confirming my suspicions; I'll switch
to some other approach.
All:
Suggestions on the alternative approach are still
very-much welcome. At the moment, I see three
alternatives (in no particular order):
o Substitute POSIX calls for the Qt calls.
o Keep an array of QStrings that represent
the complete text on the pages I've passed
by, "lazy loading" those strings as I move
forward to newly-encountered pages in my
file.
o Using my own line count, move backwards by
"rewinding" the file to the beginning and
then reading forwards again to the newly-
desired line.
Atlant
-----Original Message-----
From: qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com [mailto:qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com] On Behalf Of Thiago Macieira
Sent: Thursday, September 08, 2011 18:53
To: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] Is there any hope for the pos() method when used with a QTextStream?
On Thursday, 8 de September de 2011 17:00:04 Atlant Schmidt wrote:
> 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.)
Forget pos(). Keep the line number and column number instead.
The existence of pos() in QTextStream is a flaw in design. Trying to keep a
byte count in a buffered stream, after converting from an arbitrary 8-bit codec
into UTF-16, is close to impossible.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
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.
More information about the Qt-interest-old
mailing list