streaming redux

Dmitry Olshansky dmitry.olsh at gmail.com
Thu Dec 30 15:56:03 PST 2010


On 31.12.2010 1:17, Andrei Alexandrescu wrote:
> On 12/30/10 3:59 PM, Dmitry Olshansky wrote:
>> On 28.12.2010 16:08, Daniel Gibson wrote:
>> [snip]
>>> ## UnbufferedInputTransport:
>>>
>>> I'd like "void readFully(ubyte[] buffer)" which reads buffer.length
>>> bytes or throws an exception if that is not possible
>>> This would also fix busy-waiting (it'd block until buffer.length bytes
>>> are available).
>>>
>>> Also "size_t read(void* buffer, size_t length)" (and the same for
>>> readFully()) would be nice, so one can read from the stream to buffers
>>> of arbitrary type without too much casting. Is probably especially
>>> handy when used with (data from) extern(C) functions and such.
>>>
>>> Also, for convenience: "ubyte[] read(size_t length)" (does something
>>> like "return read(new ubyte[length]);"
>>> and "ubyte[] readFully(size_t length)"
>>
>> This, I guess, would be provided by free functions in the same module,
>> there is no point in requiring to implement them inside the stream 
>> itself.
>>>
>>> ## UnbufferedOutputTransport:
>>>
>>> I'd like "void write(void *buffer, size_t length)" - for the same
>>> reason as read(void* buffer, size_t length).
>>
>> Ditto
>
> What's wrong with void[]?
>
> Andrei

Nothing, in fact  I was repyling  to
---
I'd like "void readFully(ubyte[] buffer)" which reads buffer.length
bytes or throws an exception if that is not possible
This would also fix busy-waiting (it'd block until buffer.length bytes
are available).
[snip]
Also, for convenience: "ubyte[] read(size_t length)" (does something
like "return read(new ubyte[length]);"
and "ubyte[] readFully(size_t length)" ...
---
I should have made it clearer.

-- 
Dmitry Olshansky



More information about the Digitalmars-d mailing list