ByLineSourceRange

ByLineSourceRange is an input range that iterates over a set of input files. It provides bufferedByLine access to each file.

A ByLineSourceRange is used to iterate over a set of files passed on the command line. Files are automatically opened and closed during iteration. The front element of the range provides access to a bufferedByLine for iterating over the lines in the file.

The range is created from a set of filepaths. These filepaths are mapped to ByLineSource objects during the iteration. This is what enables automatically opening and closing files and providing bufferedByLine access.

The motivation behind ByLineSourceRange is to provide a standard way to look at the header line of the first input file during command line argument processing, and then pass the open input file along to the main processing functions. This enables features like named fields to be implemented in a standard way.

Access to the first line of the first file is available after creating the ByLineSourceRange instance. The first file is opened and a bufferedByLine created. The first line of the first file is via byLine.front (after checking !byLine.empty).

Buffering is handled by bufferedByLine. Full buffering is used by default, this can be changed to line buffering by Yes.lineBuffered. When using full buffering, the header line (first line) of the first file can read as soon as available using Yes.readHeader. This is only done for the first file, as that is when immediate processing is useful.

Both ByLineSourceRange and ByLineSource are reference objects. This keeps their use limited to a single iteration over the set of files. The files can be iterated again by creating a new InputSourceRange against the same filepaths.

Currently, ByLineSourceRange supports files and standard input. It is possible other types of input sources will be added in the future.

final
class ByLineSourceRange (
KeepTerminator keepTerminator = No.keepTerminator
Char = char
ubyte terminator = '\n'
) if (
is(Char == char) ||
is(Char == ubyte)
) {}

Constructors

this
this(string[] filepaths, LineBuffered lineBuffered, ReadHeader readHeader)
Undocumented in source.

Members

Aliases

ByLineSourceType
alias ByLineSourceType = ByLineSource!(keepTerminator, char, terminator)
Undocumented in source.

Functions

empty
bool empty()
Undocumented in source. Be warned that the author may not have intended to support it.
front
ByLineSourceType front()
Undocumented in source. Be warned that the author may not have intended to support it.
length
size_t length()
Undocumented in source. Be warned that the author may not have intended to support it.
popFront
void popFront()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta