ByLineFast

Reads by line in an efficient way (10 times faster than File.byLine from std.stdio). This is accomplished by reading entire buffers (fgetc() is not used), and allocating as little as possible.

The char \n is considered as default separator, removing the previous \r if it exists.

The \n is never returned. The \r is not returned if it was part of a \r\n (but it is returned if it was by itself).

The returned string is always a substring of a temporary buffer, that must not be stored. If necessary, you must use str[] or .dup or .idup to copy to another string. DIP-25 return qualifier is used in front() to add extra checks in @safe callers of front().

Constructors

this
this(File f, KeepTerminator kt, string separator, uint bufferSize)
Undocumented in source.

Members

Functions

empty
bool empty()
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.

Properties

front
char[] front [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

buffer
char[] buffer;
Undocumented in source.
file
File file;
Undocumented in source.
first_call
bool first_call;
Undocumented in source.
keepTerminator
KeepTerminator keepTerminator;
Undocumented in source.
line
char[] line;
Undocumented in source.
separator
string separator;
Undocumented in source.
strBuffer
char[] strBuffer;
Undocumented in source.

Examples

File f = File("file.txt"); foreach (string line; ByLineFast(f)) { ...process line... //Make a copy: string copy = line[]; }

The file isn't closed when done iterating, unless it was the only reference to the file (same as std.stdio.byLine). (example: ByLineFast(File("file.txt"))).

Meta