reading from a ubyte[] | byte[] as if from a stream? (Phobos)
Tomas Lindquist Olsen
tomas at famolsen.dk
Thu Sep 18 13:20:38 PDT 2008
Charles Hixson wrote:
> 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.
Now, I don't use phobos, but I think you're looking for std.stream.TArrayStream
something like:
---
auto data = new ubyte[1024];
auto str = new TArrayStream!(ubyte[])(data);
ubyte ub;
str.read(ub);
---
HTH
More information about the Digitalmars-d-learn
mailing list