bufferedByLine

bufferedByLine is a performance enhancement over std.stdio.File.byLine. It works by reading a large buffer from the input stream rather than just a single line.

The file argument needs to be a File object open for reading, typically a filesystem file or standard input. Use the Yes.keepTerminator template parameter to keep the newline. This is similar to stdio.File.byLine, except specified as a template paramter rather than a runtime parameter.

Reading in blocks does mean that input is not read until a full buffer is available or end-of-file is reached. Reading each line as it is available can be enabled by setting the lineBuffered parameter to Yes.lineBuffered. In this case bufferedByLine behaves like stdio.File.byLine.

As a separate option, the first line of the file can be read as soon as it is available, without waiting for a complete buffer. This is useful for reading the header line before the rest of the data is available. Set the readHeader parameter to Yes.readHeader to get this behavior.

bufferedByLine
(
KeepTerminator keepTerminator = No.keepTerminator
Char = char
ubyte terminator = '\n'
size_t readSize = 1024 * 128
size_t growSize = 1024 * 16
)
(
File file
,
LineBuffered lineBuffered = No.lineBuffered
,
ReadHeader readHeader = No.readHeader
)
if (
is(Char == char) ||
is(Char == ubyte)
)

Meta