On Wed, 16 May 2012 11:48:32 -0400, Dmitry Olshansky
<[email protected]> wrote:
On 16.05.2012 19:32, Steven Schveighoffer wrote:
On Wed, 16 May 2012 11:19:46 -0400, Robert Clipsham
<[email protected]> wrote:
A bit ugly but:
----
// Default to 4 byte chunks
auto range = myStream.byChunks(4);
foreach (chunk; range) {
// Set the next chunk is 3 bytes
// Chunk after is 4 bytes
range.nextChunkSize = 3;
// Next chunk is always 5 bytes
range.chunkSize = 5;
}
Yeah, I've seen this before. It's not convincing.
Yes, It's obvious that files do *not* generally follow range of items
semantic. I mean not even range of various items.
In case of binary data it's most of the time header followed by various
data. Or hierarchical structure. Or table of links + raw data.
Or whatever. I've yet to see standard way to deal with binary formats :)
The best solution would be a range that's specific to your format. My
solution intends to support that.
But that's only if your format fits within the "range of elements" model.
Good old fashioned "read X bytes" needs to be supported, and insisting you
do this range style is just plain wrong IMO.
-Steve