An IO Streams Library

Johannes Pfau via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 26 07:50:28 PDT 2016


Am Mon, 25 Jul 2016 13:10:42 +0000
schrieb ikod <geller.garry at gmail.com>:

> On Sunday, 7 February 2016 at 00:48:54 UTC, Jason White wrote:
> > I see the subject of IO streams brought up here occasionally. 
> > The general consensus seems to be that we need something better 
> > than what Phobos provides.
> >
> > I wrote a library "io" that can work as a replacement for 
> > std.stdio, std.mmfile, std.cstream, and parts of std.stream:
> >
> >     GitHub:  https://github.com/jasonwhite/io
> >     Package: https://code.dlang.org/packages/io
> >
> > This library provides an input and output range interface for 
> > streams (which is more efficient if the stream is buffered). 
> > Thus, many of the wonderful range operations from std.range and 
> > std.algorithm can be used with this.
> >
> > I'm interested in feedback on this library. What is it missing? 
> > How can be better?
> >
> > I'm also interested in a discussion of what IO-related 
> > functionality people are missing in Phobos.
> >
> > Please destroy!  
> 
> 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.


More information about the Digitalmars-d mailing list