Index:
[thread]
[date]
[subject]
[author]
From: Garrett Mitchener <wgm2@acpub.duke.edu>
To :
Date: 08 Feb 1999 21:39:40 -0500
Re: Streams
Janel Levon Baskerville <jlb18@acpub.duke.edu> writes:
> Does anyone know if it is possible to put a line back onto the stream
> once it is read off?? We used istream and tried the putback function but
> that can only be passed characters. Do any of the other streams carry a
> function like this so that we can but line back on the stream as
> desired??
>
> Janel and Angel
I don't think streams are powerful enough to do what you want.
This is another design issue that people run into. Often, a hash map,
list, vector, or stream may seem to be the heart of what you want to
do, but just isn't powerful enough. This means you are thinking too
much about the implementation and letting it limit you.
When a library data structure or class seems to do almost what you
want but is too limited, write a more powerful class that does exactly
what you want and implement it with the library class. Don't be
afraid to write small, simple classes.
Consider writing a buffer class of some kind which reads from a stream
when you ask for more data than it has, but which allows you to put
stuff back after reading it. To implement it, you might consider
using a deque of chars. (double ended queue, look in STL under
<queue>)
-- Garrett *<:-)
Index:
[thread]
[date]
[subject]
[author]