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.
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.