An IO Streams Library

Sönke Ludwig via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 26 23:18:07 PDT 2016


Am 26.07.2016 um 16:50 schrieb Johannes Pfau:
> Am Mon, 25 Jul 2016 13:10:42 +0000
>>
>> Hello,
>>
>> I don't know if it is good practice or not, but sometimes it make
>> life easier if you can put part of the data back into the input
>> stream.
>>
>
> Writing data back to a stream is quite uncommon. The standard way to
> solve such problems is a peek method for buffered streams:
>
> auto buf = stream.peek(length)
> // You can now look at the data in buf
> stream.read() will still return the data read by peek, no need to write
> data back into the stream.
>

With the notable exception of ungetc() for C's file streams. But working 
on the byte level is something that ranges should be used for in D's 
case and not streams, because the latter tend to have a high call 
overhead. So such a feature could make sense for a 
StreamInputRange/InputStreamRange wrapper.


More information about the Digitalmars-d mailing list