Re: Handling large text streams of integers
On Mar 31, 11:54 pm, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
James Kanze wrote:
A lot of systems maintain the current position in the file
in an std::streamsize. Which means that
std::numeric_limits<std::streamsize>::max() is also the
maximum number of bytes in the file. And that there can't
be that many numbers, since each number requires at least
two bytes (one digit and a separator).
[..]
What if the "file" is actually a serial connection that, like
the Energizer Bunny, just keeps going, and going, and... Will
the system also try to keep track of the "current position" on
a socket, for example?
That's actually a good question. I don't know what the standard
says about it---probably that it's unspecified. (The standard
doesn't require the system to try to keep track of the "current
position". But in practice, it has to, in some way, in order to
know where the next data is to come from.) I suspect that in
practice, most systems "try" to keep track of it, in the sense
that they update it each time with the number of bytes read, but
that they fail in the case of something like a socket, pipe, or
keyboard; but that it doesn't matter, because the next data are
determined automatically, and those devices don't support
seeking (which would also require the position).
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34