reading from a ubyte[] | byte[] as if from a stream? (Phobos)

Charles Hixson charleshixsn at earthlink.net
Thu Sep 18 13:51:03 PDT 2008


Tomas Lindquist Olsen wrote:
> BCS wrote:
>> Reply to Charles,
>>
>>> Is it possible to read from a byte or ubyte array as if from a stream?
>>> It looks like it should be not only possible, but easy...but I haven't
>>> figured it out.
>>>
>>> BufferedFile *MUST* do that kind of thing internally, but it feels
>>> like there ought to be a way to say "This array is your data, read
>>> from it!" rather than digging through the guts of it and copying all
>>> the relevant code into a separate code-space.
>>>
>>
>> MemoryStream
>> http://www.digitalmars.com/d/1.0/phobos/std_stream.html
>>
>>
> 
>  From what I read, MemoryStream copies, TArrayStream does not
> Not sure what's wanted here though :)
Thanks to the both!

TArrayStream would be what I want, except that it seems to require that 
the compilation be in release mode.  I'm going to need to study just 
what that means.  But if it isn't what's needed, then MemoryStream seems 
a reasonable alternative.

(My suspicion is that it only constructs an array of bytes of memory if 
you don't pass it a buffer...but I haven't checked.  The documentation 
sure seems to say that it copies the buffer.)


More information about the Digitalmars-d-learn mailing list