std.stream.EndianStream ...
nescire
chrysme at gmail.com
Thu Feb 8 12:44:58 PST 2007
torhu Wrote:
> >>> And the following code compiles:
> >>>
> >>> EndianStream es = new EndianStream( new MemoryStream() );
> >>> ubyte b;
> >>> (cast(InputStream) es).read( b );
> >>>
> >>>
> >>> Could someone explain? Am I missing something obvious, or is it a
> >>> compiler bug?
> >>
> >>
> >> I'm guessing this makes it call Stream's version of read(ubyte), which
> >> will give the wrong result.
> >
> > Why is that the wrong result? EndianStream only swaps when reading
> > multi-byte data since there's nothing to swap with a single byte.
> >
>
> Is EndianStream supposed to be used for single-byte reads too?
It seemed to me that EndianStream was supposed to wrap a source stream to provide byte swapping on multi-byte read/write. I don't think the rest of FilterStream's functionality should be affected.
The stream itself doesn't necesserily contain multi-byte data only, e.g. it can contain flag bytes, followed by multi-byte data (which is what I wanted to use EndianStream for).
And by the way, thanks for the help!
More information about the Digitalmars-d-learn
mailing list