inputSourceByChunk

inputSourceByChunk returns a range that reads either a file handle (File) or a ubyte[] array a chunk at a time.

This is a cover for File.byChunk that allows passing an in-memory array or input range as well. At present the motivation is primarily to enable unit testing of chunk-based algorithms using in-memory strings.

inputSourceByChunk takes either a File open for reading or an input range with ubyte elements. Data is read a buffer at a time. The buffer can be user provided, or allocated by inputSourceByChunk based on a caller provided buffer size.

The primary motivation for supporting both files and input ranges as sources is to enable unit testing of buffer based algorithms using in-memory arrays. Dynamic, mutable arras are fine. Use slicing to turn a static, const, or immutable arrays into an input range.

The chunks are returned as an input range.

  1. auto inputSourceByChunk(InputSource source, size_t size)
  2. auto inputSourceByChunk(InputSource source, ubyte[] buffer)
    inputSourceByChunk
    (
    InputSource
    )
    (
    InputSource source
    ,
    ubyte[] buffer
    )

Meta