On Tue, 15 May 2012 19:43:05 -0400, Sean Kelly <[email protected]>
wrote:
One thing I'd like in a buffered input API is a way to perform
transactional reads such that if the full read can't be performed, the
read state remains unchanged. The best you can do with most APIs is to
check for a desired length, but what I'd I don't want to read until a
full line is available, and I don't know the exact length? Typically,
you end up having to double buffer, which stinks.
My new design supports this. I have a function called readUntil:
https://github.com/schveiguy/phobos/blob/new-io2/std/io.d#L832
Essentially, it reads into its buffer until the condition is satisfied.
Therefore, you are not double buffering. The return value is a slice of
the buffer.
There is a way to opt-out of reading any data if you determine you cannot
do a full read. Just return 0 from the delegate.
-Steve