[Interest] QFile::size() and QTextStream::pos()

Thiago Macieira thiago.macieira at intel.com
Thu Oct 29 22:05:28 CET 2015


On Thursday 29 October 2015 21:49:40 Igor Mironchik wrote:
> On 29.10.2015 06:51, Thiago Macieira wrote:
> > On Thursday 29 October 2015 05:51:36 Igor Mironchik wrote:
> >> P.S. Why QTextStream doesn't have something like get(), peek(), unget(),
> >> putback()?
> > 
> > Explain what you would want those functions to do.
> 
> The same like in std::istream, for example...

The iostreams are, in my opinion, the worst part of the Standard Library. I 
don't consider them a good implementation, even if they have good ideas (<< 
and >>).

istream			QTextStream
get				read and readLine
	the overload with a delimiter: there was a discussion about replacing 	
	readLine with that, but it hasn't happened
peek			<missing, no one has ever asked for it>
unget			seek(pos() - 1) (slow! can't be avoided)
putback			<missing, really bad idea!>

putback does the same as unget, plus adds a character that wasn't necessarily 
the last character that was read. Plus, the function has implementation-
defined behaviour.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list